Genocs.Telemetry
9.0.0
Requires NuGet 5.0.0 or higher.
dotnet add package Genocs.Telemetry --version 9.0.0
NuGet\Install-Package Genocs.Telemetry -Version 9.0.0
<PackageReference Include="Genocs.Telemetry" Version="9.0.0" />
<PackageVersion Include="Genocs.Telemetry" Version="9.0.0" />
<PackageReference Include="Genocs.Telemetry" />
paket add Genocs.Telemetry --version 9.0.0
#r "nuget: Genocs.Telemetry, 9.0.0"
#:package Genocs.Telemetry@9.0.0
#addin nuget:?package=Genocs.Telemetry&version=9.0.0
#tool nuget:?package=Genocs.Telemetry&version=9.0.0
Genocs.Telemetry

OpenTelemetry integration helpers for traces and metrics. Supports net10.0, net9.0, and net8.0.
Installation
dotnet add package Genocs.Telemetry
Getting Started
Use this package to configure OpenTelemetry traces and metrics in Genocs services.
Service registration:
using Genocs.Telemetry;
genocs.AddTelemetry();
Configuration example:
{
"app": {
"service": "My Service"
},
"telemetry": {
"enabled": true,
"sqlClient": {
"enabled": true,
"enableStatementText": false
},
"exporter": {
"enabled": true,
"otlpEndpoint": "http://localhost:4317",
"protocol": "Grpc",
"enableTracing": true,
"enableMetrics": true
}
}
}
telemetry.sqlClient.enabled controls whether SQL client tracing instrumentation is registered.
When omitted, it defaults to true for backward compatibility.
telemetry.sqlClient.enableStatementText is disabled by default. Enable it only when SQL query text (db.query.text/db.statement) collection is explicitly required.
If telemetry.exporter.enabled is true and telemetry.exporter.otlpEndpoint is missing or invalid, OTLP exporter registration is skipped and a warning is emitted. Startup remains safe and traces/metrics continue with the remaining configured exporters.
Exception Tag Payload Guardrails
Exception enrichment now applies bounded message handling for span status and exception message tags.
- Control characters are sanitized before export.
- Exception message values are capped at
1024characters. - Oversized values are truncated with the suffix
...(truncated).
This preserves diagnostic signal while avoiding oversized payload pressure in telemetry backends.
Route Tag Cardinality Policy
Genocs.Telemetry prefers route templates for http.route (for example, orders/{orderId}).
When route metadata is unavailable, the default fallback is a bounded constant:
/_unmatched
This avoids high-cardinality tags from raw request paths.
Optional fallback behavior:
telemetry.enableRoutePathFallback: opt-in to request-path fallbacktelemetry.normalizeRoutePathFallback: when enabled (default), path fallback normalizes identifier-like segments (such as numeric IDs and GUIDs)
Example:
{
"telemetry": {
"enabled": true,
"enableRoutePathFallback": true,
"normalizeRoutePathFallback": true
}
}
Activity Source Collection Policy
Genocs.Telemetry now uses a bounded default source set to reduce unintended trace collection.
Default registered sources:
Genocs.SagaGenocs.Messaging.RabbitMQGenocs.Messaging.AzureServiceBus
Future source integration is configuration-driven via telemetry.activitySources.
Wildcard collection is opt-in via telemetry.enableWildcardActivitySources and should be used only when broad source capture is explicitly required.
Example:
{
"telemetry": {
"enabled": true,
"enableWildcardActivitySources": false,
"activitySources": [
"MyCompany.Payments",
"MyCompany.Inventory"
]
}
}
Host-Mode Behavior
Genocs.Telemetry registers tracing and metrics pipelines in both builder flows:
WebApplicationBuilderhostsIServiceCollection+IConfigurationhosts
OpenTelemetry log exporters are not configured by Genocs.Telemetry in either host mode.
If you need OTLP or Azure log export, configure it through Genocs.Logging.
OTLP Batch Settings Bounds
telemetry.exporter batch processor settings are validated before wiring exporters.
maxQueueSize: supported range512-65536, fallback2048scheduledDelayMilliseconds: supported range100-60000, fallback5000exporterTimeoutMilliseconds: supported range1000-120000, fallback30000maxExportBatchSize: supported range1-1024, fallback512
If maxExportBatchSize resolves to a value greater than maxQueueSize, it is reduced to a safe fallback and a warning is emitted.
For high-throughput workloads, prefer increasing maxQueueSize first, then tune maxExportBatchSize and timeouts incrementally while observing exporter backpressure and dropped-span metrics.
Deterministic Log Export Ownership
Genocs.Telemetry does not configure OpenTelemetry log exporters.
- Use
Genocs.Telemetryfor traces and metrics. - Use
Genocs.Loggingfor log export ownership (OTLP, Azure Application Insights, Seq, Loki, Elasticsearch, file, console). - Do not split log export between both packages.
This avoids duplicate log ingestion when both packages target the same backend.
Exporter Conflict Guidance (Azure + OTLP)
Genocs.Telemetry allows multiple exporters per signal. This is valid, but should be intentional because it increases export volume and backend cost.
Recommended profiles:
- OTLP-only profile: use OTLP as the single backend for traces/metrics.
- Azure-only profile: use Azure Monitor as the single backend for traces/metrics.
- Dual-export profile: use OTLP and Azure together only for migration windows, side-by-side validation, or temporary failover.
Signal-level guidance:
- For normal production, prefer one exporter per signal.
- If dual export is enabled for traces or metrics, define a time-bound reason and owner.
- Keep logs out of
Genocs.Telemetry; log export remains owned byGenocs.Logging.
Overlap warning when Genocs.Logging is enabled:
- If
Genocs.Loggingexports logs to OTLP or Azure, do not add any telemetry-side log export assumptions in runbooks or config templates. - Treat OTLP/Azure in
telemetryas trace/metric routing only.
Non-Overlapping Deployment Templates
Azure Application Insights (all logs from Genocs.Logging)
{
"logger": {
"azure": {
"enabled": true,
"connectionString": "InstrumentationKey=<<key>>;IngestionEndpoint=https://<<region>>.in.applicationinsights.azure.com/"
},
"otlpEndpoint": null
},
"telemetry": {
"enabled": true,
"exporter": {
"enabled": false
},
"azure": {
"enabled": true,
"enableTracing": true,
"enableMetrics": true,
"connectionString": "InstrumentationKey=<<key>>;IngestionEndpoint=https://<<region>>.in.applicationinsights.azure.com/"
},
"console": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
}
}
}
Jaeger with OTLP trace-only (logs still owned by Genocs.Logging)
Jaeger ingestion is supported via OTLP collector endpoints. Genocs.Telemetry uses OpenTelemetry.Exporter.OpenTelemetryProtocol for this flow and does not require a direct Jaeger exporter package.
Use one of the Jaeger collector OTLP endpoints:
- gRPC:
http://localhost:4317with"protocol": "Grpc" - HTTP/protobuf:
http://localhost:4318with"protocol": "HttpProtobuf"
{
"logger": {
"otlpEndpoint": null,
"azure": {
"enabled": false
}
},
"telemetry": {
"enabled": true,
"exporter": {
"enabled": true,
"otlpEndpoint": "http://localhost:4317",
"protocol": "Grpc",
"enableTracing": true,
"enableMetrics": false
},
"azure": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
},
"console": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
}
}
}
Temporary dual export (OTLP + Azure for traces and metrics)
Use this only for controlled migration or backend comparison windows.
{
"logger": {
"otlpEndpoint": "http://localhost:4317",
"azure": {
"enabled": false
}
},
"telemetry": {
"enabled": true,
"exporter": {
"enabled": true,
"otlpEndpoint": "http://localhost:4317",
"protocol": "Grpc",
"enableTracing": true,
"enableMetrics": true
},
"azure": {
"enabled": true,
"enableTracing": true,
"enableMetrics": true,
"connectionString": "InstrumentationKey=<<key>>;IngestionEndpoint=https://<<region>>.in.applicationinsights.azure.com/"
},
"console": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
}
}
}
When this profile is active, expect duplicate traces and metrics across backends by design.
Minimal-Overhead Profile (Exporters Disabled)
When trace exporters are effectively disabled, Genocs.Telemetry keeps instrumentation registration deterministic while reducing enrichment overhead:
- ASP.NET Core and HttpClient custom exception enrichment delegates are skipped.
- Exception recording for tracing instrumentation is disabled.
- SQL statement scrubbing processor is not added in no-export tracing mode.
Use this profile when instrumentation is kept on for compatibility, but trace export is intentionally disabled.
{
"telemetry": {
"enabled": true,
"exporter": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
},
"console": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false
},
"azure": {
"enabled": false,
"enableTracing": false,
"enableMetrics": false,
"connectionString": ""
}
}
}
Prometheus Plugin
Prometheus is exposed as a built-in plug-in on top of the OpenTelemetry MeterProvider. The
formerly-separate Genocs.Metrics package is no longer required — installing
Genocs.Telemetry and enabling the telemetry.prometheus sub-section is enough.
When enabled, AddTelemetry():
- Adds the
OpenTelemetry.Exporter.Prometheus.AspNetCoreexporter to the meter provider. - Registers the auth-gating middleware used by
UsePrometheus().
Configuration:
{
"telemetry": {
"enabled": true,
"prometheus": {
"enabled": true,
"endpoint": "/metrics",
"apiKey": null,
"allowedHosts": []
}
}
}
Settings:
enabled: master switch for the Prometheus plug-in. Defaults tofalse.endpoint: scraping path. Defaults to/metrics. Always normalized to start with/.apiKey: optional API key. When set, callers must pass?apiKey=<value>on the scraping endpoint.allowedHosts: optional list of allowed hosts (orx-forwarded-forvalues). When set, only matching callers may scrape. If bothapiKeyandallowedHostsare empty, the endpoint is open to any caller.
Pipeline wiring:
using Genocs.Telemetry;
var app = builder.Build();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
// Auth-gate middleware (no-op when telemetry.prometheus.enabled is false).
app.UsePrometheus();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
// Map the Prometheus scraping endpoint (no-op when telemetry.prometheus.enabled is false).
endpoints.MapPrometheus();
});
UsePrometheus() and MapPrometheus() are safe to call unconditionally: when the plug-in is
disabled, both calls are no-ops.
Main Entry Points
AddTelemetryUsePrometheus(extension onIApplicationBuilder)MapPrometheus(extension onIEndpointRouteBuilder)
Validation
Run this command before publishing telemetry changes to verify analyzer/nullability baseline remains warning-clean:
dotnet build src/Genocs.Telemetry/Genocs.Telemetry.csproj -c Debug --nologo
Support
- Documentation Portal: https://learn.fiscanner.net/
- Documentation: https://github.com/Genocs/genocs-library/tree/main/docs
- Repository: https://github.com/Genocs/genocs-library
Release Notes
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.6.0)
- Genocs.Core (>= 9.0.0)
- MongoDB.Driver.Core.Extensions.OpenTelemetry (>= 1.0.0)
- OpenTelemetry.Exporter.Console (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.1-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.15.2)
-
net8.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.6.0)
- Genocs.Core (>= 9.0.0)
- MongoDB.Driver.Core.Extensions.OpenTelemetry (>= 1.0.0)
- OpenTelemetry.Exporter.Console (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.1-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.15.2)
-
net9.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.6.0)
- Genocs.Core (>= 9.0.0)
- MongoDB.Driver.Core.Extensions.OpenTelemetry (>= 1.0.0)
- OpenTelemetry.Exporter.Console (>= 1.15.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Exporter.Prometheus.AspNetCore (>= 1.15.1-beta.1)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.2)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.15.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 69 | 5/21/2026 |
| 9.0.0-beta009 | 90 | 5/11/2026 |
| 9.0.0-beta008 | 139 | 5/2/2026 |
| 9.0.0-beta007 | 64 | 4/29/2026 |
| 9.0.0-beta006 | 60 | 4/27/2026 |
| 9.0.0-beta005 | 78 | 4/26/2026 |
| 9.0.0-beta004 | 66 | 4/18/2026 |
| 9.0.0-beta003 | 105 | 4/5/2026 |
| 9.0.0-beta002 | 93 | 3/17/2026 |
| 9.0.0-beta001 | 106 | 2/28/2026 |
The change log and breaking changes are listed here.
https://github.com/Genocs/genocs-library/releases