Path: redb/redb.Core/Diagnostics/RedbActivitySource.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Diagnostics/RedbActivitySource.cs
----
using System.Diagnostics;
namespace redb.Core.Diagnostics;
///
/// Centralized telemetry identity for REDB. The engine declares each database command on an
/// named ; an OpenTelemetry consumer subscribes
/// with .AddSource(RedbActivitySource.SourceName) and a span per command appears.
///
/// The source is inert until something subscribes: with no listener nothing is emitted and a command
/// is run straight through, so REDB adds no trace by itself and no statement text or parameters ever
/// leave the process in a span. This is the shape EF Core uses for its own
/// Microsoft.EntityFrameworkCore source: the engine owns the source, the application opts in
/// by name.
///
///
public static class RedbActivitySource
{
/// Canonical source name used for OpenTelemetry tracing instrumentation.
public const string SourceName = "redb.Core";
/// The shared activity source instance.
public static readonly ActivitySource Source = new(SourceName, GetVersion());
private static string GetVersion()
=> typeof(RedbActivitySource).Assembly.GetName().Version?.ToString() ?? "0.0.0";
}