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
if (span != null) {
            logger.trace("Finishing trace [{}]", spanId);
            span.end();
        }
    }
    @Override
    public void addEvent(String spanId, String eventName) {
        final var span = spanFromContextOrNullWithoutLogging(spans.get(spanId));
        if (span != null) {
            span.addEvent(eventName);
        }
    }
    private static Span spanFromContextOrNullWithoutLogging(Context context) {
        
        
        return context == null ? null : Span.fromContextOrNull(context);
    }
    private static class MapKeyGetter implements TextMapGetter<Map<String, String>> {
        @Override
        public Iterable<String> keys(Map<String, String> carrier) {
            return carrier.keySet().stream().filter(APMTracer::isSupportedContextKey).collect(Collectors.toSet());
        }
        @Override
        public String get(Map<String, String> carrier, String key) {
            return carrier.get(key);
        }
    }
    private static boolean isSupportedContextKey(String key) {
        return Task.TRACE_PARENT_HTTP_HEADER.equals(key) || Task.TRACE_STATE.equals(key);
    }