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

Share Instrumentation's module contextStore across instrumentations modules #1949

Closed
pavolloffay opened this issue Dec 20, 2020 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@pavolloffay
Copy link
Member

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

I would like to store an object to the context store in a module A and access an object from the context store from instrumentation module B.

For instance my apache HC client instrumentation module hooks into HttpEntity.WriteTo() and puts OutputStream into a context as a key. Now I would like to access the context store in OutputStreamInstrumentation and check if the OutputStream is in the context - if it is instrumentation for write methods puts input into buffer (value from the context).

Describe the solution you'd like

Define context store in instrumentation module A and access it in instrumentation module B

Describe alternatives you've considered

Use a global instance of weak map to share objects/state across instrumentations from different modules.

@pavolloffay pavolloffay added the enhancement New feature or request label Dec 20, 2020
@anuraaga
Copy link
Contributor

anuraaga commented Dec 21, 2020

FWIU (which could be wrong :) ), contextStore is basically just a mechanism to add fields to classes, or if that can't happen due to redefinition problems, falls back to a global weak map. I wouldn't see any reason for a context store with the same definition in two modules to not work, unless we explicitly fail to set a second contextStore if there's a duplicate definition, I guess we would be able to remove such a check if it exists.

@pavolloffay
Copy link
Member Author

I have tried to use the same context store in two inst modules it failed for some reason. I didn't dig deeper though.

@pavolloffay
Copy link
Member Author

Closing this seems to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants