Document updated on Feb 3, 2023
Exporting traces to Jaeger
The KrakenD exporter to Jaeger allows you to submit spans to a Jaeger Collector (HTTP) or Jaeger Agent (UDP) automatically.
Jaeger is an open-source, end-to-end distributed tracing system that allows you to monitor and troubleshoot transactions in complex distributed systems. Use Jaeger when you want to see the complete flow of a user request through KrakenD and its connected services.
The Opencensus Jaeger exporter allows you to export spans to Jaeger. Enabling it only requires you to add the jaeger exporter in the opencensus module. You can post spans using two different approaches:
- Submit spans to an Agent (Thrift over UDP) - using
agent_endpoint - Submit spans to a Collector (Thrift over HTTP) - using
endpoint
You can test this setup by running the All in One official Jaeger image and opening the necessary ports. For instance, to run a Jaeger container for UDP and HTTP support do:
Term
$docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp \
-p 5778:5778 -p 16686:16686 -p 14268:14268 -p 9411:9411 \
jaegertracing/all-in-one:latestThen use agent_endpoint pointing to jaeger:6831 for the Jaeger Agent (UDP) or endpoint pointing to http://jaeger:14268 for the Jaeger Collector (HTTP).
Collector - Thrift over HTTP
When you don’t have a Jaeger Agent deployed next to the application, you can submit all spans to a Jaeger Collector over HTTP/HTTPS somewhere else. To do that, use the endpoint configuration option inside jaeger, as follows:
{
"extra_config":{
"telemetry/opencensus": {
"sample_rate": 100,
"reporting_period": 0,
"exporters": {
"jaeger": {
"endpoint": "http://jaeger:14268/api/traces",
"service_name":"krakend",
"buffer_max_count": 1000
}
}
}
}
}
You can find a running demo with Jaeger using docker compose on KrakenD Playground.
Agent - Thrift over UDP
When you want to send spans to a Jaeger Agent locally over UDP in Thrift format, you need to use the agent_endpoint configuration. To configure the gateway to work with an agent, you will need the following:
{
"extra_config":{
"telemetry/opencensus": {
"sample_rate": 100,
"reporting_period": 0,
"exporters": {
"jaeger": {
"agent_endpoint": "jaeger:6831",
"service_name":"krakend",
"buffer_max_count": 1000
}
}
}
}
}
Jaeger configuration options
As with all OpenCensus exporters, you can add optional settings in the telemetry/opencensus level:
Fields of "telemetry/opencensus"
enabled_layers- Lets you specify what data you want to export. All layers are enabled by default unless you declare this section.
backendboolean- Reports the activity between KrakenD and your servicesDefaults to
false pipeboolean- Reports the activity at the beginning of the proxy layer. It gives a more detailed view of the internals of the pipe between end-users and KrakenD, having into account merging of different backends.Defaults to
false routerboolean- Reports the activity between end-users and KrakenDDefaults to
false
reporting_periodinteger- The number of seconds passing between reports. If duration is less than or equal to zero, it enables the default behavior of each exporter.Defaults to
0 sample_rateinteger- A number between 0 (no requests at all) and 100 (all requests) representing the percentage of sampled requests you want to send to the exporter. Sampling the 100% of the requests is generally discouraged when the relationship between traffic and dedicated resources is sparse.Defaults to
0
Then, the exporters key must contain the jaeger entry with the following properties:
Fields of "telemetry/opencensus": { "exporters":{} }
jaegerobject- Submit spans to a Jaeger Collector (HTTP) with
endpointor to a Jaeger Agent (UDP) withagent_endpoint.* Required one of: (endpoint+service_name) , or (agent_endpoint+service_name)agent_endpointstring- The address where the Jaeger Agent is (Thrift over UDP), e.g.,
jaeger:6831Example:"http://192.168.99.100:14268/api/traces" buffer_max_countinteger- Total number of traces to buffer in memory
endpointstring- The full URL including port indicating where your Jaeger Collector is (Thrift over HTTP/S), e.g.,
http://jaeger:14268/api/tracesExample:"http://192.168.99.100:14268/api/traces" service_namestring- The service name registered in JaegerExample:
"krakend"
