Skip to content

Commit d509dd4

Browse files
authored
[dynamic control] Add PolicyTypeInitializer interface for better readability (#2754)
1 parent 744e845 commit d509dd4

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.contrib.dynamic.policy;
7+
8+
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
9+
import javax.annotation.Nonnull;
10+
11+
/**
12+
* NOTE PolicyInit not yet added - remove this note when it is added
13+
*
14+
* <p>Initializes one policy type and returns the implementer that applies that type at runtime.
15+
*
16+
* <p>This is used by {@code
17+
* io.opentelemetry.contrib.dynamic.policy.registry.PolicyInit.registerPolicyType(...)} and is
18+
* typically provided as a method reference, for example:
19+
*
20+
* <pre>{@code
21+
* io.opentelemetry.contrib.dynamic.policy.registry.PolicyInit.registerPolicyType(
22+
* TraceSamplingRatePolicy.POLICY_TYPE,
23+
* TraceSamplingRatePolicy.class,
24+
* TraceSamplingRatePolicy::initialize);
25+
* }</pre>
26+
*/
27+
@FunctionalInterface
28+
public interface PolicyTypeInitializer {
29+
/**
30+
* Initializes policy runtime wiring for one policy type.
31+
*
32+
* @param autoConfiguration OpenTelemetry auto-configuration customizer
33+
* @return non-null implementer for the policy type
34+
*/
35+
@Nonnull
36+
PolicyImplementer initialize(AutoConfigurationCustomizer autoConfiguration);
37+
}

0 commit comments

Comments
 (0)