Tracing
The router provides built-in tracing support that extends to your plugins. This allows you to trace operations from the router through to your plugin code. To enable tracing in your plugin, use theWithTracing()
option when initializing:
How tracing works
When your plugin starts up, the router shares its telemetry configuration with the plugin. This configuration includes crucial trace context such as thetraceparent
value.
When you enable tracing in your plugin using WithTracing()
, the plugin uses this shared configuration to set up its own tracing. This ensures that any operations performed by your plugin become part of the same distributed trace that originated from the router.
Additionally, when your plugin makes HTTP requests using the provided HTTP client, the trace context is automatically propagated to downstream services. This creates an unbroken chain of tracing that spans from the initial router request, through your plugin, and into any external APIs you call.