GrafanaCloud.OpenTelemetry
1.0.0
dotnet add package GrafanaCloud.OpenTelemetry --version 1.0.0
NuGet\Install-Package GrafanaCloud.OpenTelemetry -Version 1.0.0
<PackageReference Include="GrafanaCloud.OpenTelemetry" Version="1.0.0" />
<PackageVersion Include="GrafanaCloud.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="GrafanaCloud.OpenTelemetry" />
paket add GrafanaCloud.OpenTelemetry --version 1.0.0
#r "nuget: GrafanaCloud.OpenTelemetry, 1.0.0"
#:package GrafanaCloud.OpenTelemetry@1.0.0
#addin nuget:?package=GrafanaCloud.OpenTelemetry&version=1.0.0
#tool nuget:?package=GrafanaCloud.OpenTelemetry&version=1.0.0
GrafanaCloud.OpenTelemetry
A zero-boilerplate OpenTelemetry setup for Grafana Cloud in ASP.NET Core applications. Wires traces (Tempo), metrics (Mimir), and logs (Loki) via OTLP with a single method call.
Installation
dotnet add package GrafanaCloud.OpenTelemetry
Configuration
Add the following to your appsettings.json:
"GrafanaCloud": {
"Endpoint": "https://otlp-gateway-prod-us-east-3.grafana.net/otlp",
"Headers": "Authorization=Basic <base64-encoded-instanceid:apitoken>",
"ServiceName": "my-api",
"ServiceNamespace": "my-org",
"DeploymentEnvironment": "production"
}
| Key | Required | Default | Description |
|---|---|---|---|
Endpoint |
Yes | — | Grafana Cloud OTLP gateway base URL. Traces, metrics, and logs paths are appended automatically. |
Headers |
Yes | — | Auth headers sent with every OTLP request. |
ServiceName |
No | "unknown-service" |
Service name reported in Grafana. |
ServiceNamespace |
No | "" |
Service namespace for grouping. |
DeploymentEnvironment |
No | ASP.NET Core environment name | Sets the deployment.environment resource attribute. |
Your Grafana Cloud OTLP endpoint and credentials can be found under Home → Connections → OpenTelemetry in the Grafana Cloud console.
Registration
Zero-config (reads entirely from appsettings.json)
// Program.cs
builder.AddGrafanaCloud();
With custom activity sources
Register your own ActivitySource names so they appear in Grafana Tempo traces:
builder.AddGrafanaCloud(options =>
{
options.TracingSources = ["MyApp.Auth", "MyApp.Orders", "MyApp.Payments"];
});
With EntityFrameworkCore instrumentation
EF Core instrumentation is opt-in (it is a beta package):
builder.AddGrafanaCloud(options =>
{
options.UseEntityFrameworkCoreInstrumentation = true;
options.TracingSources = ["MyApp.Auth", "MyApp.Orders"];
});
Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
Endpoint |
string |
"" |
Grafana Cloud OTLP base URL. Required. |
Headers |
string |
"" |
Auth headers for OTLP requests. |
ServiceName |
string |
"unknown-service" |
Service name in traces/metrics/logs. |
ServiceNamespace |
string |
"" |
Service namespace. |
DeploymentEnvironment |
string? |
ASP.NET Core env | Sets deployment.environment resource attribute. |
TracingSources |
IList<string> |
[] |
Custom ActivitySource names to include in traces. |
UseEntityFrameworkCoreInstrumentation |
bool |
false |
Enable EF Core tracing (opt-in). |
SuppressFrameworkLogs |
bool |
true |
Suppress noisy EF Core and ASP.NET Core log categories. |
What gets wired up
| Signal | Instrumentation |
|---|---|
| Traces | ASP.NET Core, HttpClient, custom activity sources, optionally EF Core |
| Metrics | ASP.NET Core, HttpClient, .NET Runtime |
| Logs | All ILogger output via OTLP |
Health check (/health) and favicon (/favicon.ico) requests are excluded from traces automatically.
Custom Activity Sources
Define your activity sources in your app as usual:
using System.Diagnostics;
public static class MyActivitySource
{
public static readonly ActivitySource Auth = new("MyApp.Auth");
public static readonly ActivitySource Orders = new("MyApp.Orders");
}
Then register the names with the library:
builder.AddGrafanaCloud(options =>
{
options.TracingSources = ["MyApp.Auth", "MyApp.Orders"];
});
Use them in your services:
using var activity = MyActivitySource.Auth.StartActivity("auth.login");
activity?.SetTag("user.id", userId);
Requirements
- .NET 8
- ASP.NET Core
- A Grafana Cloud account with an OTLP endpoint and API token
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.11.2)
- OpenTelemetry.Extensions.Hosting (>= 1.11.2)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.11.1)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.0.0-beta.12)
- OpenTelemetry.Instrumentation.Http (>= 1.11.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.11.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 121 | 3/9/2026 |