diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/KeyHolder.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/KeyHolder.java deleted file mode 100644 index e6f28d6eec..0000000000 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/KeyHolder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.api.undertow; - -import java.util.IdentityHashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * Undertow's {@code io.undertow.server.HttpServerExchange} uses {@code - * io.undertow.util.AttachmentKey} as a key for storing arbitrary data. It uses {@link - * IdentityHashMap} and thus all keys are compared for equality by object reference. This means that - * we cannot hold an instance of {@code io.undertow.util.AttachmentKey} in a static field of the - * corresponding Tracer, as we usually do. Tracers are loaded into user's classloaders and thus it - * is totally possible to have several instances of tracers. Each of those instances will have a - * separate value in a static field and {@code io.undertow.server.HttpServerExchange} will treat - * them as different keys then. - * - *

That is why this class exists and resides in a separate package. This package is treated in a - * special way and is always loaded by bootstrap classloader. This makes sure that this class is - * available to all tracers from every classloader. - * - *

But at the same time, being loaded by bootstrap classloader, this class itself cannot initiate - * the loading of {@code io.undertow.util.AttachmentKey} class. Class has to be loaded by any - * classloader that has it, e.g. by the classloader of a Tracer that uses this key holder. After - * that, all Tracers, loaded by all classloaders, will be able to use exactly the same sole - * instance of the key. - */ -// TODO allow instrumentation to have their own classes that should go to bootstrap classloader -public final class KeyHolder { - public static final ConcurrentMap, Object> contextKeys = new ConcurrentHashMap<>(); - - private KeyHolder() {} -} diff --git a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/UndertowActiveHandlers.java b/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/UndertowActiveHandlers.java deleted file mode 100644 index 6e6fc85cfe..0000000000 --- a/javaagent-instrumentation-api/src/main/java/io/opentelemetry/javaagent/instrumentation/api/undertow/UndertowActiveHandlers.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.instrumentation.api.undertow; - -import io.opentelemetry.context.Context; -import io.opentelemetry.context.ContextKey; -import java.util.concurrent.atomic.AtomicInteger; - -/** Helper container for keeping track of request processing state in undertow. */ -public final class UndertowActiveHandlers { - private static final ContextKey CONTEXT_KEY = - ContextKey.named("opentelemetry-undertow-active-handlers"); - - private UndertowActiveHandlers() {} - - /** - * Attach to context. - * - * @param context server context - * @param initialValue initial value for counter - * @return new context - */ - public static Context init(Context context, int initialValue) { - return context.with(CONTEXT_KEY, new AtomicInteger(initialValue)); - } - - /** - * Increment counter. - * - * @param context server context - */ - public static void increment(Context context) { - context.get(CONTEXT_KEY).incrementAndGet(); - } - - /** - * Decrement counter. - * - * @param context server context - * @return value of counter after decrementing it - */ - public static int decrementAndGet(Context context) { - return context.get(CONTEXT_KEY).decrementAndGet(); - } -}