-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
635 additions
and
158 deletions.
There are no files selected for viewing
21 changes: 15 additions & 6 deletions
21
docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
Comparing source compatibility of against | ||
+++* NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.ScopeConfig (not serializable) | ||
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.ScopeConfigurator (not serializable) | ||
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
GENERIC TEMPLATES: +++ T:java.lang.Object | ||
+++ NEW INTERFACE: java.util.function.Function | ||
+++ NEW SUPERCLASS: java.lang.Object | ||
+++* NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Function<io.opentelemetry.sdk.common.InstrumentationScopeInfo,T> applyToMatching(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, java.lang.Object) | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> builder() | ||
GENERIC TEMPLATES: +++ T:java.lang.Object | ||
+++* NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Function<io.opentelemetry.sdk.common.InstrumentationScopeInfo,T> applyToMatching(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, java.lang.Object, java.lang.Object) | ||
GENERIC TEMPLATES: +++ T:java.lang.Object | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> scopeNameEquals(java.lang.String) | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> scopeNameMatches(java.lang.String) | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> toBuilder() | ||
+++ NEW ANNOTATION: java.lang.FunctionalInterface | ||
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder (not serializable) | ||
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
GENERIC TEMPLATES: +++ T:java.lang.Object | ||
+++ NEW SUPERCLASS: java.lang.Object | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> addCondition(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, java.lang.Object) | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfigurator<T> build() | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> nameEquals(java.lang.String) | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo> nameMatchesGlob(java.lang.String) | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<T> setDefault(java.lang.Object) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
Comparing source compatibility of against | ||
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.SdkTracerProviderBuilder (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder addScopeConfig(io.opentelemetry.sdk.common.ScopeSelector, io.opentelemetry.sdk.trace.TracerConfig) | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder addTracerConfiguratorMatcher(java.util.function.Predicate<io.opentelemetry.sdk.common.InstrumentationScopeInfo>, io.opentelemetry.sdk.trace.TracerConfig) | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder setTracerConfigurator(io.opentelemetry.sdk.common.ScopeConfigurator<io.opentelemetry.sdk.trace.TracerConfig>) | ||
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.trace.TracerConfig (not serializable) | ||
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
+++ NEW SUPERCLASS: java.lang.Object | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.ScopeConfiguratorBuilder<io.opentelemetry.sdk.trace.TracerConfig> configuratorBuilder() | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig defaultConfig() | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig disabled() | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.TracerConfig enabled() | ||
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) boolean isEnabled() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
sdk/common/src/main/java/io/opentelemetry/sdk/common/ScopeConfig.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
sdk/common/src/main/java/io/opentelemetry/sdk/common/ScopeConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.common; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* A {@link ScopeConfigurator} computes configuration for a given {@link InstrumentationScopeInfo}. | ||
*/ | ||
@FunctionalInterface | ||
public interface ScopeConfigurator<T> extends Function<InstrumentationScopeInfo, T> { | ||
|
||
/** Create a new builder. */ | ||
static <T> ScopeConfiguratorBuilder<T> builder() { | ||
return new ScopeConfiguratorBuilder<>(unused -> null); | ||
} | ||
|
||
/** | ||
* Convert this {@link ScopeConfigurator} to a builder. Additional added matchers only apply when | ||
* {@link #apply(Object)} returns {@code null}. If this configurator contains {@link | ||
* ScopeConfiguratorBuilder#setDefault(Object)}, additional matchers are never applied. | ||
*/ | ||
default ScopeConfiguratorBuilder<T> toBuilder() { | ||
return new ScopeConfiguratorBuilder<>(this); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
sdk/common/src/main/java/io/opentelemetry/sdk/common/ScopeConfiguratorBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.common; | ||
|
||
import io.opentelemetry.sdk.internal.GlobUtil; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Predicate; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Builder for {@link ScopeConfigurator}. | ||
* | ||
* @param <T> The scope configuration object, e.g. {@code TracerConfig}, {@code LoggerConfig}, | ||
* {@code MeterConfig}. | ||
*/ | ||
public final class ScopeConfiguratorBuilder<T> { | ||
|
||
private final ScopeConfigurator<T> baseScopeConfigurator; | ||
@Nullable private T defaultScopeConfig; | ||
private final List<Condition<T>> conditions = new ArrayList<>(); | ||
|
||
ScopeConfiguratorBuilder(ScopeConfigurator<T> baseScopeConfigurator) { | ||
this.baseScopeConfigurator = baseScopeConfigurator; | ||
} | ||
|
||
/** | ||
* Set the default scope config, which is returned by {@link ScopeConfigurator#apply(Object)} if a | ||
* {@link InstrumentationScopeInfo} does not match any {@link #addCondition(Predicate, Object) | ||
* conditions}. If a default is not set, an SDK defined default is used. | ||
*/ | ||
public ScopeConfiguratorBuilder<T> setDefault(T defaultScopeConfig) { | ||
this.defaultScopeConfig = defaultScopeConfig; | ||
return this; | ||
} | ||
|
||
/** | ||
* Add a condition. Conditions are evaluated in order. The {@code scopeConfig} for the first match | ||
* is returned by {@link ScopeConfigurator#apply(Object)}. | ||
* | ||
* @param scopePredicate predicate that {@link InstrumentationScopeInfo}s are evaluated against | ||
* @param scopeConfig the scope config to use when this condition is the first matching {@code | ||
* scopePredicate} | ||
* @see #nameMatchesGlob(String) | ||
* @see #nameEquals(String) | ||
*/ | ||
public ScopeConfiguratorBuilder<T> addCondition( | ||
Predicate<InstrumentationScopeInfo> scopePredicate, T scopeConfig) { | ||
conditions.add(new Condition<>(scopePredicate, scopeConfig)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Helper function for pattern matching {@link InstrumentationScopeInfo#getName()} against the | ||
* {@code globPattern}. | ||
* | ||
* <p>{@code globPattern} may contain the wildcard characters {@code *} and {@code ?} with the | ||
* following matching criteria: | ||
* | ||
* <ul> | ||
* <li>{@code *} matches 0 or more instances of any character | ||
* <li>{@code ?} matches exactly one instance of any character | ||
* </ul> | ||
* | ||
* @see #addCondition(Predicate, Object) | ||
*/ | ||
public static Predicate<InstrumentationScopeInfo> nameMatchesGlob(String globPattern) { | ||
Predicate<String> globPredicate = GlobUtil.toGlobPatternPredicate(globPattern); | ||
return scopeInfo -> globPredicate.test(scopeInfo.getName()); | ||
} | ||
|
||
/** | ||
* Helper function for exact matching {@link InstrumentationScopeInfo#getName()} against the | ||
* {@code scopeName}. | ||
* | ||
* @see #addCondition(Predicate, Object) | ||
*/ | ||
public static Predicate<InstrumentationScopeInfo> nameEquals(String scopeName) { | ||
return scopeInfo -> scopeInfo.getName().equals(scopeName); | ||
} | ||
|
||
/** Build a {@link ScopeConfigurator} with the configuration of this builder. */ | ||
public ScopeConfigurator<T> build() { | ||
// TODO: return an instance with toString implementation which self describes rules | ||
return scopeInfo -> { | ||
T scopeConfig = baseScopeConfigurator.apply(scopeInfo); | ||
if (scopeConfig != null) { | ||
return scopeConfig; | ||
} | ||
for (Condition<T> condition : conditions) { | ||
if (condition.scopeMatcher.test(scopeInfo)) { | ||
return condition.scopeConfig; | ||
} | ||
} | ||
return defaultScopeConfig; | ||
}; | ||
} | ||
|
||
private static final class Condition<T> { | ||
private final Predicate<InstrumentationScopeInfo> scopeMatcher; | ||
private final T scopeConfig; | ||
|
||
private Condition(Predicate<InstrumentationScopeInfo> scopeMatcher, T scopeConfig) { | ||
this.scopeMatcher = scopeMatcher; | ||
this.scopeConfig = scopeConfig; | ||
} | ||
} | ||
} |
Oops, something went wrong.