Search code examples
.net-coreopenshifthystrixturbinesteeltoe

How to bind c# dotnet core 3.1 microservice stream to turbine server stream


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]


Solution

  • 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.