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

Simpler solution for library instrumentation to benefit from InstrumentationContext when used in agent #4081

Closed
trask opened this issue Sep 10, 2021 · 1 comment · Fixed by #4218
Assignees
Labels
enhancement New feature or request

Comments

@trask
Copy link
Member

trask commented Sep 10, 2021

If we had an instrumentation-api something like:

public AssociatingCache {
  public static <Q extends K, K, C> Cache<Q, C> get(Class<K> keyClass, Class<C> contextClass) {
    return Cache.newBuilder().setWeakKeys().build();
  }
}

then the agent could replace the implementation of that method at runtime with

InstrumentationContext.get(keyClass, contextClass).asCache()

and I think that would make it easier to migrate things to library instrumentation while not losing the benefit of InstrumentationContext when used in agent.

(see JdbcData.java for the current solution to using InstrumentationContext from library instrumentation when it is used in agent)

@trask trask added the enhancement New feature or request label Sep 10, 2021
@mateuszrzeszutek
Copy link
Member

We'd probably have to do sth like

if (contextStoreSupplier == null) {
  return Cache.newBuilder().setWeakKeys().build();
}
return contextStoreSupplier.get(keyClass, contextClass);

With the contextStoreSupplier being set by the agent.

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
2 participants