Skip to content

feat(logging): add telemetry registry and context examples - #111

Merged
LimiNode merged 5 commits into
mainfrom
feat/telemetry-registry-context-examples
May 29, 2026
Merged

feat(logging): add telemetry registry and context examples#111
LimiNode merged 5 commits into
mainfrom
feat/telemetry-registry-context-examples

Conversation

@LimiNode

@LimiNode LimiNode commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • fixes OTLP graceful-shutdown worker wakeups so the worker does not spin while in-flight requests are saturated
  • adds zstd OTLP/HTTP compression integration coverage
  • adds PrometheusRegistry for declarative custom app metrics and updates Prometheus examples/docs
  • adds opt-in MDC/NDC context helpers, formatter tokens, tests, and a focused example behind LOGIT_WITH_CONTEXT
  • keeps the default LogRecord hot path unchanged when context support is disabled
  • documents existing Prometheus scrape diagnostics and points users to runnable OTLP/Prometheus/MDC examples

Tests

  • git diff --check
  • cmake --build tmp/build-context-on-mingw --target mdc_ndc_context_test example_logit_mdc_ndc
  • cmake --build tmp/build-context-off-mingw --target include_formatter_nhr_test include_utils_nhr_test example_logit_mdc_ndc example_logit_otlp_http
  • ctest --test-dir tmp/build-context-on-mingw -R ^mdc_ndc_context_test$ --output-on-failure
  • ctest --test-dir tmp/build-context-off-mingw --output-on-failure (51/51 passed)
  • cmake --build tmp/build-integrated-mingw --target mdc_ndc_context_test example_logit_mdc_ndc example_logit_otlp_http example_logit_prometheus_payload example_logit_prometheus_server
  • ctest --test-dir tmp/build-integrated-mingw -R ^(mdc_ndc_context_test|otlp_http_logger_callback_test|otlp_http_logger_gzip_test|otlp_http_logger_zstd_test|prometheus_registry_test|prometheus_payload_logger_test|prometheus_http_server_logger_test)$ --output-on-failure
  • GitHub CI: all checks passing

LimiNode and others added 5 commits May 22, 2026 19:24
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.
@LimiNode
LimiNode merged commit c69733c into main May 29, 2026
12 checks passed
@LimiNode
LimiNode deleted the feat/telemetry-registry-context-examples branch June 3, 2026 00:04
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