|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Telemetry |
| 4 | +nav_order: 6 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- prettier-ignore-start --> |
| 8 | + |
| 9 | +{: .no_toc} |
| 10 | + |
| 11 | +# Telemetry Insights |
| 12 | + |
| 13 | +<!-- prettier-ignore --> |
| 14 | + |
| 15 | +- TOC |
| 16 | +{: toc} |
| 17 | + |
| 18 | +<!-- prettier-ignore-end --> |
| 19 | + |
| 20 | +The `@cap-js-community/event-queue` module comes with built-in support for OpenTelemetry, enabling seamless tracing and |
| 21 | +observability of event processing. With this integration, you can track events from publication to execution, ensuring |
| 22 | +full visibility into your system’s event flow. |
| 23 | + |
| 24 | +## Key Features |
| 25 | + |
| 26 | +- **Automatic Event Tracing** – Captures OpenTelemetry traces for event execution, helping you analyze processing times |
| 27 | +- and dependencies. |
| 28 | +- **Trace Context Propagation** – Preserves the OpenTelemetry tracing context when events are published and processed, |
| 29 | +- maintaining a clear linkage across distributed systems. |
| 30 | +- **End-to-End Monitoring** – Ensures that traceability is maintained from the moment an event is created until it is |
| 31 | +- fully processed. |
| 32 | + |
| 33 | +## How It Works |
| 34 | + |
| 35 | +1. **Publishing an Event** |
| 36 | + |
| 37 | + - When an event is published, the current OpenTelemetry trace context is extracted. |
| 38 | + - If no trace context is present, a new one is automatically created. |
| 39 | + - The trace context is then attached to the event metadata. |
| 40 | + |
| 41 | +2. **Processing an Event** |
| 42 | + - Upon processing, the previously stored trace context is retrieved. |
| 43 | + - If no trace context exists, a new one is generated to ensure traceability. |
| 44 | + - Periodic Events never have a existing trace context |
| 45 | + - The trace context is injected back into the OpenTelemetry framework, maintaining continuity. |
| 46 | + |
| 47 | +## Benefits |
| 48 | + |
| 49 | +- **Comprehensive Observability** – Gain insight into event-driven workflows across different services. |
| 50 | +- **Easier Debugging** – Quickly pinpoint performance issues and failure points. |
| 51 | +- **Seamless Integration** – Compatible with OpenTelemetry-based monitoring tools with minimal setup. |
| 52 | + |
| 53 | +## Configuration |
| 54 | + |
| 55 | +By default, OpenTelemetry tracing is enabled if an OpenTelemetry exporter is set up or if Dynatrace OneAgent is |
| 56 | +configured to export traces. However, the OpenTelemetry API must always be installed in the project. |
| 57 | + |
| 58 | +### Trace Context Propagation |
| 59 | + |
| 60 | +The propagation of the trace context can be controlled on an event level using the parameter `inheritTraceContext`. |
| 61 | +By default, this is set to `true`, meaning the trace context will be inherited and propagated during event publishing |
| 62 | +and processing. If set to `false`, the trace context propagation will be disabled for that particular event. |
| 63 | + |
| 64 | +### Disabling Telemetry |
| 65 | + |
| 66 | +Complete telemetry support can be disabled globally with the initialization parameter `enableTelemetry`. The default |
| 67 | +value is `true`, meaning telemetry is enabled. If set to `false`, all telemetry features, including OpenTelemetry |
| 68 | +tracing, will be disabled for the event-queue. |
| 69 | + |
| 70 | +For more advanced configurations, refer to the OpenTelemetry documentation on context propagation and trace exporters. |
| 71 | +This integration also works smoothly with `@cap-js/telemetry`, meaning that if `@cap-js/telemetry` is configured, trace |
| 72 | +exporting works out of the box with no additional setup. |
| 73 | + |
| 74 | +## Pitfalls with OpenTelemetry Tracing and Dynatrace OneAgent |
| 75 | + |
| 76 | +When using Dynatrace OneAgent for trace exporting without a separate OpenTelemetry exporter, there are some important |
| 77 | +limitations to be aware of: |
| 78 | + |
| 79 | +- **Dependency on Dynatrace Trace Context** |
| 80 | + Dynatrace OneAgent only exports traces to Dynatrace if they contain a valid Dynatrace trace context. This context is |
| 81 | + automatically created when an event is published within the scope of an HTTP request or another operation captured by |
| 82 | + Dynatrace OneAgent. |
| 83 | + |
| 84 | +- **Issues with Periodic and Standalone Events** |
| 85 | + Events that are triggered periodically (e.g., scheduled jobs) or published without an existing Dynatrace trace context |
| 86 | + may not be visible in Dynatrace. Since these events lack the necessary Dynatrace trace context, OneAgent does not |
| 87 | + export them unless a separate OpenTelemetry exporter is configured. |
| 88 | + |
| 89 | +### Recommendation |
| 90 | + |
| 91 | +To ensure visibility of all traces—including periodic events or events outside of a Dynatrace-traced request—configure |
| 92 | +a dedicated OpenTelemetry exporter alongside Dynatrace OneAgent. This guarantees that traces are properly exported even |
| 93 | +when a Dynatrace trace context is missing. |
| 94 | + |
| 95 | +## Example Trace |
| 96 | + |
| 97 | + |
0 commit comments