Skip to main content
This guide explains how to set up Dynatrace to ingest OpenTelemetry traces via the OpenTelemetry Collector (OTel Collector) using Docker.

Prerequisites

If Dynatrace OneAgent runs on your Tyk Gateway hosts, you can send traces to OneAgent instead of the OTel Collector. See Use Dynatrace OneAgent Instead of the OTel Collector.

Instructions

Step 1. Generate Dynatrace Token

  1. In the Dynatrace console, navigate to access keys.
  2. Click on Create a new key
  3. You will be prompted to select a scope. Choose Ingest OpenTelemetry traces.
  4. Save the generated token securely; it cannot be retrieved once lost. Example of a generated token (taken from Dynatrace website):

Step 2. Configuration Files

  1. OTel Collector Configuration File Create a YAML file named otel-collector-config.yml. In this file replace <YOUR-ENVIRONMENT-STRING> with the string from the address bar when you log into Dynatrace. Replace <YOUR-DYNATRACE-API-KEY> with the token you generated earlier. Here’s a sample configuration file:
  1. Docker Compose File Create a file named docker-compose.yml. Here is the sample Docker Compose file:

Step 3. Testing and Viewing Traces

  1. Launch the Docker containers: docker-compose up -d
  2. Initialize your Tyk environment.
  3. Deploy a simple HTTP API on your Tyk Gateway.
  4. Use cURL or Postman to send requests to the Gateway.
  5. Navigate to Dynatrace -> Services -> Tyk-Gateway. Dynatrace Services
  6. Wait for 5 minutes and refresh.
  7. Traces, along with graphs, should appear. If they don’t, click on the “Full Search” button. Dynatrace Metrics
And there you have it! You’ve successfully integrated Dynatrace with the OpenTelemetry Collector using Docker.

Use Dynatrace OneAgent Instead of the OTel Collector

Dynatrace OneAgent can run on your Tyk Gateway hosts in Full-Stack Monitoring or Infrastructure Monitoring mode. In this case, Tyk Gateway can send traces to the local OTLP endpoint of OneAgent. OneAgent then sends the traces to Dynatrace. You do not need the OTel Collector.
The OneAgent OTLP endpoint is not available for container deployments. If Tyk Gateway runs in a container, use the OTel Collector setup on this page.
In Full-Stack Monitoring mode, OneAgent can also trace Tyk Gateway with its own Go instrumentation. On hosts, this requires Go monitoring and a process monitoring rule for the Tyk Gateway process. See Enable Go monitoring. These OneAgent traces do not include Tyk Gateway span attributes, such as tyk.api.name and tyk.api.id, or middleware spans. To get Tyk Gateway spans in Dynatrace, use the steps below. To send traces to OneAgent:
  1. Enable the OneAgent OTLP endpoint. In Dynatrace, enable the Extension Execution Controller for your Tyk Gateway hosts. See Use OneAgent with OpenTelemetry data. For an environment-level setup, also turn on the Enable local HTTP Metric, Log and Event Ingest API setting.
  2. Configure tracing in Tyk Gateway. Use the http exporter and the OneAgent port. The OneAgent endpoint accepts OTLP over HTTP only. The default port is 14499.
  3. Set the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable for the Tyk Gateway process.
    Tyk Gateway uses only the host and port from opentelemetry.traces.endpoint, and sends traces to the /v1/traces path. The OneAgent endpoint uses the /otlp/v1/traces path. This environment variable sets the correct path.
  4. Restart Tyk Gateway.
Do not enable the OpenTelemetry (Go) OneAgent feature while Tyk Gateway sends traces to the OneAgent endpoint. If both are active, Dynatrace creates duplicate spans.

Trace Retention in Dynatrace

In Dynatrace environments that use Grail, Dynatrace keeps traces for 10 days by default. It keeps logs for 35 days and metrics for 15 months. To keep trace data for a longer time, create a custom span bucket with a longer retention period and route spans to it. See How to organize your data stored in Grail and Configure data storage and retention for Distributed Tracing.

Troubleshooting

If traces are not appearing:
  • try clicking on the “Full Search” button after waiting for 5 minutes.
  • Make sure your Dynatrace token is correct in the configuration files.
  • Validate the Docker Compose setup by checking the logs for any errors: docker-compose logs