Case Study Jobteaser Case Study: Scalable Public APIs with KrakenD

Document updated on Oct 24, 2022

AWS X-Ray Telemetry Integration

AWS X-Ray is a service offered by Amazon that provides an end-to-end view of requests as they travel through your application, and shows a map of your application’s underlying components.

The Opencensus exporter allows you export data to AWS X-Ray. Enabling it only requires you to add the xray exporter in the opencensus module.

Consider switching to OpenTelemetry
The AWS Distro for OpenTelemetry Collector (ADOT Collector) is an AWS supported version of the upstream OpenTelemetry Collector and is distributed by Amazon. It enables users to send telemetry data to AWS CloudWatch Metrics, Traces, and Logs backends as well as the other supported backends. See how to configure OpenTelemetry

The following configuration snippet sends data to your X-Ray:

{
  "extra_config": {
    "telemetry/opencensus": {
      "sample_rate": 100,
      "reporting_period": 0,
      "exporters": {
        "xray": {
          "version": "latest",
          "region": "eu-west-1",
          "use_env": false,
          "access_key_id": "myaccesskey",
          "secret_access_key": "mysecretkey"
        }
      }
    }
  }
}

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 xray entry with the following properties:

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

xray object
AWS X-Ray is a service offered by Amazon that provides an end-to-end view of requests as they travel through your application, and shows a map of your application’s underlying components.
* Required one of: ( region + version + access_key_id + secret_access_key ) , or ( region + version + use_env )
access_key_id string
Your access key ID provided by Amazon. Needed when use_env is unset or set to false.
region string
The AWS geographical region, e.g, us-east-1.
Example: "eu-west-1"
secret_access_key string
Your secret access key provided by Amazon. Needed when use_env is unset or set to false.
use_env boolean
When true the AWS credentials (access_key_id and secret_access_key) are taken from environment vars. Don’t specify them then.
Defaults to false
version string
The version of the AWS X-Ray service to use.
Defaults to "KrakenD-opencensus"

See also the additional settings of the Opencensus module that can be declared.

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