Version 1.17.0 of the OpenTelemetry Java SDK was released a few days ago, and this release includes a fix for the performance bug identified in https://github.com/elastic/elasticsearch/issues/89107. We should upgrade to the latest version and revert the workaround introduced in https://github.com/elastic/elasticsearch/pull/89135.
modules/apm/src/main/java/org/elasticsearch/tracing/apm/APMTracer.java
}
        spans.computeIfAbsent(spanId, _spanId -> AccessController.doPrivileged((PrivilegedAction<Context>) () -> {
            logger.trace("Tracing [{}] [{}]", spanId, spanName);
            final SpanBuilder spanBuilder = services.tracer.spanBuilder(spanName);
            
            
            final Context parentContext = getParentContext(threadContext);
            if (parentContext != null) {
                spanBuilder.setParent(parentContext);
            }
            setSpanAttributes(threadContext, attributes, spanBuilder);
            final Span span = spanBuilder.startSpan();
            final Context contextForNewSpan = Context.current().with(span);
            updateThreadContext(threadContext, services, contextForNewSpan);
            return contextForNewSpan;
        }));
    }
    private static void updateThreadContext(ThreadContext threadContext, APMServices services, Context context) {
        
        threadContext.putTransient(Task.APM_TRACE_CONTEXT, context);
        
        
        services.openTelemetry.getPropagators().getTextMapPropagator().inject(context, threadContext, (tc, key, value) -> {
            if (isSupportedContextKey(key)) {
                tc.putHeader(key, value);
            }
        });
    }
    private Context getParentContext(ThreadContext threadContext) {