Skip to content

Commit 7a1582b

Browse files
committed
Adopt OTel 1.62.0
1 parent 1a6c6c8 commit 7a1582b

8 files changed

Lines changed: 101 additions & 5 deletions

File tree

dependencies/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
<!-- Force upgrade okhttp3 for dependency convergence -->
9797
<version.lib.okhttp3>4.12.0</version.lib.okhttp3>
9898
<version.lib.opentelemetry.semconv>1.37.0</version.lib.opentelemetry.semconv>
99-
<version.lib.opentelemetry>1.58.0</version.lib.opentelemetry>
100-
<version.lib.opentelemetry.instrumentation.annotations>2.24.0</version.lib.opentelemetry.instrumentation.annotations>
99+
<version.lib.opentelemetry>1.62.0</version.lib.opentelemetry>
100+
<version.lib.opentelemetry.instrumentation.annotations>2.27.0</version.lib.opentelemetry.instrumentation.annotations>
101101
<version.lib.parsson>1.1.7</version.lib.parsson>
102102
<version.lib.postgresql>42.7.11</version.lib.postgresql>
103103
<version.lib.prometheus>0.16.0</version.lib.prometheus>

telemetry/opentelemetry-config/src/main/java/io/helidon/telemetry/otelconfig/Base2ExponentialHistogramAggregationConfigBlueprint.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@Prototype.Configured
2828
@Prototype.Blueprint(decorator = Base2ExponentialHistogramAggregationSupport.BuilderDecorator.class)
2929
@Prototype.CustomMethods(Base2ExponentialHistogramAggregationSupport.CustomMethods.class)
30+
@Prototype.IncludeDefaultMethods
3031
interface Base2ExponentialHistogramAggregationConfigBlueprint {
3132

3233
/**
@@ -45,4 +46,15 @@ interface Base2ExponentialHistogramAggregationConfigBlueprint {
4546
@Option.Configured
4647
Optional<Integer> maxScale();
4748

49+
/**
50+
* Whether the min and max should be recorded.
51+
*
52+
* @return whether to record min and max
53+
*/
54+
@Option.DefaultBoolean(Base2ExponentialHistogramAggregationSupport.DEFAULT_RECORD_MIN_MAX)
55+
@Option.Configured
56+
default boolean recordMinMax() {
57+
return Base2ExponentialHistogramAggregationSupport.DEFAULT_RECORD_MIN_MAX;
58+
}
59+
4860
}

telemetry/opentelemetry-config/src/main/java/io/helidon/telemetry/otelconfig/Base2ExponentialHistogramAggregationSupport.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
import io.opentelemetry.sdk.metrics.internal.view.Base2ExponentialHistogramAggregation;
2424

2525
class Base2ExponentialHistogramAggregationSupport {
26+
/**
27+
* Helidon-supplied default value for {@code recordMinMax} for backward compatibility.
28+
*/
29+
static final boolean DEFAULT_RECORD_MIN_MAX = true;
30+
31+
private Base2ExponentialHistogramAggregationSupport() {
32+
}
2633

2734
static class BuilderDecorator implements Prototype.BuilderDecorator<Base2ExponentialHistogramAggregationConfig.BuilderBase<?, ?>> {
2835

@@ -53,7 +60,8 @@ private CustomMethods() {
5360
static Aggregation aggregation(Base2ExponentialHistogramAggregationConfig config) {
5461
return config.maxBuckets().isPresent()
5562
? Base2ExponentialHistogramAggregation.create(config.maxBuckets().get(),
56-
config.maxScale().get())
63+
config.maxScale().get(),
64+
config.recordMinMax())
5765
: Base2ExponentialHistogramAggregation.getDefault();
5866
}
5967
}

telemetry/opentelemetry-config/src/main/java/io/helidon/telemetry/otelconfig/ExplicitBucketHistogramAggregationConfigBlueprint.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@Prototype.Blueprint
2828
@Prototype.Configured
2929
@Prototype.CustomMethods(ExplicitBucketHistogramAggregationSupport.CustomMethods.class)
30+
@Prototype.IncludeDefaultMethods
3031
interface ExplicitBucketHistogramAggregationConfigBlueprint {
3132

3233
/**
@@ -36,4 +37,15 @@ interface ExplicitBucketHistogramAggregationConfigBlueprint {
3637
*/
3738
@Option.Configured
3839
List<Double> bucketBoundaries();
40+
41+
/**
42+
* Whether the min and max should be recorded.
43+
*
44+
* @return whether to record min and max
45+
*/
46+
@Option.Configured
47+
@Option.DefaultBoolean(ExplicitBucketHistogramAggregationSupport.DEFAULT_RECORD_MIN_MAX)
48+
default boolean recordMinMax() {
49+
return ExplicitBucketHistogramAggregationSupport.DEFAULT_RECORD_MIN_MAX;
50+
}
3951
}

telemetry/opentelemetry-config/src/main/java/io/helidon/telemetry/otelconfig/ExplicitBucketHistogramAggregationSupport.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323

2424
class ExplicitBucketHistogramAggregationSupport {
2525

26+
private ExplicitBucketHistogramAggregationSupport() {
27+
}
28+
29+
/**
30+
* Helidon-supplied default value for {@code recordMinMax} for backward compatibility.
31+
*/
32+
static final boolean DEFAULT_RECORD_MIN_MAX = true;
33+
2634
static class CustomMethods {
2735

2836
/**
@@ -35,7 +43,8 @@ static class CustomMethods {
3543
static Aggregation aggregation(ExplicitBucketHistogramAggregationConfig config) {
3644
return config.bucketBoundaries().isEmpty()
3745
? ExplicitBucketHistogramAggregation.getDefault()
38-
: ExplicitBucketHistogramAggregation.create(config.bucketBoundaries());
46+
: ExplicitBucketHistogramAggregation.create(config.bucketBoundaries(),
47+
config.recordMinMax());
3948
}
4049
}
4150
}

telemetry/opentelemetry-config/src/test/java/io/helidon/telemetry/otelconfig/TestBasicConfig.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,37 @@ void testTelemetryDefaults() {
116116
assertThat("Global", openTelemetry.global(), is(true));
117117
assertThat("Enabled", openTelemetry.enabled(), is(true));
118118
}
119+
120+
@Test
121+
void testBase2ExponentialHistogramRecordMinMaxDefault() {
122+
var config = Config.just(ConfigSources.create(
123+
"""
124+
aggregation:
125+
max-buckets: 152
126+
max-scale: 19
127+
""",
128+
MediaTypes.APPLICATION_YAML));
129+
130+
var aggregationConfig = Base2ExponentialHistogramAggregationConfig.create(config.get("aggregation"));
131+
132+
assertThat("Record min/max default",
133+
aggregationConfig.recordMinMax(),
134+
is(true));
135+
}
136+
137+
@Test
138+
void testExplicitBucketHistogramRecordMinMaxDefault() {
139+
var config = Config.just(ConfigSources.create(
140+
"""
141+
aggregation:
142+
bucket-boundaries: [3, 5, 7]
143+
""",
144+
MediaTypes.APPLICATION_YAML));
145+
146+
var aggregationConfig = ExplicitBucketHistogramAggregationConfig.create(config.get("aggregation"));
147+
148+
assertThat("Record min/max default",
149+
aggregationConfig.recordMinMax(),
150+
is(true));
151+
}
119152
}

webserver/observe/telemetry/metrics/src/test/java/io/helidon/webserver/observe/telemetry/metrics/TestLogHandler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import io.helidon.common.testing.junit5.MatcherWithRetry;
2727

28+
import org.hamcrest.Matcher;
29+
2830
import static org.hamcrest.Matchers.hasSize;
2931

3032
/**
@@ -65,4 +67,12 @@ List<String> messages(int expectedCount) {
6567
messages.clear();
6668
return result;
6769
}
70+
71+
List<String> messages(Matcher<Iterable<? super String>> matcher) {
72+
var result = MatcherWithRetry.assertThatWithRetry("Logged messages",
73+
() -> List.copyOf(messages),
74+
matcher);
75+
messages.clear();
76+
return result;
77+
}
6878
}

webserver/observe/telemetry/metrics/src/test/java/io/helidon/webserver/observe/telemetry/metrics/TestOpenTelemetrySemanticConventions.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import static io.helidon.webserver.observe.telemetry.metrics.OpenTelemetryMetricsHttpSemanticConventions.SOCKET_NAME;
5151
import static org.hamcrest.MatcherAssert.assertThat;
5252
import static org.hamcrest.Matchers.allOf;
53+
import static org.hamcrest.Matchers.containsString;
5354
import static org.hamcrest.Matchers.greaterThan;
5455
import static org.hamcrest.Matchers.hasEntry;
5556
import static org.hamcrest.Matchers.hasItem;
@@ -162,7 +163,8 @@ void checkAutoMetrics() {
162163
and the timer's count is 1.
163164
*/
164165

165-
List<String> jsonText = testLogHandler.messages(2);
166+
List<String> jsonText = testLogHandler.messages(
167+
hasItem(containsString(OpenTelemetryMetricsHttpSemanticConventions.TIMER_NAME)));
166168

167169
var root = JsonParser.create(jsonText.getFirst()).readJsonObject();
168170

@@ -197,6 +199,16 @@ void checkAutoMetrics() {
197199

198200
for (JsonObject metricsEntry : metricsEntries) {
199201

202+
/*
203+
OTel can insert some of its own messages, which we can ignore for this test. Skip any for which the
204+
metric name is not the name of our timer.
205+
*/
206+
var metricEntryName = metricsEntry.stringValue("name");
207+
if (metricEntryName.isEmpty()
208+
|| !metricEntryName.get().equals(OpenTelemetryMetricsHttpSemanticConventions.TIMER_NAME)) {
209+
continue;
210+
}
211+
200212
var dataPoints = metricsEntry.objectValue("histogram").orElseThrow()
201213
.arrayValue("dataPoints").orElseThrow()
202214
.values()

0 commit comments

Comments
 (0)