File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed
main/java/io/opentelemetry/contrib/dynamic
test/java/io/opentelemetry/contrib/dynamic Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,22 @@ java {
1111 sourceCompatibility = JavaVersion .VERSION_1_8
1212 targetCompatibility = JavaVersion .VERSION_1_8
1313}
14+
15+ dependencies {
16+ annotationProcessor(" com.google.auto.service:auto-service" )
17+ compileOnly(" com.google.auto.service:auto-service-annotations" )
18+
19+ compileOnly(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
20+ compileOnly(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi" )
21+
22+ testCompileOnly(" com.google.auto.service:auto-service-annotations" )
23+ testRuntimeOnly(" org.junit.jupiter:junit-jupiter-engine" )
24+ testImplementation(" org.junit.jupiter:junit-jupiter-api" )
25+ testCompileOnly(" org.junit.jupiter:junit-jupiter-params" )
26+
27+ testImplementation(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure" )
28+ testImplementation(" io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi" )
29+ testImplementation(" org.assertj:assertj-core" )
30+ testImplementation(" org.mockito:mockito-inline" )
31+ testImplementation(" org.mockito:mockito-junit-jupiter" )
32+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright The OpenTelemetry Authors
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package io .opentelemetry .contrib .dynamic ;
7+
8+ import com .google .auto .service .AutoService ;
9+ import io .opentelemetry .sdk .autoconfigure .spi .AutoConfigurationCustomizer ;
10+ import io .opentelemetry .sdk .autoconfigure .spi .AutoConfigurationCustomizerProvider ;
11+ import java .util .logging .Level ;
12+ import java .util .logging .Logger ;
13+
14+ /**
15+ * AutoConfigurationCustomizerProvider for dynamic control extension.
16+ *
17+ * <p>This extension provides a skeleton for dynamic control of agent features. Currently, it only
18+ * logs when loaded by the agent.
19+ */
20+ @ AutoService (AutoConfigurationCustomizerProvider .class )
21+ public class DynamicControlAutoConfiguration implements AutoConfigurationCustomizerProvider {
22+
23+ private static final Logger logger =
24+ Logger .getLogger (DynamicControlAutoConfiguration .class .getName ());
25+
26+ @ Override
27+ public void customize (AutoConfigurationCustomizer autoConfiguration ) {
28+ logger .log (Level .INFO , "Dynamic control extension has been loaded by the agent" );
29+ }
30+
31+ @ Override
32+ public int order () {
33+ return 0 ;
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright The OpenTelemetry Authors
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package io .opentelemetry .contrib .dynamic ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+ import static org .mockito .Mockito .mock ;
10+
11+ import io .opentelemetry .sdk .autoconfigure .spi .AutoConfigurationCustomizer ;
12+ import org .junit .jupiter .api .Test ;
13+
14+ class DynamicControlAutoConfigurationTest {
15+
16+ @ Test
17+ void testCustomize () {
18+ DynamicControlAutoConfiguration config = new DynamicControlAutoConfiguration ();
19+ AutoConfigurationCustomizer customizer = mock (AutoConfigurationCustomizer .class );
20+
21+ config .customize (customizer );
22+
23+ // The customize method should not throw and should be callable
24+ // Logging is tested manually or via integration tests
25+ }
26+
27+ @ Test
28+ void testOrder () {
29+ // This is a placeholder test, just to have something
30+ DynamicControlAutoConfiguration config = new DynamicControlAutoConfiguration ();
31+ // Default order should be 0
32+ assertThat (config .order ()).isEqualTo (0 );
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments