News KrakenD CE v2.8 released with improved Lua and OpenTelemetry

You are viewing a previous version of KrakenD Enterprise Edition (v2.2), go to the latest version

Document updated on Feb 28, 2023

Exporting traces to Datadog

Exporting traces to Datadog

Datadog is a cloud monitoring and security platform for developers, IT operations teams, and businesses.

Datadog configuration

The Opencensus exporter allows you to export data to Datadog. Enabling it only requires adding the datadog exporter in the opencensus module.

The following configuration snippet sends data to your Datadog:

{
      "version": 3,
      "extra_config": {
        "telemetry/opencensus": {
          "sample_rate": 100,
          "reporting_period": 0,
          "exporters": {
            "datadog": {
              "tags": [
                "gw"
              ],
              "global_tags": {
                "env": "prod"
              },
              "disable_count_per_buckets": true,
              "trace_address": "localhost:8126",
              "stats_address": "localhost:8125",
              "namespace": "krakend",
              "service": "gateway"
            }
          }
        }
      }
}

As with all OpenCensus exporters, you can add optional settings in the telemetry/opencensus level:

Fields of "telemetry/opencensus"
* required fields

enabled_layers
Lets you specify what data you want to export. All layers are enabled by default unless you declare this section.
backend boolean
Reports the activity between KrakenD and your services
Defaults to false
pipe boolean
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
router boolean
Reports the activity between end-users and KrakenD
Defaults to false
reporting_period integer
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_rate integer
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 an datadog entry with the following properties:

Fields of "telemetry/opencensus": { "exporters":{} }
* required fields

datadog object
Datadog is a monitoring and security platform for developers, IT operations teams and business in the cloud.
disable_count_per_buckets boolean
Specifies whether to emit count_per_bucket metrics.
Defaults to false
global_tags object
A set of tags (key/value) that will automatically be applied to all exported spans.
Example: {"env":"prod"}
namespace string
The namespace to which metric keys are appended.
service string
Service specifies the service name used for tracing
Example: "gateway"
stats_address string
Specifies the host[:port] address for DogStatsD. To enable ingestion using Unix Domain Socket (UDS) mount your UDS path and reference it in the stats_address using a path like unix:///var/run/datadog/dsd.socket.
Example: "localhost:8125"
Defaults to "localhost:8125"
tags array
Specifies a set of global tags to attach to each metric.
trace_address string
Specifies the host[:port] address of the Datadog Trace Agent.
Defaults to "localhost:8126"

B3 propagation

The Opencensus module uses B3-style propagation headers, while the rest of your services might be using Datadog-specific propagation headers. If this difference is actual, krakend traces will show up in Datadog, but they won’t be connected to the frontend and backend traces.

The ddtrace-run adds an option to support B3 style propagation using the environment variables DD_TRACE_PROPAGATION_STYLE_EXTRACT and DD_TRACE_PROPAGATION_STYLE_INJECT. Use these variables to have your traces perfectly aligned.

For more information, see its configuration.

Datadog agent

You must set your Datadog API key in the agent. The exporter communicates with the agent and is the agent the one reporting to Datadog.

Here’s an example of how to run the Datadog agent together with KrakenD in a docker-compose file:

krakend:
  image:
ddagent:
  image: gcr.io/datadoghq/agent:latest
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro
    - /proc/:/host/proc/:ro
    - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
  ports:
    - 8126:8126/tcp
    - 8125:8125/udp
  environment:
    - DD_API_KEY=<API-KEY>
    - DD_APM_ENABLED=true
    - DD_SITE=<DATADOG-SITE>
    - DD_APM_NON_LOCAL_TRAFFIC=true

And the configuration would contain:

{ "datadog":
  {
    "@comment": "Rest of the necessary fields intentionally omitted",
    "trace_address": "ddagent:8126",
    "stats_address": "ddagent:8125"
  }
}

Notice that we are naming the service ddagent in Docker compose, and this is what we have added in the address.

Scarf

Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.

See all support channels