You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 60bc55f
Browse filesBrowse the repository at this point in the historyBrowse files
feat!(opentelemetry): add push notification tracing and trace-context propagation
- PushNotificationSender.sendNotification() returns boolean to let decorators observe delivery outcome
- OpenTelemetryPushNotificationSenderDecorator wraps sendNotification() with a span and records delivery failures
- OpenTelemetryA2AHttpClient injects W3C trace-context headers into outbound push-notification POSTs
- @Instrumented CDI qualifier selects a custom A2AHttpClient bean to wrap rather than replacing it
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Copy file name to clipboardExpand all lines: compat-0.3/server-conversion/src/test/java/org/a2aproject/sdk/compat03/conversion/AbstractA2ARequestHandlerTest_v0_3.java
Copy file name to clipboardExpand all lines: docs/content/dev/extra/http-clients.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,3 +266,9 @@ public class MyHttpClientProducer {
266
266
| 0 | JDK | Always (fallback) |
267
267
268
268
If the CDI container is active but no `A2AHttpClient` bean is registered, this provider is skipped and the next available provider is used.
269
+
270
+
### Compatibility with OpenTelemetry
271
+
272
+
When the [OpenTelemetry server module](opentelemetry.md) is on the classpath alongside a custom `A2AHttpClient` CDI bean, the OpenTelemetry module wraps your bean with trace-context propagation rather than replacing it. Your custom configuration (mTLS, proxy, authentication, timeouts, etc.) is preserved for push notification delivery while `traceparent` and `tracestate` headers are injected automatically.
273
+
274
+
This works through the `@Instrumented` CDI qualifier (defined in `server-common`): the OpenTelemetry module produces an `@Instrumented A2AHttpClient` that delegates to your unqualified bean. `BasePushNotificationSender` prefers the `@Instrumented` variant when available, so both your custom configuration and the trace-context headers are present on outbound requests. No changes to your producer code are required.
Copy file name to clipboardExpand all lines: docs/content/dev/extra/opentelemetry.md
+65-1Lines changed: 65 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,49 @@ The following attributes are automatically added to spans (defined in `A2AObserv
106
106
|`gen_ai.agent.a2a.response`| Full response data (only if extraction enabled) |
107
107
|`error.type`| Error message (on failures) |
108
108
109
+
### Push Notification Delivery Tracing
110
+
111
+
When the server delivers a push notification to a client webhook, `OpenTelemetryPushNotificationSenderDecorator` creates a `CLIENT` span named `SendPushNotification`. This span is independent of the original request span but carries the `gen_ai.agent.a2a.task_id` attribute, allowing correlation by task ID in your observability tool. The span status reflects the actual delivery outcome: `OK` when all notifications succeed, `ERROR` when one or more deliveries fail (with `error.type` set to `delivery_failed`) or when an exception is thrown.
112
+
113
+
The module also provides **W3C trace-context propagation** for outbound push notification HTTP requests via the `@Instrumented` CDI qualifier and `OpenTelemetryHttpClientProducer`.
114
+
115
+
#### How it works
116
+
117
+
The `OpenTelemetryHttpClientProducer` CDI bean produces an `@Instrumented A2AHttpClient` — a wrapper that injects `traceparent` and `tracestate` headers into every outbound HTTP request. `BasePushNotificationSender` resolves the HTTP client in this order:
118
+
119
+
1. An `@Instrumented A2AHttpClient` bean (if available — e.g. the one produced by this module)
120
+
2. An unqualified `A2AHttpClient` bean (if the application provides one)
121
+
3.`A2AHttpClientFactory.create()` as last resort
122
+
123
+
The `@Instrumented` qualifier (defined in `server-common`) marks HTTP client beans that have been wrapped with observability instrumentation. It ensures the instrumented client does not compete with the application's own `A2AHttpClient` bean in default CDI resolution — the two coexist, and the instrumented variant wraps the application's bean as its delegate.
124
+
125
+
#### Custom HTTP client compatibility
126
+
127
+
If your application provides a custom `A2AHttpClient` CDI bean (e.g. for mTLS, proxy, or custom timeouts), the OpenTelemetry wrapper **preserves that configuration** by delegating to your bean rather than replacing it. No additional annotations or configuration are needed — just produce your bean as usual:
128
+
129
+
```java
130
+
@Produces
131
+
@ApplicationScoped
132
+
publicA2AHttpClient myHttpClient() {
133
+
// your custom client (mTLS, proxy, auth, etc.)
134
+
}
135
+
```
136
+
137
+
The OpenTelemetry module automatically wraps it with trace-context injection.
138
+
139
+
#### Context-propagating executor
140
+
141
+
The producer also creates a context-propagating `Executor` (via `Context.taskWrapping()`) that ensures the OTel trace context survives the async boundary when push notifications are dispatched to multiple recipients in parallel. This allows the receiving webhook to join the distributed trace.
Copy file name to clipboardExpand all lines: extras/opentelemetry/common/src/main/java/org/a2aproject/sdk/extras/opentelemetry/A2AObservabilityNames.java
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,4 +20,8 @@ public interface A2AObservabilityNames {
Copy file name to clipboardExpand all lines: extras/opentelemetry/integration-tests/src/main/java/org/a2aproject/sdk/extras/opentelemetry/it/A2ATestRoutes.java
Copy file name to clipboardExpand all lines: extras/opentelemetry/integration-tests/src/main/java/org/a2aproject/sdk/extras/opentelemetry/it/TestAgentCardProducer.java
Copy file name to clipboardExpand all lines: extras/opentelemetry/integration-tests/src/main/java/org/a2aproject/sdk/extras/opentelemetry/it/TestUtilsBean.java
0 commit comments