Skip to content

Conversation

@xuan-cao-swi
Copy link
Contributor

Description

Add optional OpenTelemetry HTTP metrics support for http.server.request.duration and http.client.request.duration while preserving backward compatibility for Ruby users until the metrics SDK matures.

Prometheus dashboard (metrics come from sinatra app that made net http request call)
Screenshot 2025-11-06 at 2 14 51 PM

  • Base
    • Added initialize_metrics hook that instrumentations should override to create instruments (e.g., counters, histograms).
      • initialize_metrics is invoked from install.
      • If no metrics SDK is installed/initialized or metrics are disabled, initialize_metrics does nothing.
    • Metrics are controlled by enable_metrics?, which considers configuration and an environment variable (metrics_env_var_value).
      • Default: disabled. Enable explicitly via config (e.g., {:metrics => true}) or env var.
  • net_http (client)
    • Added a Metrics module that is prepended as a patch to record client request duration.
  • rack (server)
    • Added EventHandlerWithMetrics and TracerMiddlewareWithMetrics to capture and record server-side request durations.

Python and JS instrumentations require metrics; Ruby’s metrics SDK is still developing. This design records metrics safely without forcing changes to existing behavior or requiring a full SDK.

@github-actions
Copy link
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Marks an issue/PR stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant