-
Notifications
You must be signed in to change notification settings - Fork 119
feat: Add telemetry support. #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ehsavoie
wants to merge
1
commit into
a2aproject:main
Choose a base branch
from
ehsavoie:issue_388
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,435
−177
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
client/transport/spi/src/main/java/io/a2a/client/transport/spi/ClientTransportWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package io.a2a.client.transport.spi; | ||
|
|
||
| /** | ||
| * Service provider interface for wrapping client transports with additional functionality. | ||
| * Implementations can add cross-cutting concerns like tracing, metrics, logging, etc. | ||
| * | ||
| * <p>Wrappers are discovered via Java's ServiceLoader mechanism. To register a wrapper, | ||
| * create a file {@code META-INF/services/io.a2a.client.transport.spi.ClientTransportWrapper} | ||
| * containing the fully qualified class name of your implementation. | ||
| * | ||
| * <p>Wrappers are sorted by priority in descending order (highest priority first). | ||
| * This interface implements {@link Comparable} to enable natural sorting. | ||
| * | ||
| * <p>Example implementation: | ||
| * <pre>{@code | ||
| * public class TracingWrapper implements ClientTransportWrapper { | ||
| * @Override | ||
| * public ClientTransport wrap(ClientTransport transport, ClientTransportConfig<?> config) { | ||
| * if (config.getParameters().containsKey("tracer")) { | ||
| * return new TracingTransport(transport, (Tracer) config.getParameters().get("tracer")); | ||
| * } | ||
| * return transport; | ||
| * } | ||
| * | ||
| * @Override | ||
| * public int priority() { | ||
| * return 100; // Higher priority = wraps earlier (outermost) | ||
| * } | ||
| * } | ||
| * }</pre> | ||
| */ | ||
| public interface ClientTransportWrapper extends Comparable<ClientTransportWrapper> { | ||
|
|
||
| /** | ||
| * Wraps the given transport with additional functionality. | ||
| * | ||
| * <p>Implementations should check the configuration to determine if they should | ||
| * actually wrap the transport. If the wrapper is not applicable (e.g., required | ||
| * configuration is missing), return the original transport unchanged. | ||
| * | ||
| * @param transport the transport to wrap | ||
| * @param config the transport configuration, may contain wrapper-specific parameters | ||
| * @return the wrapped transport, or the original if wrapping is not applicable | ||
| */ | ||
| ClientTransport wrap(ClientTransport transport, ClientTransportConfig<?> config); | ||
|
|
||
| /** | ||
| * Returns the priority of this wrapper. Higher priority wrappers are applied first | ||
| * (wrap the transport earlier, resulting in being the outermost wrapper). | ||
| * | ||
| * <p>Default priority is 0. Suggested ranges: | ||
| * <ul> | ||
| * <li>1000+ : Critical infrastructure (security, authentication) | ||
| * <li>500-999: Observability (tracing, metrics, logging) | ||
| * <li>100-499: Enhancement (caching, retry logic) | ||
| * <li>0-99: Optional features | ||
| * </ul> | ||
| * | ||
| * @return the priority value, higher values = higher priority | ||
| */ | ||
| default int priority() { | ||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * Compares this wrapper with another based on priority. | ||
| * Returns a negative integer, zero, or a positive integer as this wrapper | ||
| * has higher priority than, equal to, or lower priority than the specified wrapper. | ||
| * | ||
| * <p>Note: This comparison is reversed (higher priority comes first) to enable | ||
| * natural sorting in descending priority order. | ||
| * | ||
| * @param other the wrapper to compare to | ||
| * @return negative if this has higher priority, positive if lower, zero if equal | ||
| */ | ||
| @Override | ||
| default int compareTo(ClientTransportWrapper other) { | ||
| // Reverse comparison: higher priority should come first | ||
| return Integer.compare(other.priority(), this.priority()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.