feat(logging): add telemetry registry and context examples - #111
Merged
Conversation
Add four built-in metrics to PrometheusHttpServerLogger so operators can observe scrape health and collection latency: - logit_prometheus_scrapes_total (counter) - logit_prometheus_scrape_errors_total (counter) - logit_prometheus_last_scrape_timestamp_ms (gauge) - logit_prometheus_collect_duration_seconds (gauge) Scrapes are counted in the HTTP handler before collect_payload(). Collection duration is measured inside collect_payload() using steady_clock. Failed scrapes (exceptions from collect_payload()) increment scrape_errors_total. All scrape metrics carry the logger="prometheus_http_server" label for consistency with existing built-in families. Not-tested: scrape_errors_total > 0 (requires an exception during collect_payload, which is hard to trigger deterministically in the current test setup). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add PrometheusRegistry for declarative custom application metrics and wire it into Prometheus examples and docs. Add MDC/NDC context support based on the existing local LogContext design, including formatter tokens and coverage. Fix OTLP graceful-shutdown worker wakeups and add zstd compression integration coverage.
Add LOGIT_WITH_CONTEXT so diagnostic context support does not affect the default logging hot path. Store context as an optional shared snapshot only when the thread context is non-empty, and keep ASan builds away from intentionally leaked thread-local storage.
Apply PrometheusTextFormatConfig logger and instance label settings to PrometheusHttpServerLogger scrape diagnostics. Add coverage for custom logger label names, instance labels, and disabled logger labels on scrape metrics.
Continue collecting PrometheusRegistry entries after a value callback throws, append successfully collected samples, and then rethrow the first exception so Prometheus loggers still count the collection failure. Update registry coverage and docs for the partial-success behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests