Skip to content

Observability

Servers emit OpenTelemetry-friendly telemetry through the standard .NET primitives, like the client runtime: no NSmithy-specific setup, no extra packages. What is recorded depends on what the application subscribes to:

The application recordsNSmithy adds
nothingnothing
the request’s span, ASP.NET Core’s or the MCP SDK’sthe call’s attributes on that span
the NSmithy.Server sourcean internal span around each handler call
the NSmithy.Server metersmithy.server.operation.duration
Program.cs
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddSource("NSmithy.Server"))
.WithMetrics(metrics => metrics.AddMeter("NSmithy.Server"));

The source and meter names are also available as constants: SmithyServerTelemetry.ActivitySourceName and SmithyServerTelemetry.MeterName.

The request’s span belongs to the host: ASP.NET Core’s POST /users, found through the request rather than Activity.Current, so a span your middleware starts does not hide it; or, for an MCP tool call, the MCP SDK’s span. NSmithy keeps its name and describes the call on it, so a caller’s client span and the server span it reaches carry the same attributes. A .NET caller connects to it with HttpClient’s instrumentation, as the client guide describes.

AttributeValue
rpc.systemsmithy
rpc.serviceThe service shape id (e.g. example.weather#Weather).
rpc.methodThe operation name.
error.typeThe exception type of a failed call: a modeled error, a rejected request, or a failure reading the request or writing the response.

With the NSmithy.Server source subscribed, each handler call runs in an internal span named {Service}.{Operation} (e.g. Weather.GetForecast) with the same attributes, under whatever span is current. The gap between it and the request’s span is the time spent reading and writing the request. A request rejected before the handler runs, such as one that fails validation, has no handler span.

A modeled client error is the caller’s mistake: the handler span names its error.type but leaves the status unset. A modeled server error, or an unmodeled exception, marks the span Error. The model decides, not the response, so a gRPC fault, which is answered with HTTP 200, still marks it.

InstrumentTypeUnitMeaning
smithy.server.operation.durationHistogramsCall duration, from reading the request to writing the last byte of the response.

It carries rpc.system, rpc.service, and rpc.method, and error.type for a failed call. A streamed response is measured until it ends, and a stream that fails partway records its failure.