AxisTelemetry 2.2.0
dotnet add package AxisTelemetry --version 2.2.0
NuGet\Install-Package AxisTelemetry -Version 2.2.0
<PackageReference Include="AxisTelemetry" Version="2.2.0" />
<PackageVersion Include="AxisTelemetry" Version="2.2.0" />
<PackageReference Include="AxisTelemetry" />
paket add AxisTelemetry --version 2.2.0
#r "nuget: AxisTelemetry, 2.2.0"
#:package AxisTelemetry@2.2.0
#addin nuget:?package=AxisTelemetry&version=2.2.0
#tool nuget:?package=AxisTelemetry&version=2.2.0
AxisTelemetry — Documentation
Tracing and metrics for the Axis pipeline — IAxisTelemetry for spans, IAxisMetrics for counters and histograms, an OpenTelemetryAdapter over System.Diagnostics.ActivitySource + Meter, a NullAxisTelemetry for when you want telemetry off, and a TelemetryBehavior that wraps every mediator request with an AxisMediator.{RequestName} span plus duration / invocation / exception metrics.
using var span = telemetry.StartSpan("db.postgres.commit", AxisSpanKind.Client);
span.SetTag("db.system", "postgresql");
try
{
await transaction.CommitAsync();
span.SetStatus(AxisSpanStatus.Ok);
}
catch (Exception ex)
{
span.RecordException(ex);
throw;
}
Use this page as a map: read the trunk below (~5 min) and jump straight to the detail of the group you need — without reading hundreds of lines.
The trunk (read first)
The two interfaces in 60 seconds
public interface IAxisTelemetry
{
IAxisSpan StartSpan(string operationName, AxisSpanKind kind = AxisSpanKind.Internal);
string? CurrentTraceId { get; }
string? CurrentSpanId { get; }
}
public interface IAxisMetrics
{
void RecordHistogram(string name, double value, params KeyValuePair<string, object?>[] tags);
void IncrementCounter(string name, long delta = 1, params KeyValuePair<string, object?>[] tags);
}
Tracing on one side, metrics on the other. The bundled OpenTelemetryAdapter implements both. → The contracts
IAxisSpan — the span you actually work with
public interface IAxisSpan : IDisposable
{
string TraceId { get; }
string SpanId { get; }
IAxisSpan SetTag(string key, object? value);
IAxisSpan SetStatus(AxisSpanStatus status, string? description = null);
IAxisSpan RecordException(Exception exception);
IAxisSpan AddEvent(string name, params KeyValuePair<string, object?>[] attributes);
}
Fluent — every mutator returns this. Dispose() ends the span. → Spans · IAxisSpan
TelemetryBehavior — auto-instrumentation of the mediator
Opt-in IAxisPipelineBehavior that opens an AxisMediator.{RequestName} span around every request, tags it with TraceId/JourneyId/RequestType/AxisEntityId/RequestName, times it, records:
axis.handler.duration_ms(histogram)axis.handler.invocations(counter)axis.handler.exceptions(counter, on unhandled exceptions)
→ TelemetryBehavior — automatic instrumentation
Adapters
| Adapter | Use when |
|---|---|
OpenTelemetryAdapter |
production — emits to ActivitySource + Meter; pair with the OpenTelemetry exporter of your choice |
AxisTelemetry.AzureMonitor (separate package) |
production on Azure — the adapter above pre-paired with the official Azure Monitor / Application Insights distro, with cost controls (sampling, log filtering) and a no-op fallback when no connection string is around |
NullAxisTelemetry |
tests, single-process tools — every call is a no-op, every span is NullAxisSpan.Instance |
→ OpenTelemetry adapter · Azure Monitor adapter · Null adapter
Installation
dotnet add package AxisTelemetry
AxisTelemetry depends directly only on AxisLogger (which brings AxisResult and AxisMediator.Contracts transitively). The OpenTelemetry adapter uses System.Diagnostics.ActivitySource and System.Diagnostics.Metrics.Meter from the BCL — no extra NuGet packages.
Exporting to Azure Monitor / Application Insights? Install the pairing package instead:
dotnet add package AxisTelemetry.AzureMonitor
→ Full guide: Getting started
The map (jump to what you need)
| Group | You want to… | Detail |
|---|---|---|
Contracts · IAxisTelemetry / IAxisMetrics |
the two ports | contracts.md |
Spans · IAxisSpan ⭐ |
start, tag, record exceptions, dispose | spans.md |
TelemetryBehavior |
auto-trace every mediator request | telemetry-behavior.md |
| OpenTelemetry adapter | production tracing + metrics | opentelemetry-adapter.md |
| Azure Monitor adapter | export to Application Insights, control the bill | azure-monitor.md |
| Null adapter | turn telemetry off in tests | null-adapter.md |
| Tag names | the canonical constants | tag-names.md |
| Why? | the case for the abstraction | why-axistelemetry.md |
| Reference | every member at a glance | api-reference.md |
Start here: Getting started · The contracts · Why AxisTelemetry?
Fundamentals: Spans · IAxisSpan · TelemetryBehavior · OpenTelemetry adapter · Azure Monitor adapter
Reference & extras: Null adapter · Tag names · API reference
Design principles
- Two narrow ports, one adapter.
IAxisTelemetryfor traces,IAxisMetricsfor metrics; the OpenTelemetry adapter implements both with one type. - Vendor-neutral application code.
ActivitySourceandMeterlive in the BCL; the application seesIAxisSpanonly. - Pipeline-level instrumentation. Register
TelemetryBehaviorand every command/query is timed, tagged and traced — no per-handler boilerplate. - Null is a first-class adapter.
NullAxisTelemetry.Instancelets tests and one-off tools skip the cost without changing the calling code. - Tag names are constants.
TelemetryTagNames.RequestName(and friends) prevent typos and make sink-side queries predictable.
License
Apache 2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- AxisLogger (>= 2.2.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AxisTelemetry:
| Package | Downloads |
|---|---|
|
AxisRepository.MySql
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisRepository.Postgres
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
|
|
AxisTelemetry.AzureMonitor
Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.