-
Notifications
You must be signed in to change notification settings - Fork 791
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
Sort instrumentations before adding them to ByteBuddy #1326
Sort instrumentations before adding them to ByteBuddy #1326
Conversation
How exactly do you think achieving the desired order? Can you give an example? |
Let's say upstream instrumentation is named BTW. I have noticed that the instrumentations are always loaded in alphanumeric order, however the java service loader does not document that it's guaranteed so I would like to sort them before adding to BB. |
You mean, e.g. |
At least it solves my problem :) It is clearly described that it's better to combine advice methods, however this is not always possible. The custom instrumentations are tested with the upstream version so the bugs should be easily detected. An alternative approach could be to expose |
@trask @tylerbenson WDYT? |
I like this, glowroot has similar: I like the term "order" over "priority" because the term priority is always unclear to me whether low or high values have preference (thanks linux 😂). But I can live with priority if others prefer that. |
I also don't like the "alphabetical sort" idea. I don't have strong feelings between order/priority. |
+1 for Order |
Alright let's go with the order |
6f875b8
to
ab8c39f
Compare
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
ab8c39f
to
ae56591
Compare
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.
Cool
So instrumentations with bigger order will override those with smaller order? |
Nothing is overridden. All advice methods will be applied. However the advice method that runs as second has access to the current span from the previous advice method. |
Right, we are not talking about overriding here, we are talking about the order of application. |
So instrumentation with order=1 runs after another one that has order=0, right? Could you include this in the JavaDoc? |
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
@mateuszrzeszutek I have added to it to the Javadoc. |
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.
👍
Signed-off-by: Pavol Loffay p.loffay@gmail.com
Use case: I am adding custom instrumenations that depend on the existing instrumentation from the core (for instance to get the current span). I want to make sure that the existing instrumentation is added to ByteBuddy before my custom instrumentation.