In .NET, tracing is built into the runtime: a span is a System.Diagnostics.Activity. The OpenTelemetry SDK listens to those activities and to ILogger, and one exporter sends all three signals to Maple.
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
dotnet add package OpenTelemetry.Instrumentation.Http // Program.cs
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation())
.WithMetrics(metrics => metrics.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation())
.WithLogging()
.UseOtlpExporter();
var app = builder.Build();
app.MapGet("/", () => "Hello!");
app.Run(); export OTEL_SERVICE_NAME="my-dotnet-app"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.maple.dev"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR_INGEST_KEY"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=production"
dotnet run This is the short path. The full .NET guide covers the rest.
Organization in the EU region? Send to https://ingest.eu.maple.dev instead of https://ingest.maple.dev. An ingest key only works in its own region.
What you get
Each request is one root server span named after its method and route, plus request duration metrics.
Client spans carry traceparent to the service you call. When that service is instrumented, the call is an edge on the service map.
Add OpenTelemetry.Instrumentation.EntityFrameworkCore or SqlClient. Query spans carry the statement and the database system.
WithLogging() exports ILogger<T> records. A record written inside an activity carries its trace and span id.
StackExchange.Redis and GrpcNetClient each have an instrumentation package, registered the same way.
OpenTelemetry.Instrumentation.Runtime adds .NET runtime metrics, exported every 60 seconds.
Custom spans come from an ActivitySource. They are only exported when the source name is registered with AddSource; an unregistered source records nothing.
Set OTEL_EXPORTER_OTLP_PROTOCOL to http/protobuf, as above, or the exporter speaks gRPC. With HttpProtobuf, an endpoint set in code needs the full /v1/traces path.
Without a host, build the providers with Sdk.CreateTracerProviderBuilder() and dispose them before exit, so the last batch is sent.
SDK를 추가하고 OTLP 익스포터를 Maple로 향하게 하면 트레이스가 도착합니다.
maple.dev: OpenTelemetry 위의 옵저버빌리티