Skip to content

This is an Instrumentation Library, which instruments ASP.NET Core SignalR and collect metrics and traces about SignalR hub method invocations.

License

Notifications You must be signed in to change notification settings

nenoNaninu/AspNetCore.SignalR.OpenTelemetry

Repository files navigation

AspNetCore.SignalR.OpenTelemetry

NuGet build-and-test

This is an Instrumentation Library, which instruments ASP.NET Core SignalR and collect traces about SignalR hub method invocations.

Table of Contents

Install

NuGet: AspNetCore.SignalR.OpenTelemetry

dotnet add package AspNetCore.SignalR.OpenTelemetry

Usage

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSignalR()
    .AddHubInstrumentation(); // <- Add this!

builder.Services.AddOpenTelemetry()
    .ConfigureResource(builder =>
    {
        builder.AddService("AspNetCore.SignalR.OpenTelemetry.Example");
    })
    .WithTracing(providerBuilder =>
    {
        providerBuilder
            .AddAspNetCoreInstrumentation()
            .AddSignalRInstrumentation() // <- Add this!
            .AddOtlpExporter();
    });

Example

The example code architecture is as follows.

graph LR;
    app[ASP.NET Core Server] --> otelc[OpenTelemetry Collector];
    otelc --> Tempo;
    Grafana --> Tempo;
Loading

The example code can be quickly executed from Visual Studio.

Docker

It can also be quickly executed from the CLI.

$ docker compose build
$ docker compose up

In Grafana, you can see the SignalR method call trace as follows.

Trace

Related Work

About

This is an Instrumentation Library, which instruments ASP.NET Core SignalR and collect metrics and traces about SignalR hub method invocations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages