content: /*
   * Copyright The OpenTelemetry Authors
   * SPDX-License-Identifier: Apache-2.0
   */
  
  package instrumentation;
  
  import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
  import static java.util.Collections.singletonList;
  import static net.bytebuddy.matcher.ElementMatchers.named;
  
  import com.google.auto.service.AutoService;
  import io.opentelemetry.javaagent.extension.instrumentation.HelperResourceBuilder;
  import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
  import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
  import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
  import java.util.List;
  import net.bytebuddy.description.type.TypeDescription;
  import net.bytebuddy.matcher.ElementMatcher;
  
  @AutoService(InstrumentationModule.class)
  public class TestInstrumentationModule extends InstrumentationModule {
    public TestInstrumentationModule() {
      super("test-instrumentation");
    }
  
    @Override
    public List<TypeInstrumentation> typeInstrumentations() {
      return singletonList(new TestTypeInstrumentation());
    }
  
    @Override
    public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
      helperResourceBuilder.register("test-resources/test-resource.txt");
      helperResourceBuilder.register(
          "test-resources/test-resource.txt", "test-resources/test-resource-2.txt");
    }
  
    @Override
    public boolean isIndyModule() {
      return false;
    }
  
    public static class TestTypeInstrumentation implements TypeInstrumentation {
      @Override
      public ElementMatcher<ClassLoader> classLoaderOptimization() {
        return hasClassesNamed("org.apache.commons.lang3.SystemUtils");
      }
  
      @Override
      public ElementMatcher<TypeDescription> typeMatcher() {
        return named("org.apache.commons.lang3.SystemUtils");
      }
  
      @Override
      public void transform(TypeTransformer transformer) {
        // Nothing to transform, this type instrumentation is only used for injecting resources.
      }
    }
  }
  