Setup Data Streams Monitoring for Java

Prerequisites

Supported libraries

TechnologyLibraryMinimal tracer versionRecommended tracer version
Kafkakafka-clients1.9.01.43.0 or later
RabbitMQamqp-client1.9.01.42.2 or later
Amazon SQSaws-java-sdk-sqs (v1)1.27.01.42.2 or later
Amazon SQSsqs (v2)1.27.01.42.2 or later
Amazon KinesisKinesis (v1)1.22.01.42.2 or later
Amazon KinesisKinesis (v2)1.22.01.42.2 or later
Amazon SNSSNS (v1)1.31.01.42.2 or later
Amazon SNSSNS (v2)1.31.01.42.2 or later
Google PubSubGoogle Cloud Pub/Sub1.25.01.42.2 or later

Installation

Java uses auto-instrumentation to inject and extract additional metadata required by Data Streams Monitoring for measuring end-to-end latencies and the relationship between queues and services. To enable Data Streams Monitoring, set the DD_DATA_STREAMS_ENABLED environment variable to true on services sending messages to (or consuming messages from) Kafka, SQS or RabbitMQ.

Also, set the DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED variable to true so that DD_SERVICE is used as the service name in traces.

For example:

environment:
  - DD_DATA_STREAMS_ENABLED: "true"
  - DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: "true"

As an alternative, you can set the -Ddd.data.streams.enabled=true system property by running the following when you start your Java application:

java -javaagent:/path/to/dd-java-agent.jar -Ddd.data.streams.enabled=true -Ddd.trace.remove.integration-service-names.enabled=true -jar path/to/your/app.jar

One-Click Installation

To set up Data Streams Monitoring from the Datadog UI without needing to restart your service, use Configuration at Runtime. Navigate to the APM Service Page and Enable DSM.

Enable the Data Streams Monitoring from the Dependencies section of the APM Service Page

Monitoring SQS pipelines

Data Streams Monitoring uses one message attribute to track a message’s path through an SQS queue. As Amazon SQS has a maximum limit of 10 message attributes allowed per message, all messages streamed through the data pipelines must have 9 or fewer message attributes set, allowing the remaining attribute for Data Streams Monitoring.

Manual instrumentation

Data Streams Monitoring propagates context through message headers. If you are using a message queue technology that is not supported by DSM, a technology without headers (such as Kinesis), or Lambdas, use manual instrumentation to set up DSM.

Further Reading

Additional helpful documentation, links, and articles: