-
Notifications
You must be signed in to change notification settings - Fork 5k
camel-aws-xray tracing support #2072
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
Conversation
…lities which works similar to the OpenTracing tracer support camel-opentracing provides. This implementation differs, however, slightly from the one of OpenTracing due to the thread-local nature of an AWS XRay segment and its behavior if a new segment is created if already an existing segment is present in the context of the current thread. Upon exchange creation it is first checked whether an existing segment is already present. If not, a new one will be created otherwise a subsegment will be created and added to the existing segment. In case of a multicast the segment is copied over via exchange properties to the intermediary thread created for initializing the respective threads otherwise it wont be able to take notice of the previous segment it belongs to. By default no tracing strategy (= InterceptStragegy) is applied though a tracing subsegment can be created on utilizing EIPTracingStrategy. If only @xraytrace annotated beans and processors (which keep the actual business logic in it in our case) should be tracked TraceAnnotatedTracingStrategy can be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to run also the -Psourcecheck to verify the code style
components/camel-aws-xray/pom.xml
Outdated
<parent> | ||
<artifactId>components</artifactId> | ||
<groupId>org.apache.camel</groupId> | ||
<version>2.19.2-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the version should be 2.21.0-SNAPSHOT in this PR.
@davsclaus can you give a look? |
Oh there was another PR - I commented there. They same applies for this one. |
…view Applied formatting guidlines according to checkstyle
…mpatibilities with the Apache 2.0 licence
@davsclaus I'll wait for you to start the merging process. |
I'm not sure if this PR is really ready for merging yet. I've not yet tested the A thing that bothers me still somehow is, that the decorator classes added just append selected information for certain endpoints as metadata (as of now) to the given (sub)segment. The trace generated though does not contain route-interna like choices or other processor definitions by default as they are not captured by the |
@davsclaus did you get a chance to review the requested changes? |
@oscerd not yet - will try to find some time tomorrow. There is a bit of comments as well to read as well |
…ng the actual processed EIP separated by a colon to the actual name Added service loader provider configuration in oder for ServiceLoader to be able to find actual implementations Added a sanitizeName helper method as AWS does only allow a certain set of characters to appear within a (sub)segment name Updated some tests due to decorators now disable the tracing of i.e. .to("log:...") invocations
Just to give a quick headsup on the current status. The images below are taken from my test project which defines a custom intercept strategy in order to learn which processor definitions got invoked. Note that this sample project does not aim to solve any real world issues and is therefore just a tech-demo. The exchange creation/closing is handled by a The first image also indicates that an error occurred during the SQL query. This error is also set by the On clicking on the exclamation mark AWS will present the stacktrace that lead the component to fail: While I think that this project is on a good track, I don't think it is ready yet for production and needs some more finetuning. I will try to get MySQL, MongoDB and eventually Elasticsearch queries up and running in my sample project in order to determine if AWS can handle other queries besides SQL as well. |
As I managed to get the SQL sample route to work in my tech demo, I experimented with the decorator a bit and, well, the With the above mentioned changes AWS XRay will present the actual query issued in the meta data of the trace while the additional metadata gathered by the decorator are added via a separate SQL tab This tab will filter any unknown properties. While it would allow to add an additional As pulling in additional information into the trace might require to add further dependencies, what is your prefered strategy here? Add the dependencies to camel-aws-xray? Move the decorators to sub-projects like camel-aws-xray-sql or leave that kind of data collection to the user itself who needs that kind of information and therefore just implement a very minimal decorator? |
I guess this PR will need a bit of time to get merged. We'll wait for @davsclaus feedback, since he's the one that worked more on tracing stuff. |
@davsclaus, maybe we can merge this for the moment and do some changes in the future. WDYT? |
Do you know if opentracing or Zipkin can be used to bridge to AWS Xray? Because in that case, we can use them instead of this custom component. The intercept wrapper doesn't not work with async non blocking routing engine. This is a concern about this component. Also, we need to test this against AWS.. Btw I think all your comments, images and stuff can be added to the .adoc, we'll review soon. |
There may be some implementations which I am not aware of that probably bridge OpenTracing spans to XRay (sub)segments. I've only found this python project and some thoughts to position OpenTracing as vendor-neutral bridge for other tracing frameworks so far. I haven't used Zipkin nor OpenTracing so far and thus can't state if the XRay support can be handled via one of the other Camel components. OpenTracing seems to work with spans while XRay uses segments and subsegments. I'm not sure if OpenTracing also utilizes a thread-local acting version of AWSRay in order to manage the lifecycle of spans. If so, it might be possible to unify the approach somehow in order to support both, OpenTracing and XRay.
The
The .adoc documentation needs some update as the code changed notably since I wrote that information. I will see if I can find some time at weekends to update it |
We merged the PR, any other update or something (docs, fixes etc) can be in other PRs. Thanks :-) |
I suggest add some additional information to AbstractSegmentDecorator to extract Rest endpoint data. Also, it would be nice to allow the inclusion of custom decorators. |
@rmaugusto you are surely welcome to contribute. You can create a JIRA ticket for this enhancement |
[ENTESB-19997] Upgrade to BouncyCastle 1.72
As requested by @oscerd I open the PR for the master-branch this time. I copy over the other information from the original
2.19.x
branch PR #2071Added support for AWS XRay tracing (similar to OpenTracing) which tracks the lifecycle of the exchange and invoked EIPs and bean/processors and adds the gathered information to AWS XRay segments. The code itself is currently added to the
2.19.x
branch as we still use2.19.1
internally.AWS XRay will send the data to a locally running daemon listening on UDP port 2000 which sends the gathered data to AWS and presents it as visualization as for service maps
and actual traces 
In the trace image above, a segment corresponds to the bold entries, like
api-file-upload
andprocess-file
while anything indented is a subsegment of the corresponding segment.The code itself does create a new AWS XRay segment for a new exchange unless there is already an active segment available within the threads context. AWS XRay manages its segments on a thread-local basis and discards any information gathered in case a new segment is spawned although an already active segment is present in the threads context. To circumvent data loss, the implementation will check first if already an active segment is present in the current threads context and only then create a new one. If already an active segment is present (in case of
.to("direct:foo")
the creation of a new exchange will add a subsegment to the current segment. As multicast with parallel processing enabled will spawn new threads in a separate thread, the segment is copied over via an exchange property and set manually for threads which name contains a multicast name.The images above contains only traces of
.bean(...)
and.process(...)
instances which are a annotated with@XRayTrace
. This annotation is processed by TraceAnnotatedTracingStrategy which adds subsegments for the respective beans to the AWS XRay segment. If no tracing strategy (= InterceptStrategy) is configured, this implementation will default to aNoopTracingStrategy
which as its name suggest will do nothing. A very simpleEIPTracingStrategy
is also provided which adds subsegments for the currently processedProcessorDefinition
s short name to the current segment.