Skip to content

Commit 593ffb0

Browse files
committed
Merge branch 'main' into fbc-create-resource-from-model
2 parents f451e45 + 29a7fe8 commit 593ffb0

File tree

178 files changed

+2242
-568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+2242
-568
lines changed

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,62 @@
22

33
## Unreleased
44

5+
## Version 1.52.0 (2025-07-11)
6+
7+
### API
8+
9+
#### Common
10+
11+
* Promote `ComponentLoader` to new `opentelemetry-common` artifact,
12+
standardize SPI loading
13+
([#7446](https://github.com/open-telemetry/opentelemetry-java/pull/7446))
14+
15+
#### Context
16+
17+
* LazyStorage passes its ClassLoader when loading ContextStorageProvider SPI
18+
([#7424](https://github.com/open-telemetry/opentelemetry-java/pull/7424))
19+
20+
#### Incubator
21+
22+
* Add context and severity params to ExtendedLogger#isEnabled
23+
([#7268](https://github.com/open-telemetry/opentelemetry-java/pull/7268))
24+
* Add new convenience methods for converting DeclarativeConfigProperties to config model
25+
([#7453](https://github.com/open-telemetry/opentelemetry-java/pull/7453))
26+
27+
### SDK
28+
29+
* Add custom stacktrace renderer which is length limit aware
30+
([#7281](https://github.com/open-telemetry/opentelemetry-java/pull/7281))
31+
32+
#### Metrics
33+
34+
* Propagate flush to PeriodicMetricReader's metricExporter.
35+
([#7410](https://github.com/open-telemetry/opentelemetry-java/pull/7410))
36+
37+
#### Exporters
38+
39+
* OTLP - JdkHttpSender: ensure proper closure of HttpClient in shutdown method
40+
([#7390](https://github.com/open-telemetry/opentelemetry-java/pull/7390))
41+
* OTLP: profile exporters fix and test improvements
42+
([#7442](https://github.com/open-telemetry/opentelemetry-java/pull/7442))
43+
* OTLP: Loading Compressor SPI via ComponentLoader configured through setComponentLoader
44+
([#7428](https://github.com/open-telemetry/opentelemetry-java/pull/7428))
45+
* Prometheus: add scope schema URL and attributes
46+
([#7356](https://github.com/open-telemetry/opentelemetry-java/pull/7356))
47+
* Prometheus: extend prometheus declarative config support to include without_scope_info,
48+
with_resource_constant_labels
49+
([#6840](https://github.com/open-telemetry/opentelemetry-java/pull/6840))
50+
51+
#### Extensions
52+
53+
* Autoconfigure: fix race condition of `GlobalOpenTelemetry` initialization with
54+
`AutoConfiguredOpenTelemetrySdkBuilder`
55+
([#7365](https://github.com/open-telemetry/opentelemetry-java/pull/7365))
56+
* Declarative config: update to declarative config 1.0-rc.1
57+
([#7436](https://github.com/open-telemetry/opentelemetry-java/pull/7436))
58+
* Declarative config: resolve environment variable substitution for mixed quotes
59+
([#7433](https://github.com/open-telemetry/opentelemetry-java/pull/7433))
60+
561
## Version 1.51.0 (2025-06-06)
662

763
### API

README.md

Lines changed: 32 additions & 31 deletions
Large diffs are not rendered by default.

all/src/test/java/io/opentelemetry/all/SdkDesignTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SdkDesignTest {
2828
* Ensures that all SDK methods that: - are defined in classes that extend or implement API model
2929
* and are public (to exclude protected builders) - are public (avoids issues with protected
3030
* methods returning classes unavailable to test's CL) - override or implement parent method
31-
* return only API, Context or generic Java type.
31+
* return only API, Context, Common, or generic Java type.
3232
*/
3333
@Test
3434
void sdkImplementationOfApiClassesShouldReturnApiTypeOnly() {
@@ -45,7 +45,11 @@ void sdkImplementationOfApiClassesShouldReturnApiTypeOnly() {
4545
.and(implementOrOverride())
4646
.should()
4747
.haveRawReturnType(
48-
inPackage("io.opentelemetry.api..", "io.opentelemetry.context..", "java.."))
48+
inPackage(
49+
"io.opentelemetry.api..",
50+
"io.opentelemetry.context..",
51+
"io.opentelemetry.common..",
52+
"java.."))
4953
.orShould()
5054
.haveRawReturnType("void");
5155

api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ public static void set(OpenTelemetry openTelemetry) {
122122
*
123123
* <p>This method calls the given {@code supplier} and calls {@link #set(OpenTelemetry)}, all
124124
* while holding the {@link GlobalOpenTelemetry} mutex.
125+
*
126+
* @since 1.52.0
125127
*/
126128
public static void set(Supplier<OpenTelemetry> supplier) {
127129
synchronized (mutex) {

api/incubator/build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ otelJava.moduleName.set("io.opentelemetry.api.incubator")
1212
dependencies {
1313
api(project(":api:all"))
1414

15+
// Supports optional InstrumentationConfigUtil#convertToModel
16+
compileOnly("com.fasterxml.jackson.core:jackson-databind")
17+
1518
annotationProcessor("com.google.auto.value:auto-value")
1619

1720
// To use parsed config file as input for InstrumentationConfigUtilTest
@@ -24,3 +27,16 @@ dependencies {
2427

2528
testImplementation("com.google.guava:guava")
2629
}
30+
31+
testing {
32+
suites {
33+
register<JvmTestSuite>("testConvertToModel") {
34+
dependencies {
35+
implementation("com.fasterxml.jackson.core:jackson-databind")
36+
implementation(project(":sdk-extensions:incubator"))
37+
implementation(project(":sdk-extensions:autoconfigure"))
38+
implementation("com.google.guava:guava")
39+
}
40+
}
41+
}
42+
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/config/DeclarativeConfigProperties.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
import static io.opentelemetry.api.internal.ConfigUtil.defaultIfNull;
99

10+
import io.opentelemetry.common.ComponentLoader;
1011
import java.util.List;
12+
import java.util.Map;
1113
import java.util.Set;
1214
import javax.annotation.Nullable;
1315

@@ -36,6 +38,11 @@ static DeclarativeConfigProperties empty() {
3638
return EmptyDeclarativeConfigProperties.getInstance();
3739
}
3840

41+
/** Return a map representation of the {@code declarativeConfigProperties}. */
42+
static Map<String, Object> toMap(DeclarativeConfigProperties declarativeConfigProperties) {
43+
return DeclarativeConfigPropertyUtil.toMap(declarativeConfigProperties);
44+
}
45+
3946
/**
4047
* Returns a {@link String} configuration property.
4148
*
@@ -222,4 +229,7 @@ default List<DeclarativeConfigProperties> getStructuredList(
222229
* @return the configuration property keys
223230
*/
224231
Set<String> getPropertyKeys();
232+
233+
/** Return a {@link ComponentLoader} that should be used to load SPIs. */
234+
ComponentLoader getComponentLoader();
225235
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.api.incubator.config;
7+
8+
import static java.util.stream.Collectors.toList;
9+
10+
import java.util.Arrays;
11+
import java.util.HashMap;
12+
import java.util.List;
13+
import java.util.Map;
14+
import java.util.Optional;
15+
import java.util.Set;
16+
import java.util.function.BiFunction;
17+
import javax.annotation.Nullable;
18+
19+
final class DeclarativeConfigPropertyUtil {
20+
21+
private DeclarativeConfigPropertyUtil() {}
22+
23+
private static final List<BiFunction<String, DeclarativeConfigProperties, Object>>
24+
valueResolvers =
25+
Arrays.asList(
26+
DeclarativeConfigPropertyUtil::getString,
27+
DeclarativeConfigPropertyUtil::getBoolean,
28+
DeclarativeConfigPropertyUtil::getLong,
29+
DeclarativeConfigPropertyUtil::getDouble,
30+
DeclarativeConfigPropertyUtil::getStringList,
31+
DeclarativeConfigPropertyUtil::getBooleanList,
32+
DeclarativeConfigPropertyUtil::getLongList,
33+
DeclarativeConfigPropertyUtil::getDoubleList,
34+
DeclarativeConfigPropertyUtil::getStringList,
35+
DeclarativeConfigPropertyUtil::getStructuredList,
36+
DeclarativeConfigPropertyUtil::getStructured);
37+
38+
static Map<String, Object> toMap(DeclarativeConfigProperties declarativeConfigProperties) {
39+
Set<String> propertyKeys = declarativeConfigProperties.getPropertyKeys();
40+
Map<String, Object> result = new HashMap<>(propertyKeys.size());
41+
for (String key : declarativeConfigProperties.getPropertyKeys()) {
42+
result.put(key, resolveValue(key, declarativeConfigProperties));
43+
}
44+
return result;
45+
}
46+
47+
@Nullable
48+
private static Object resolveValue(
49+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
50+
for (int i = 0; i < valueResolvers.size(); i++) {
51+
try {
52+
Object value = valueResolvers.get(i).apply(key, declarativeConfigProperties);
53+
if (value != null) {
54+
return value;
55+
}
56+
} catch (DeclarativeConfigException e) {
57+
// Ignore and continue
58+
}
59+
}
60+
return null;
61+
}
62+
63+
@Nullable
64+
private static Object getString(
65+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
66+
return declarativeConfigProperties.getString(key);
67+
}
68+
69+
@Nullable
70+
private static Object getBoolean(
71+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
72+
return declarativeConfigProperties.getBoolean(key);
73+
}
74+
75+
@Nullable
76+
private static Object getLong(
77+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
78+
return declarativeConfigProperties.getLong(key);
79+
}
80+
81+
@Nullable
82+
private static Object getDouble(
83+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
84+
return declarativeConfigProperties.getDouble(key);
85+
}
86+
87+
@Nullable
88+
private static Object getStringList(
89+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
90+
return declarativeConfigProperties.getScalarList(key, String.class);
91+
}
92+
93+
@Nullable
94+
private static Object getBooleanList(
95+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
96+
return declarativeConfigProperties.getScalarList(key, Boolean.class);
97+
}
98+
99+
@Nullable
100+
private static Object getLongList(
101+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
102+
return declarativeConfigProperties.getScalarList(key, Long.class);
103+
}
104+
105+
@Nullable
106+
private static Object getDoubleList(
107+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
108+
return declarativeConfigProperties.getScalarList(key, Double.class);
109+
}
110+
111+
@Nullable
112+
private static Object getStructuredList(
113+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
114+
return Optional.ofNullable(declarativeConfigProperties.getStructuredList(key))
115+
.map(list -> list.stream().map(DeclarativeConfigPropertyUtil::toMap).collect(toList()))
116+
.orElse(null);
117+
}
118+
119+
@Nullable
120+
private static Object getStructured(
121+
String key, DeclarativeConfigProperties declarativeConfigProperties) {
122+
return Optional.ofNullable(declarativeConfigProperties.getStructured(key))
123+
.map(DeclarativeConfigPropertyUtil::toMap)
124+
.orElse(null);
125+
}
126+
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/config/EmptyDeclarativeConfigProperties.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.api.incubator.config;
77

8+
import io.opentelemetry.common.ComponentLoader;
89
import java.util.Collections;
910
import java.util.List;
1011
import java.util.Set;
@@ -15,6 +16,8 @@ final class EmptyDeclarativeConfigProperties implements DeclarativeConfigPropert
1516

1617
private static final EmptyDeclarativeConfigProperties INSTANCE =
1718
new EmptyDeclarativeConfigProperties();
19+
private static final ComponentLoader COMPONENT_LOADER =
20+
ComponentLoader.forClassLoader(EmptyDeclarativeConfigProperties.class.getClassLoader());
1821

1922
private EmptyDeclarativeConfigProperties() {}
2023

@@ -74,4 +77,9 @@ public List<DeclarativeConfigProperties> getStructuredList(String name) {
7477
public Set<String> getPropertyKeys() {
7578
return Collections.emptySet();
7679
}
80+
81+
@Override
82+
public ComponentLoader getComponentLoader() {
83+
return COMPONENT_LOADER;
84+
}
7785
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/config/InstrumentationConfigUtil.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.api.incubator.config;
77

8+
import com.fasterxml.jackson.databind.ObjectMapper;
89
import java.util.LinkedHashMap;
910
import java.util.List;
1011
import java.util.Map;
@@ -148,4 +149,49 @@ public static <T> T getOrNull(
148149
}
149150

150151
private InstrumentationConfigUtil() {}
152+
153+
/**
154+
* Return {@code .instrumentation.java.<instrumentationName>}, after converting it to the {@code
155+
* modelType} using the {@code objectMapper}. If no configuration exists for the {@code
156+
* instrumentationName}, returns {@code null}.
157+
*
158+
* <p>This method is a convenience method for a common instrumentation library workflow:
159+
*
160+
* <ul>
161+
* <li>During initialization, an instrumentation library is given an {@link ConfigProvider} and
162+
* must initialize according to the relevant config
163+
* <li>It checks if the user has provided configuration for it, and if so...
164+
* <li>It converts the configuration to an in-memory model representing all of its relevant
165+
* properties
166+
* <li>It initializes using the strongly typed in-memory model
167+
* </ul>
168+
*
169+
* <p>Conversion is done using {@link ObjectMapper#convertValue(Object, Class)} from {@code
170+
* com.fasterxml.jackson.databind}, and assumes the {@code modelType} is a POJO written /
171+
* annotated to support jackson databinding.
172+
*
173+
* <p>NOTE: callers MUST add their own dependency on {@code
174+
* com.fasterxml.jackson.core:jackson-databind}. This module's dependency is {@code compileOnly}
175+
* since jackson is a large dependency that many users will not require. It's very possible to
176+
* convert between {@link DeclarativeConfigProperties} (or a map representation from {@link
177+
* DeclarativeConfigProperties#toMap(DeclarativeConfigProperties)}) and a target model type
178+
* without jackson. This method is provided as an optional convenience method.
179+
*
180+
* @throws IllegalArgumentException if conversion fails. See {@link
181+
* ObjectMapper#convertValue(Object, Class)} for details.
182+
*/
183+
@Nullable
184+
public static <T> T getInstrumentationConfigModel(
185+
ConfigProvider configProvider,
186+
String instrumentationName,
187+
ObjectMapper objectMapper,
188+
Class<T> modelType) {
189+
DeclarativeConfigProperties properties =
190+
javaInstrumentationConfig(configProvider, instrumentationName);
191+
if (properties == null) {
192+
return null;
193+
}
194+
Map<String, Object> configPropertiesMap = DeclarativeConfigProperties.toMap(properties);
195+
return objectMapper.convertValue(configPropertiesMap, modelType);
196+
}
151197
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/logs/ExtendedDefaultLogger.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ static Logger getNoop() {
2727
return INSTANCE;
2828
}
2929

30+
@Override
31+
public boolean isEnabled(Severity severity, Context context) {
32+
return false;
33+
}
34+
3035
@Override
3136
public ExtendedLogRecordBuilder logRecordBuilder() {
3237
return NOOP_LOG_RECORD_BUILDER;

0 commit comments

Comments
 (0)