This is the accompanying repository for my meetup talk on Modern Observability for your .NET apps with OpenTelemetry.
The meetup was hosted by .NET Devs Austria (thanks for having me!). You can find the recording on their YouTube Channel (don't forget to subscribe!).
The slides for the talk can be found on Speaker Deck.
The sample consists of a "usual" ASP.NET API, protected by JWT tokens, coming from Duende IdentityServer. The API is pretty much the same used for my blog post series on. ASP.NET Authorization.
The difference being it's now instrumented with OpenTelemetry! 🔭
Dependencies managed in docker-compose.yaml
:
- SQL Server
- Duende IdentityServer
- OpenTelemetry Collector
- Jaeger
- Start the dependencies by running
docker-compose up
from the root of this repo - Start the ASP.NET API inside
src/API
dotnet run
- The API is available on
https://localhost:7249/swagger
- Click on the "Authorize" button on the swagger page, select the scopes and log in either with
alice:alice
orbob:bob
. - Try the requests on the Swagger pages
By default, the telemetry data (traces, metrics and logs) are exported to
the OpenTelemetry collector running on Docker.
The collector is configured to export data to the console output for all signals.
Traces are also exported to Jaeger on http://localhost:16686.
Check out the otel-collector-config.yaml
to see how the configuration looks like.
To learn more about the collector configuration, check out the OpenTelemetry website
Take a look at the method AddOpenTelemetry
inside src/API/HostingExtensions.cs
to see how the OpenTelemetry SDK along with several instrumentation packages
are configured.
To see how to manual start a span or create metrics, take a look at either PermissionsMiddleware
or src/AuthUtils/PolicyProvider/PermissionHandler.cs
.
To learn more, take a look at the OpenTelemetry .NET docs.