opentelemetry-java-instrumentation icon indicating copy to clipboard operation
opentelemetry-java-instrumentation copied to clipboard

Make the extra field inserted by virtualfield a transient field

Open 123liuziming opened this issue 9 months ago • 5 comments

Is your feature request related to a problem? Please describe.

Yes, sometimes users may serialize some Java bean, which may be instrumented by OpenTelemetry Java Agent. Java Agent may insert an extra field through VirtualField, and it will led to a serialization failure.

Image

Describe the solution you'd like

Make the extra field inserted by virtualfield a transient field and Java will ignore such transient field while doing serialization

Describe alternatives you've considered

No

Additional context

No response

123liuziming avatar Mar 05 '25 11:03 123liuziming

Are you sure this is because virtual fields or just guessing? To me it looks more likely that you somehow end up serializing request attributes map.

laurit avatar Mar 05 '25 12:03 laurit

My bad, it is because the agent put the response into the request attributes map. Actually the virtual field has been marked as transient

Image

123liuziming avatar Mar 05 '25 14:03 123liuziming

Seems that we can only use a custom serializer to avoid the case?

123liuziming avatar Mar 05 '25 14:03 123liuziming

Or can we mark the AsyncListenerResponse as a virtual field of request rather than putting it into request's attribute map since the virtual field is transient

123liuziming avatar Mar 05 '25 14:03 123liuziming

@123liuziming, just in case you were looking into this after our discussion in last week's APAC meeting, wanted to give you a heads up that it looks like @laurit may be exploring options for this in #13493

trask avatar Mar 12 '25 20:03 trask