ServiceComposer emits OpenTelemetry traces using System.Diagnostics.ActivitySource, which is built into the .NET runtime. No additional NuGet packages are required in the application library itself.
Two independent activity sources are available — one per feature — so each can be opted into separately.
| Feature | Activity source name |
|---|---|
| ViewModel Composition | ServiceComposer.AspNetCore.ViewModelComposition |
| Scatter/Gather | ServiceComposer.AspNetCore.ScatterGather |
Add the OpenTelemetry.Extensions.Hosting NuGet package, then register the desired source(s) with the tracing pipeline.
builder.Services.AddOpenTelemetry()
.WithTracing(b => b
.AddSource("ServiceComposer.AspNetCore.ViewModelComposition"));
builder.Services.AddOpenTelemetry()
.WithTracing(b => b
.AddSource("ServiceComposer.AspNetCore.ScatterGather"));
AddSource supports * as a wildcard, so both sources can be registered in one call:
builder.Services.AddOpenTelemetry()
.WithTracing(b => b
.AddSource("ServiceComposer.AspNetCore.*"));
Each ICompositionRequestsHandler execution produces a child span of the ASP.NET Core HTTP server span.
| Â | Value |
|---|---|
| Operation name | composition.handler |
| Display name | Fully qualified handler type name |
composition.handler.type |
Fully qualified handler type name |
composition.handler.namespace |
Handler namespace |
When a handler raises an event via context.RaiseEvent<TEvent>(), the event handling produces a child span of the raising handler’s span.
| Â | Value |
|---|---|
| Operation name | composition.event |
| Display name | Fully qualified event type name |
composition.event.type |
Fully qualified event type name |
composition.event.namespace |
Event namespace |
When a handler or event handler throws, the span sets ActivityStatusCode.Error and adds the following tags and an exception span event following the OTel exception conventions.
| Tag | Value |
|---|---|
otel.status_code |
"error" |
otel.status_description |
Exception message |
Each IGatherer execution produces a child span of the ASP.NET Core HTTP server span.
| Â | Value |
|---|---|
| Operation name | scatter-gather.gatherer |
| Display name | Gatherer key |
scatter_gather.gatherer.key |
The gatherer key |
When a gatherer throws, the span sets ActivityStatusCode.Error with the same otel.status_code, otel.status_description tags and exception span event as described above.