The :tracing plugin allows interception of tracepoints around the request lifecycle. It was designed to easen the integration of instrumentation/tracing platforms, and both the open-telemetry or datadog integrations are built on top of it.
You can add a custom integration to your metrics/tracing platform by passing an integration object to :tracer:
http = HTTP.plugin(:tracing, tracer: my_home_metrics_collector)
http.get("http://www.example.com")
You can chain several integrations too:
http = HTTP.plugin(:tracing).with(tracer: telemetry_platform_tracer).with(tracer: metrics_collector)
A new option :tracer accepts an object which must respond to the following callbacks:
#enabled?(request) - should return true or false depending on whether instrumentation/traccing is enabled#start(request) - called when a request is about to be sent#finish(request, response) - called when a response is received#reset(request) - called when a request is being prepared to be resent, in cases where it makes sense (i.e. when a request is retried via the retries plugin).Next: Custom Plugins