How to integrate with Jaeger on Docker

Last updated: 2 minutes read.

This quick start guide offers a detailed, step-by-step walkthrough for configuring Tyk API Gateway (OSS, self-managed or hybrid gateway connected to Tyk Cloud) with OpenTelemetry and Jaeger to significantly improve API observability. We will cover the installation of essential components, their configuration, and the process of ensuring seamless integration.

For Kubernetes instructions, please refer to How to integrate with Jaeger on Kubernetes.

Prerequisites

Ensure the following prerequisites are met before proceeding:

Step 1: Create the Docker-Compose File for Jaeger

Save the following YAML configuration in a file named docker-compose.yml:

Copy code
version: "2" services: # Jaeger: Distributed Tracing System jaeger-all-in-one: image: jaegertracing/all-in-one:latest ports: - "16686:16686" # Jaeger UI - "4317:4317" # OTLP receiver

This configuration sets up Jaeger’s all-in-one instance with ports exposed for Jaeger UI and the OTLP receiver.

Step 2: Deploy a Test API Definition

If you haven’t configured any APIs yet, follow these steps:

  • Create a subdirectory named apps in the current directory.
  • Create a new file named apidef-hello-world.json.
  • Copy the provided simple API definition below into the apidef-hello-world.json file:
Copy code
{ "name": "Hello-World", "slug": "hello-world", "api_id": "Hello-World", "org_id": "1", "use_keyless": true, "detailed_tracing": true, "version_data": { "not_versioned": true, "versions": { "Default": { "name": "Default", "use_extended_paths": true } } }, "proxy": { "listen_path": "/hello-world/", "target_url": "http://echo.tyk-demo.com:8080/", "strip_listen_path": true }, "active": true }

This API definition sets up a basic API named Hello-World for testing purposes, configured to proxy requests to http://echo.tyk-demo.com:8080/.

Step 3: Run Tyk Gateway OSS with OpenTelemetry Enabled

To run Tyk Gateway with OpenTelemetry integration, extend the previous Docker Compose file to include Tyk Gateway and Redis services. Follow these steps:

  • Add the following configuration to your existing docker-compose.yml file:
Copy code
# ... Existing docker-compose.yml content for jaeger tyk: image: tykio/tyk-gateway:v5.2.0 ports: - 8080:8080 environment: - TYK_GW_OPENTELEMETRY_ENABLED=true - TYK_GW_OPENTELEMETRY_EXPORTER=grpc - TYK_GW_OPENTELEMETRY_ENDPOINT=jaeger-all-in-one:4317 volumes: - ${TYK_APPS:-./apps}:/opt/tyk-gateway/apps depends_on: - redis redis: image: redis:4.0-alpine ports: - 6379:6379 command: redis-server --appendonly yes
  • Navigate to the directory containing the docker-compose.yml file in your terminal.
  • Execute the following command to start the services:
Copy code
docker compose up

Step 4: Explore OpenTelemetry Traces in Jaeger

  • Start by sending a few requests to the API endpoint configured in Step 2:
Copy code
curl http://localhost:8080/hello-world/ -i
  • Access Jaeger at http://localhost:16686.
  • In Jaeger’s interface:
    • Select the service named tyk-gateway.
    • Click the Find Traces button.

You should observe traces generated by Tyk Gateway, showcasing the distributed tracing information.

Tyk API Gateway distributed trace in Jaeger

Select a trace to visualize its corresponding internal spans:

Tyk API Gateway spans in Jaeger