Skip to content
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

Allow transforming classes with missing field types #8393

Merged

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Apr 28, 2023

Hopefully resolves #8276
Previously we had SafeTypeStrategy that allowed transforming classes with missing method argument or return type. For this it filtered out such methods so that transformation wouldn't fail. Seems like DECORATE strategy doesn't perform such checks.

@laurit laurit requested a review from a team as a code owner April 28, 2023 12:00
.with(MethodGraph.Compiler.ForDeclaredMethods.INSTANCE)
.with(VisibilityBridgeStrategy.Default.NEVER)
.with(InstrumentedType.Factory.Default.FROZEN))
.with(AgentBuilder.TypeStrategy.Default.DECORATE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DECORATE javadocs say that:

A decoration does not allow for any standard transformations but can be used as a performance optimization compared to a redefinition, especially when implementing a Java agent that only applies ASM-based code changes.

I'm not sure what "standard transformations" mean in this context; do you know if this has any extra limitations compared to the previous strategy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question, but the tests pass so it seems that it is working for our use case. I think that the advices that we use are only a small and very restrictive part of byte buddy transformations. It is possible that there is a difference when more complicated transforms are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference I noticed was the issue in #8391 where there was a failure instrumenting a static method with an advice that used this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the tests pass

👍

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@trask trask merged commit 43073e7 into open-telemetry:main May 9, 2023
@laurit laurit deleted the allow-transform-with-missing-field-type branch July 6, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cause net.bytebuddy.pool.TypePool$Resolution$NoSuchTypeException unexpectedly
3 participants