1

I have a turbine server running on openshift 3 and deployed a donet core 3.1 c# microservice using steeltoe 3.0.2 circuit breaker libraries. I can monitor the microservice stream on hystrix dashboard through service stream url (/hystrix/hystrix.stream). What I want to do is to register the microservice hystrix event stream to the turbine server event stream. Does anyone know how to do this? any reference link will be a great help also.

Update: project references and setup files configuration

myproject.csproj:

<ItemGroup>
  <PackageReference Include="Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore" Version="3.0.2" />
  <PackageReference Include="Steeltoe.CircuitBreaker.HystrixCore" Version="3.0.2" />
<ItemGroup>

startup.cs: ConfigureServices section

services.AddMvc(options => options.EnableEndpointRouting = false);
services.AddHystrixCommand<MyCircuitBreakerCommand>("MyCircuitBreakerGroup", Configuration);
services.AddHystrixMetricsStream(Configuration);

startup.cs -> Configure section

app.UseHystrixRequestContext();
app.UseHystrixMetricsStream();
app.UseMvc();

I haven't modified program.cs or any .json setting file either.

Recently tried to access these microservice resources: /hystrix/config.stream, /hystrix/request.stream and /hystrix/utilization.stream, but get this internal server error:

Connection id "0HM90GL5F64RK", Request id "0HM90GL5F64RK:00000003": An unhandled exception was thrown by the application. System.InvalidOperationException: Unable to resolve service for type 'Steeltoe.CircuitBreaker.Hystrix.Config.HystrixConfigurationStream' while attempting to activate 'Steeltoe.CircuitBreaker.Hystrix.MetricsEvents.Controllers.HystrixConfigStreamController'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired) at lambda_method(Closure , IServiceProvider , Object[] ) at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.b__0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Steeltoe.CircuitBreaker.Hystrix.HystrixRequestContextMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application) fail: Microsoft.AspNetCore.Server.Kestrel[13]

iperezmel78
  • 415
  • 5
  • 20
  • Can you update this question to include relevant snippets of .csproj, program.cs and startup.cs so we can see which packages you're using and how? Also to make sure I understand the issue, are you saying you're able to use a local hystrix dashboard (using an HTTP stream), but not one that uses a service binding (over RabbitMQ)? – Tim May 26 '21 at 11:33
  • Hello @Tim, thanks for your comment!. Question updated. Don't really know if the internal server error I found in container logs it is related to the issue I have.. – iperezmel78 May 26 '21 at 21:17

1 Answers1

1

This error message is telling us that HystrixConfigurationStream hasn't been registered with the service container. That can be added with this code in startup.cs:

services.AddHystrixConfigStream(Configuration);

But I think the better option is to pluralize AddHystrixMetricsStream to AddHystrixMonitoringStreams, which registers a couple other things as well.

I've not personally spent a lot of time with this code so I don't know exactly what's going on, but I've filed an issue for the documentation and if there is a bug we should be able to follow up with a fix.

Tim
  • 2,587
  • 13
  • 18
  • Hi @Tim, by using AddHystrixConfigStream solved the exception shown in container logs! and I will mark your answer as the solution because what I need to bind service hystrix stream to turbine server is by using a RabbitMQ server like you mentioned earlier, didn't know that at the beginning but gave me the idea. I'm searching on that, but sounds it will not be that easy. And of course, thank you very much for the great help! – iperezmel78 May 27 '21 at 17:16
  • Assuming you're getting a RabbitMQ service binding it shouldn't take a whole lot more then changing your package reference from `MetricsEventsCore` to `MetricsStreamCore` Maybe take a look at [this Steeltoe sample](https://github.com/SteeltoeOSS/Samples/tree/main/CircuitBreaker/src/FortuneTeller) and try that out. I don't know for sure if it has been run on openshift before but I'd hope it "just works" – Tim May 27 '21 at 17:24