/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ package io.opentelemetry.javaagent.instrumentation.api; /** Instrumentation Context API. */ public class InstrumentationContext { private InstrumentationContext() {} /** * Find a {@link ContextStore} instance for given key class and context class. * *

Conceptually this can be thought of as a map lookup to fetch a second level map given * keyClass. * *

In reality, the calls to this method are re-written to something more performant * while injecting advice into a method. * *

This method must only be called within an Advice class. * * @param keyClass The key class context is attached to. * @param contextClass The context class attached to the user class. * @param key class * @param context class * @return The instance of context store for given arguments. */ public static ContextStore get( Class keyClass, Class contextClass) { throw new IllegalStateException( "Calls to this method will be rewritten by Instrumentation Context Provider (e.g. FieldBackedProvider)"); } }