Open youngm opened 2 years ago
I think this is a good idea..now we just have to figure out how to make it work while maintaining binary backward compatibility.
@youngm SendMessageRequest has a Builder class can you use it to inject?
Returning the type probably would be good but indeed will be somewhat tricky to update instrumentation for. In practice I've seen most immutable objects have a builder type so wondering if it's something we can live with still.
@anuraaga SendMessageRequest does have a builder but it builds a new immutable instance, it doesn't modify the original instance. Creating the new Carrier isn't the issue here. I think the main issue here is the API to get that new carrier to the code sending the carrier.
just as a reference, here are two places in the java-instrumentation repo where we hack around immutable carriers:
@anuraaga SendMessageRequest does have a builder but it builds a new immutable instance, it doesn't modify the original instance. Creating the new Carrier isn't the issue here. I think the main issue here is the API to get that new carrier to the code sending the carrier.
I think @anuraaga 's idea was to use the builder as the carrier, rather than the request itself.
@anuraaga yeah, that's a good idea and better than the workaround I've been using in many cases. Thanks.
Is your feature request related to a problem? Please describe. TextMapSetter API doesn't work well with immutable Carriers. For example, SQS
SendMessageRequest
in the AWS Java SDK v2.Describe the solution you'd like Perhaps the
inject()
API andTextMapSetter
could support returning the newly injected carrier?Describe alternatives you've considered Currently, my TextMapSetter for Immutable carriers put the new carrier in some kind of variable that I then aquire and actually send. This is sub-optimal because it makes my TextMapSetter, not thread-safe requiring a new instance for each injection. This isn't too bad but seems to go against the idea of the injection api.