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
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.Version;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.tasks.Task;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.elasticsearch.tracing.apm.APMAgentSettings.APM_ENABLED_SETTING;
import static org.elasticsearch.tracing.apm.APMAgentSettings.APM_TRACING_NAMES_EXCLUDE_SETTING;
import static org.elasticsearch.tracing.apm.APMAgentSettings.APM_TRACING_NAMES_INCLUDE_SETTING;
/**
 * This is an implementation of the {@link org.elasticsearch.tracing.Tracer} interface, which uses
 * the OpenTelemetry API to capture spans.
 * <p>
 * This module doesn't provide an implementation of the OTel API. Normally that would mean that the
 * API's default, no-op implementation would be used. However, when the APM Java is attached, it
 * intercepts the {@link GlobalOpenTelemetry} class and provides its own implementation instead.
 */
public class APMTracer extends AbstractLifecycleComponent implements org.elasticsearch.tracing.Tracer {