This document explains what the Datadog APM Connector is, how to configure it and how to make use of it.
Software required:
-
Java JDK 8.
-
Anypoint Studio 7 or greater.
-
Apache Maven 3.3.9 or greater.
Using the Connector
The Connector has 6 operations:
-
Create Span
-
Finish Span
-
Update Span
-
Activate Span
-
Finish All
-
Logger
Additionally, it has a Global Configuration called Datadog APM Config.
Datadog APM Config
The Datadog APM Config is the global configuration of the Connector. It establishes the connection between the Mule application and the Datadog agent running APM.
-
These are the connection settings, here you set the host where the Datadog Agent is running, and the port, by default the traces are sent via port 8126.
-
These are optional information to give more context about the connection, by default the service name is unnamed-java-app, even if this field is empty.
Operations
Create Span
The create span operation as states, creates a new span in the flow, it will run in the flow until it gets finished. A span can contain Children, and those Children as well can contain Children and so on, this is useful to add granularity to the project.
The operation looks like this:
-
Display name: By default is displayed as Create Span.
-
Connector configuration: This is where the Datadog Global Configuration is set, required.
-
Span name: required.
-
Parent: The parent of the created span, optional.
-
Finish this span at the end of the main flow: This checkbox ensures that the span will be closed automatically at the end of the flow execution, the default is unchecked.
-
Tags: These are key-value pairs that can be set Inline or with Dataweave expressions, this provides labels attached to the spans that are created in execution time, optional.
-
HTTP Request Tags: Additional info the user can provide to the span, in this case the HTTP Method and the URI Path in case the user may require it for REST Services. Accept Dataweave expressions as well as static values. optional.
The following is an example of how to assign a child span to a parent. This flow will be used as the main example thoughout the different operation explanations. Let’s check how this can be useful.
There are 3 spans created in the flow: Parent, Child, and GrandChild
The main span is called Parent, then in the Child span we assign the Parent field as Parent, which is the name of the first span created, and finally, we assign GrandChild span Parent field as Child.
With this we have the following hierarchy:
Parent will contain Child, at the same time Child will contain GrandChild.
If we run the following flow and go to the Datadog APM, the result is this trace:
And here the spans created:
As you can see, Child and GrandChild are nested to the Parent. Nesting can have n level.