Skip to content

matt-hensley/grafana-opentelemetry-dotnet

 
 

Repository files navigation

Grafana logo OpenTelemetry logo

Grafana OpenTelemetry distribution for .NET

Build OATS Nuget SDK Slack

About

This is a pre-configured and pre-packaged bundle of OpenTelemetry .NET components, optimized for Grafana Cloud Application Observability.

It requires only minimal setup and configuration and makes it very easy to emit OpenTelemetry metrics, logs, and traces from your .NET application.

Getting Started

Step 1: Install package

For installing the distribution with the full set of dependencies, add a reference to the Grafana.OpenTelemetry package to your project.

dotnet add package --prerelease Grafana.OpenTelemetry

Step 2: Enable the Grafana distribution at application startup

The UseGrafana extension method on the TracerProviderBuilder or the MetricProviderBuilder can be used to set up the Grafana distribution. By default, telemetry data will be sent to Grafana Alloy or an OTel collector that runs locally and listens to default OTLP ports.

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .UseGrafana()
    .Build();

Alternatively, you can send telemetry data directly to Grafana Cloud without involving an agent or collector. This can be configured via the environment variables OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_ENDPOINT, and OTEL_EXPORTER_OTLP_HEADERS.

For details on how to obtain those values, refer to Push directly from applications using the OpenTelemetry SDKs.

export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-gateway-prod-eu-west-0.grafana.net/otlp"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic a-secret-token"

Documentation

For detailed documentation and setup instructions, refer to the following documents:

Troubleshooting

This project utilizes the self-diagnostics feature of the .NET OpenTelemetry SDK.

To enable self-diagnostics, go to the current working directory of your process and create a configuration file named OTEL_DIAGNOSTICS.json with the following content:

{
    "LogDirectory": ".",
    "FileSize": 32768,
    "LogLevel": "Warning"
}

To disable self-diagnostics, delete the above file.

Community

To engage with the Grafana Application Observability community:

About

Grafana's distribution of OpenTelemetry instrumentation for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.8%
  • Shell 0.2%