Skip to content

feat: add metric sink infrastructure with console sink support and DI… - #8

Merged
medevod merged 8 commits into
mainfrom
feat/v1.0.51-add-sink
Oct 9, 2026
Merged

medevod merged 8 commits into
mainfrom
feat/v1.0.51-add-sink

Conversation

@medevod

@medevod medevod commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

[1.0.53] - 2026-10-07

Added

  • Pluggable Metric Sink Pipeline (IMetricSink):
    • Core IMetricSink abstraction supporting synchronous Emit(IReadOnlyList<IMetricSnapshot>) and asynchronous EmitAsync(...) with bidirectional default interface implementations.
    • In-process snapshot dispatching for centralized logging, file writes, and local persistence.
  • Reactive Observable Pattern (ObservableMetricSink):
    • Implementation of IMetricSink and IObservable<IReadOnlyList<IMetricSnapshot>> enabling standard reactive subscriptions (sink.Subscribe(...)) for piping metric snapshots to Rx.NET queries, event channels, or custom log writers.
  • Timer-Free Sampling Triggers (MetricSinkTriggerOptions):
    • First-class support for execution-lifecycle triggers evaluated during operation completion (Out / Dispose), completely avoiding mandatory background timers or polling threads:
      • Stride Sampling: Emit snapshots every $N$ executions (EmitEveryNExecutions).
      • Tail / Outlier Sampling: Immediately emit on operation failure (EmitOnFailure) or when duration exceeds latency thresholds (EmitOnSlowDurationThreshold).
      • Probabilistic Sampling: Random percentage sampling (EmitSampleRate).
    • Zero idle CPU and thread overhead; ideal for serverless (AWS Lambda), CLI utilities, and short-lived batch jobs.
  • Structured Console Log Sink (ConsoleMetricSink & ConsoleMetricSinkOptions):
    • High-performance console sink formatting metric snapshots into human-readable single-line structured log entries.
    • Configurable ANSI colorization (Colorize), timestamps, custom prefixes, and redirection to any TextWriter for testing.
    • Dedicated formatting for throughput rates, execution counts, and failure rates.
  • Fluent Builder & DI Extensions:
    • Registered sinks on MetricFlowOptions: options.AddSink(...), options.AddConsoleSink(...), options.AddObservableSink(...), and options.ConfigureSinkTriggers(...).
    • Fluent builder chaining: builder.AddConsoleSink(...) and builder.AddSink(...).
    • Automatic dependency injection discovery: automatically resolves any registered IMetricSink services from the DI container into metric trackers.
    • Manual and asynchronous flush support: tracker.FlushSinks() and tracker.FlushSinksAsync().
  • Roadmap Updates (ROADMAP.md):
    • Updated Section 2 to reflect IMetricSink, ObservableMetricSink, timer-free sampling, and the console sink.
    • Realigned Section 3 to clarify that cloud APMs (AWS CloudWatch, Azure Monitor, Datadog, Prometheus) are natively handled via OpenTelemetry and System.Diagnostics.Metrics.

@medevod
medevod merged commit 1782f8b into main Oct 9, 2026
1 check passed
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