Skip to content

feat: System.Diagnostics.Metrics bridge & OpenTelemetry integration (v1.0.51) - #6

Merged
medevod merged 8 commits into
mainfrom
v1.0.51-refactor-internal-implementations
Sep 27, 2026
Merged

medevod merged 8 commits into
mainfrom
v1.0.51-refactor-internal-implementations

Conversation

@medevod

@medevod medevod commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements iteration v1.0.51, adding native System.Diagnostics.Metrics BCL instrumentation to DotnetKit.MetricFlow, releasing the companion package DotnetKit.MetricFlow.OpenTelemetry, and adding an end-to-end console example.

Key Changes

  1. Core BCL Metrics Bridge (DotnetKit.MetricFlow):
    • IMetricMeterBridge, MetricFlowMeterBridge, and MetricFlowMeterRegistry: Map MetricFlow trackers and metrics ({metricName}.duration, {metricName}.total, {metricName}.items, {metricName}.exceptions, {metricName}.active) directly to BCL Meter, Counter, Histogram, and UpDownCounter.
    • TagCardinalityGuard: Enforces configurable tag cardinality limits (MaxUniqueTagValues, default 50) and clamps high-cardinality values to [Other] to prevent memory leaks and TSDB degradation.
    • Preserves 100% backward compatibility with existing MetricTracker, CodeTracker, In(), Out(), and local snapshot APIs.
  2. OpenTelemetry Companion Package (DotnetKit.MetricFlow.OpenTelemetry):
    • Fluent .AddMetricFlowInstrumentation(...) for MeterProviderBuilder.
    • Ambient trace context correlation: WithTraceContext() captures Activity.Current (trace_id, span_id) without coupling core MetricFlow to OpenTelemetry.
    • MetricFlowTracerProviderBuilderExtensions: Adds MetricFlow ActivitySource for distributed tracing.
  3. End-to-End Example:
    • examples/OpenTelemetryConsoleExample: Demonstrates OpenTelemetry console export, high-cardinality protection, and dotnet-counters monitoring.
  4. Testing & Documentation:
    • Added unit test suite in tests/MetricFlow.Tests/MetricMeterBridgeTests.cs (11 tests).
    • Added integration test suite in tests/MetricFlow.OpenTelemetry.Tests/ (5 tests with InMemoryExporter).
    • All 139 tests pass across both net8.0 and net10.0.
    • Updated README.md, ROADMAP.md, and CHANGELOG.md.

Verification

  • dotnet build succeeded with 0 warnings/errors.
  • dotnet test passed 139/139 tests across .NET 8.0 and .NET 10.0.

…ntegration (v1.0.51)

- Add core IMetricMeterBridge, MetricFlowMeterBridge, and TagCardinalityGuard in DotnetKit.MetricFlow
- Wire automatic Meter dispatch into MetricTrackerBase and CodeTracker for duration, items, active, exceptions, and throughput
- Create DotnetKit.MetricFlow.OpenTelemetry package with .AddMetricFlowInstrumentation() and WithTraceContext()
- Add end-to-end OpenTelemetryConsoleExample demonstrating OTel console export, dotnet-counters, and cardinality clamping
- Add unit and integration test suites covering net8.0 and net10.0
- Update README.md, ROADMAP.md, and CHANGELOG.md for v1.0.51
@medevod
medevod merged commit f8c60ae into main Sep 27, 2026
1 check passed
@medevod
medevod deleted the v1.0.51-refactor-internal-implementations branch October 12, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant