Traces

The agentgateway integrates with Jaeger as the tracing platform. Jaeger is an open source tool that helps you follow the path of a request as it is forwarded between agents. The chain of events and interactions are captured by an OpenTelemetry pipeline that is configured to send traces to the Jaeger agent. You can then visualize the traces by using the Jaeger UI.

Set up Jaeger

Use docker compose to spin up a Jaeger instance with the following components:

  • An OpenTelemetry collector that receives traces from the agentgateway. The collector is exposed on http://localhost:4317.
  • A Jaeger agent that receives the collected traces. The agent is exposed on http://localhost:14268.
  • A Jaeger UI that is exposed on http://localhost:16686.
docker compose -f - up -d <<EOF
services:
  jaeger:
    container_name: jaeger
    restart: unless-stopped
    image: jaegertracing/all-in-one:latest
    ports:
    - "127.0.0.1:16686:16686"
    - "127.0.0.1:14268:14268"
    - "127.0.0.1:4317:4317"
    environment:
    - COLLECTOR_OTLP_ENABLED=true

EOF

Configure the agentgateway

  1. Create a configuration file for your agentgateway. In this example, you configure the following elements:

    • Listener: An HTTP listener that listens for incoming traffic on port 3000.
    • Traces: The agentgateway is configured to send traces to the OpenTelemetry collector that you exposed on http://localhost:4317.
    • Backend: The agentgateway targets a sample, open source MCP test server, server-everything.
    cat <<EOF > ./config.json
    {
      "binds": [
        {
          "port": 3000,
          "listeners": [
            {
              "name": "sse",
              "protocol": "HTTP",
              "hostname": null,
              "routes": [
                {
                  "name": null,
                  "ruleName": null,
                  "hostnames": [],
                  "matches": [
                    {
                      "path": {
                        "pathPrefix": "/"
                      }
                    }
                  ],
                  "policies": null,
                  "backends": [
                    {
                      "mcp": {
                        "targets": [
                          {
                            "name": "everything",
                            "stdio": {
                              "cmd": "npx",
                              "args": [
                                "@modelcontextprotocol/server-everything"
                              ]
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              ],
              "tls": null
            }
          ]
        }
      ],
      "tracing": {
        "tracer": {
          "otlp": {
            "endpoint": "http://localhost:4317"
          }
        }
      }
    }
    EOF
  2. Run the agentgateway.

    agentgateway -f config.json