.NET
StackState v6.0
Automatic instrumentation
Automatic instrumentation for .NET can automatically capture traces and metrics for a variety of libraries and frameworks.
Automatic instrumentation does not require any modifications of the application. To set it up follow these steps:
Download the glibc or musl version of the instrumentation libraries (musl for Alpine, glibc for most other docker images) from the Releases of the opentelemetry-dotnet-instrumentation repository. Unzip the files and include them in your application docker image in a directory, here we use
/autoinstrumentation
.Set the following env vars, here we do it via the
env
of the container in the Kubernetes pod spec:
Also add the extra environment variables to configure the service name and exporter endpoint on the pod.
Deploy your application with the changes
Verify StackState is receiving traces and/or metrics
For more details please refer to the Open Telemetry documentation.
Manual instrumentation
Manual instrumentation can be used when you need metrics, traces or logs from parts of the code that are not supported by the auto instrumentation. For example unsupported libraries, in-house code or business-level metrics.
To capture that data you need to modify your application.
Include the Open Telemetry SDK as a dependency
Add code to your application to capture metrics, spans or logs where needed
There is detailed documentation for this on the Open Telemetry .NET SDK doc pages.
Make sure you use the OTLP exporter (this is the default) and auto-configuration. When deploying the application the service name and exporter are configured via environment variables.
Metrics in StackState
For some .NET metrics, for example, garbage collector metrics, StackState has defined charts on the related components. For Kubernetes,the charts are available on the pods. It is possible to add charts for more metrics, this works for metrics from automatic instrumentation but also for application-specific metrics from manual instrumentation.
Last updated