Skip to main content
In this lesson we’ll replace the ConsoleSpanExporter (which prints spans to stdout) with an exporter that sends traces to a tracing backend. Printing spans to the console is useful for local debugging, but production systems typically send traces to a backend such as Jaeger or a hosted OTLP-compatible service. Why this matters:
  • ConsoleSpanExporter: good for quick debugging and tests.
  • OTLP exporter: sends traces to real backends for storage, visualization, and correlation across services.

Current tracer configuration (ConsoleSpanExporter)

Example: a minimal tracer setup that prints spans to the console:
A typical ConsoleSpanExporter output for a span might look like this JSON representation:

Exporting to Jaeger via OTLP

Rather than printing spans locally, we’ll send them to Jaeger. Jaeger accepts traces via the OpenTelemetry Protocol (OTLP), so we can use the OTLP HTTP exporter provided by OpenTelemetry instead of a Jaeger‑specific exporter. This keeps your instrumentation portable to any OTLP-compatible backend.
Jaeger supports OTLP (HTTP and gRPC). Using the OTLP exporter keeps your instrumentation portable to any backend that accepts OTLP, not just Jaeger.
Install the OTLP HTTP exporter package:
Verify installation (example output; versions may differ):

Update tracer configuration to use OTLPSpanExporter

When sending to a local Jaeger instance, the OTLP HTTP endpoint is typically http://localhost:4318/v1/traces. Update your tracer configuration to use the OTLP HTTP exporter:
Notes:
  • Use BatchSpanProcessor in production; it buffers spans and sends them efficiently. SimpleSpanProcessor sends synchronously and can hurt performance.
  • OTLP over HTTP commonly uses port 4318 and the /v1/traces path. If using OTLP/gRPC or a hosted service, verify the endpoint and protocol in the backend docs.
Make sure the endpoint, protocol (HTTP vs gRPC), and any required authentication match your Jaeger or hosted OTLP service. Sending to the wrong endpoint or protocol will result in dropped traces.

Quick comparison

ExporterUse caseExample configuration
ConsoleSpanExporterLocal debugging and developmentConsoleSpanExporter()
OTLPSpanExporter (HTTP)Send traces to Jaeger or any OTLP-compatible backendOTLPSpanExporter(endpoint="http://localhost:4318/v1/traces")

Run your instrumented application

Save the updated configuration and run your application. The application’s runtime output (print statements) will remain the same, but span data will be exported to Jaeger:
After running, open the Jaeger UI (usually at http://localhost:16686) and search for traces. In this example the traces appear, but the service is shown as unknown_service — we’ll fix the service/resource name in the next step.
The image shows the Jaeger UI with search parameters for tracing a service labeled "unknown_service" and displaying one trace related to a payment service.
The trace shown includes spans for the payment flow (start payment, validating card, charge bank), confirming that OTLP export to Jaeger is working. In the following lesson we’ll configure the Resource (service name and attributes) so traces display with a meaningful service name in Jaeger.

References

Watch Video