Skip to content

Commit 53e8a36

Browse files
author
Anuraag Agrawal
authored
Update to OTel 1.6 (#80)
* Update to OTel 1.6 * Sort
1 parent 71ae48e commit 53e8a36

File tree

7 files changed

+99
-132
lines changed

7 files changed

+99
-132
lines changed

aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
package io.opentelemetry.contrib.awsxray;
66

77
import com.google.auto.service.AutoService;
8-
import io.opentelemetry.sdk.autoconfigure.ConfigProperties;
98
import io.opentelemetry.sdk.autoconfigure.OpenTelemetryResourceAutoConfiguration;
10-
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider;
9+
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
10+
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider;
1111
import io.opentelemetry.sdk.trace.samplers.Sampler;
1212
import java.util.Map;
1313

@@ -20,7 +20,7 @@ public Sampler createSampler(ConfigProperties config) {
2020
AwsXrayRemoteSampler.newBuilder(
2121
OpenTelemetryResourceAutoConfiguration.configureResource(config));
2222

23-
Map<String, String> params = config.getCommaSeparatedMap("otel.traces.sampler.arg");
23+
Map<String, String> params = config.getMap("otel.traces.sampler.arg");
2424

2525
String endpoint = params.get("endpoint");
2626
if (endpoint != null) {

aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import static org.assertj.core.api.InstanceOfAssertFactories.type;
99
import static org.mockito.Mockito.when;
1010

11-
import io.opentelemetry.sdk.autoconfigure.ConfigProperties;
12-
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider;
11+
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
12+
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider;
1313
import java.util.Collections;
1414
import java.util.ServiceLoader;
1515
import org.junit.jupiter.api.Test;
@@ -49,9 +49,8 @@ void emptyConfig() {
4949

5050
@Test
5151
void setEndpoint() {
52-
when(config.getCommaSeparatedMap("otel.resource.attributes"))
53-
.thenReturn(Collections.emptyMap());
54-
when(config.getCommaSeparatedMap("otel.traces.sampler.arg"))
52+
when(config.getMap("otel.resource.attributes")).thenReturn(Collections.emptyMap());
53+
when(config.getMap("otel.traces.sampler.arg"))
5554
.thenReturn(Collections.singletonMap("endpoint", "http://localhost:3000"));
5655
try (AwsXrayRemoteSampler sampler =
5756
(AwsXrayRemoteSampler) new AwsXrayRemoteSamplerProvider().createSampler(config)) {

dependencyManagement/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ val DEPENDENCY_BOMS = listOf(
1717
"org.junit:junit-bom:5.7.2",
1818
"com.linecorp.armeria:armeria-bom:1.9.1",
1919
"io.grpc:grpc-bom:1.39.0",
20-
"io.opentelemetry:opentelemetry-bom:1.5.0",
21-
"io.opentelemetry:opentelemetry-bom-alpha:1.5.0-alpha",
20+
"io.opentelemetry:opentelemetry-bom:1.6.0",
21+
"io.opentelemetry:opentelemetry-bom-alpha:1.6.0-alpha",
2222
"org.testcontainers:testcontainers-bom:1.16.0"
2323
)
2424

jmx-metrics/src/test/groovy/io/opentelemetry/contrib/jmxmetrics/InstrumentHelperTest.groovy

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ package io.opentelemetry.contrib.jmxmetrics
77
import static io.opentelemetry.api.common.AttributeKey.stringKey
88
import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_GAUGE
99
import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_SUM
10+
import static io.opentelemetry.sdk.metrics.data.MetricDataType.HISTOGRAM
1011
import static io.opentelemetry.sdk.metrics.data.MetricDataType.LONG_GAUGE
1112
import static io.opentelemetry.sdk.metrics.data.MetricDataType.LONG_SUM
12-
import static io.opentelemetry.sdk.metrics.data.MetricDataType.SUMMARY
1313
import static java.lang.management.ManagementFactory.getPlatformMBeanServer
1414

1515
import io.opentelemetry.api.common.Attributes
@@ -93,8 +93,8 @@ class InstrumentHelperTest extends Specification {
9393
def s1 = p1.startEpochNanos
9494
def s2 = p2.startEpochNanos
9595
if (s1 == s2) {
96-
if (md1.type == SUMMARY) {
97-
return p1.percentileValues[0].value <=> p2.percentileValues[0].value
96+
if (md1.type == HISTOGRAM) {
97+
return p1.counts[0] <=> p2.counts[0]
9898
}
9999
return p1.value <=> p2.value
100100
}
@@ -140,13 +140,10 @@ class InstrumentHelperTest extends Specification {
140140
metric.data.points.eachWithIndex { point, i ->
141141
assert point.attributes == Attributes.of(stringKey("labelOne"), "labelOneValue", stringKey("labelTwo"), "${i}".toString())
142142

143-
if (metricType == SUMMARY) {
143+
if (metricType == HISTOGRAM) {
144144
assert point.count == 1
145145
assert point.sum == value
146-
assert point.percentileValues[0].percentile == 0
147-
assert point.percentileValues[0].value == value
148-
assert point.percentileValues[1].percentile == 100
149-
assert point.percentileValues[1].value == value
146+
assert point.counts[6].value == 1
150147
} else {
151148
assert point.value == value
152149
}
@@ -163,10 +160,10 @@ class InstrumentHelperTest extends Specification {
163160
false | "multiple" | "Long" | "longCounter" | LONG_SUM | 234
164161
true | "single" | "Long" | "longUpDownCounter" | LONG_SUM | 234
165162
false | "multiple" | "Long" | "longUpDownCounter" | LONG_SUM | 234
166-
true | "single" | "Double" | "doubleHistogram" | SUMMARY | 123.456
167-
false | "multiple" | "Double" | "doubleHistogram" | SUMMARY | 123.456
168-
true | "single" | "Long" | "longHistogram" | SUMMARY | 234
169-
false | "multiple" | "Long" | "longHistogram" | SUMMARY | 234
163+
true | "single" | "Double" | "doubleHistogram" | HISTOGRAM | 123.456
164+
false | "multiple" | "Double" | "doubleHistogram" | HISTOGRAM | 123.456
165+
true | "single" | "Long" | "longHistogram" | HISTOGRAM | 234
166+
false | "multiple" | "Long" | "longHistogram" | HISTOGRAM | 234
170167
true | "single" | "Double" | "doubleCounterCallback" | DOUBLE_SUM | 123.456
171168
false | "multiple" | "Double" | "doubleCounterCallback" | DOUBLE_SUM | 123.456
172169
true | "single" | "Double" | "doubleUpDownCounterCallback" | DOUBLE_SUM | 123.456

jmx-metrics/src/test/groovy/io/opentelemetry/contrib/jmxmetrics/OtelHelperSynchronousMetricTest.groovy

Lines changed: 71 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package io.opentelemetry.contrib.jmxmetrics
77
import static io.opentelemetry.api.common.AttributeKey.stringKey
88
import static io.opentelemetry.sdk.metrics.data.MetricDataType.DOUBLE_SUM
99
import static io.opentelemetry.sdk.metrics.data.MetricDataType.LONG_SUM
10-
import static io.opentelemetry.sdk.metrics.data.MetricDataType.SUMMARY
10+
import static io.opentelemetry.sdk.metrics.data.MetricDataType.HISTOGRAM
1111

1212
import io.opentelemetry.api.common.Attributes
1313
import io.opentelemetry.api.metrics.GlobalMeterProvider
@@ -46,8 +46,8 @@ class OtelHelperSynchronousMetricTest extends Specification{
4646
def s1 = p1.startEpochNanos
4747
def s2 = p2.startEpochNanos
4848
if (s1 == s2) {
49-
if (md1.type == SUMMARY) {
50-
return p1.percentileValues[0].value <=> p2.percentileValues[0].value
49+
if (md1.type == HISTOGRAM) {
50+
return p1.counts[0] <=> p2.counts[0]
5151
}
5252
return p1.value <=> p2.value
5353
}
@@ -404,57 +404,45 @@ class OtelHelperSynchronousMetricTest extends Specification{
404404
def third = metrics[2]
405405
def fourth = metrics[3]
406406

407-
assert first.name == 'double-value-recorder'
408-
assert first.description == 'a double value-recorder'
409-
assert first.unit == 'ms'
410-
assert first.type == SUMMARY
407+
assert first.name == 'yet-another-double-value-recorder'
408+
assert first.description == ''
409+
assert first.unit == '1'
410+
assert first.type == HISTOGRAM
411411
assert first.data.points.size() == 1
412412
assert first.data.points[0].count == 1
413-
assert first.data.points[0].sum == -234.567
414-
assert first.data.points[0].percentileValues[0].percentile == 0
415-
assert first.data.points[0].percentileValues[0].value == -234.567
416-
assert first.data.points[0].percentileValues[1].percentile == 100
417-
assert first.data.points[0].percentileValues[1].value == -234.567
418-
assert first.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
419-
420-
assert second.name == 'my-double-value-recorder'
421-
assert second.description == 'another double value-recorder'
422-
assert second.unit == 'µs'
423-
assert second.type == SUMMARY
413+
assert first.data.points[0].sum == 456.789
414+
assert first.data.points[0].counts[7] == 1
415+
assert first.data.points[0].attributes == Attributes.of(stringKey('yetAnotherKey'), 'yetAnotherValue')
416+
417+
assert second.name == 'another-double-value-recorder'
418+
assert second.description == 'double value-recorder'
419+
assert second.unit == '1'
420+
assert second.type == HISTOGRAM
424421
assert second.data.points.size() == 1
425422
assert second.data.points[0].count == 1
426-
assert second.data.points[0].sum == -123.456
427-
assert second.data.points[0].percentileValues[0].percentile == 0
428-
assert second.data.points[0].percentileValues[0].value == -123.456
429-
assert second.data.points[0].percentileValues[1].percentile == 100
430-
assert second.data.points[0].percentileValues[1].value == -123.456
431-
assert second.data.points[0].attributes == Attributes.of(stringKey('myKey'), 'myValue')
432-
433-
assert third.name == 'another-double-value-recorder'
434-
assert third.description == 'double value-recorder'
435-
assert third.unit == '1'
436-
assert third.type == SUMMARY
423+
assert second.data.points[0].sum == 345.678
424+
assert second.data.points[0].counts[7] == 1
425+
assert second.data.points[0].attributes == Attributes.of(stringKey('anotherKey'), 'anotherValue')
426+
427+
assert third.name == 'double-value-recorder'
428+
assert third.description == 'a double value-recorder'
429+
assert third.unit == 'ms'
430+
assert third.type == HISTOGRAM
437431
assert third.data.points.size() == 1
438432
assert third.data.points[0].count == 1
439-
assert third.data.points[0].sum == 345.678
440-
assert third.data.points[0].percentileValues[0].percentile == 0
441-
assert third.data.points[0].percentileValues[0].value == 345.678
442-
assert third.data.points[0].percentileValues[1].percentile == 100
443-
assert third.data.points[0].percentileValues[1].value == 345.678
444-
assert third.data.points[0].attributes == Attributes.of(stringKey('anotherKey'), 'anotherValue')
445-
446-
assert fourth.name == 'yet-another-double-value-recorder'
447-
assert fourth.description == ''
448-
assert fourth.unit == '1'
449-
assert fourth.type == SUMMARY
433+
assert third.data.points[0].sum == -234.567
434+
assert third.data.points[0].counts[0] == 1
435+
assert third.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
436+
437+
assert fourth.name == 'my-double-value-recorder'
438+
assert fourth.description == 'another double value-recorder'
439+
assert fourth.unit == 'µs'
440+
assert fourth.type == HISTOGRAM
450441
assert fourth.data.points.size() == 1
451442
assert fourth.data.points[0].count == 1
452-
assert fourth.data.points[0].sum == 456.789
453-
assert fourth.data.points[0].percentileValues[0].percentile == 0
454-
assert fourth.data.points[0].percentileValues[0].value == 456.789
455-
assert fourth.data.points[0].percentileValues[1].percentile == 100
456-
assert fourth.data.points[0].percentileValues[1].value == 456.789
457-
assert fourth.data.points[0].attributes == Attributes.of(stringKey('yetAnotherKey'), 'yetAnotherValue')
443+
assert fourth.data.points[0].sum == -123.456
444+
assert fourth.data.points[0].counts[0] == 1
445+
assert fourth.data.points[0].attributes == Attributes.of(stringKey('myKey'), 'myValue')
458446
}
459447

460448
def "double value recorder memoization"() {
@@ -474,14 +462,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
474462
assert metric.name == 'dvr'
475463
assert metric.description == 'double value'
476464
assert metric.unit == '1'
477-
assert metric.type == SUMMARY
465+
assert metric.type == HISTOGRAM
478466
assert metric.data.points.size() == 1
479467
assert metric.data.points[0].count == 2
480468
assert metric.data.points[0].sum == 0
481-
assert metric.data.points[0].percentileValues[0].percentile == 0
482-
assert metric.data.points[0].percentileValues[0].value == -10.1
483-
assert metric.data.points[0].percentileValues[1].percentile == 100
484-
assert metric.data.points[0].percentileValues[1].value == 10.1
469+
assert metric.data.points[0].counts[0] == 1
470+
assert metric.data.points[0].counts[1] == 0
485471
assert metric.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
486472
}
487473

@@ -510,57 +496,45 @@ class OtelHelperSynchronousMetricTest extends Specification{
510496
def third = metrics[2]
511497
def fourth = metrics[3]
512498

513-
assert first.name == 'long-value-recorder'
514-
assert first.description == 'a long value-recorder'
515-
assert first.unit == 'ms'
516-
assert first.type == SUMMARY
499+
assert first.name == 'yet-another-long-value-recorder'
500+
assert first.description == ''
501+
assert first.unit == '1'
502+
assert first.type == HISTOGRAM
517503
assert first.data.points.size() == 1
518504
assert first.data.points[0].count == 1
519-
assert first.data.points[0].sum == -234
520-
assert first.data.points[0].percentileValues[0].percentile == 0
521-
assert first.data.points[0].percentileValues[0].value == -234
522-
assert first.data.points[0].percentileValues[1].percentile == 100
523-
assert first.data.points[0].percentileValues[1].value == -234
524-
assert first.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
525-
526-
assert second.name == 'my-long-value-recorder'
527-
assert second.description == 'another long value-recorder'
528-
assert second.unit == 'µs'
529-
assert second.type == SUMMARY
505+
assert first.data.points[0].sum == 456
506+
assert first.data.points[0].counts[7] == 1
507+
assert first.data.points[0].attributes == Attributes.of(stringKey('yetAnotherKey'), 'yetAnotherValue')
508+
509+
assert second.name == 'another-long-value-recorder'
510+
assert second.description == 'long value-recorder'
511+
assert second.unit == '1'
512+
assert second.type == HISTOGRAM
530513
assert second.data.points.size() == 1
531514
assert second.data.points[0].count == 1
532-
assert second.data.points[0].sum == -123
533-
assert second.data.points[0].percentileValues[0].percentile == 0
534-
assert second.data.points[0].percentileValues[0].value == -123
535-
assert second.data.points[0].percentileValues[1].percentile == 100
536-
assert second.data.points[0].percentileValues[1].value == -123
537-
assert second.data.points[0].attributes == Attributes.of(stringKey('myKey'), 'myValue')
538-
539-
assert third.name == 'another-long-value-recorder'
540-
assert third.description == 'long value-recorder'
541-
assert third.unit == '1'
542-
assert third.type == SUMMARY
515+
assert second.data.points[0].sum == 345
516+
assert second.data.points[0].counts[7] == 1
517+
assert second.data.points[0].attributes == Attributes.of(stringKey('anotherKey'), 'anotherValue')
518+
519+
assert third.name == 'long-value-recorder'
520+
assert third.description == 'a long value-recorder'
521+
assert third.unit == 'ms'
522+
assert third.type == HISTOGRAM
543523
assert third.data.points.size() == 1
544524
assert third.data.points[0].count == 1
545-
assert third.data.points[0].sum == 345
546-
assert third.data.points[0].percentileValues[0].percentile == 0
547-
assert third.data.points[0].percentileValues[0].value == 345
548-
assert third.data.points[0].percentileValues[1].percentile == 100
549-
assert third.data.points[0].percentileValues[1].value == 345
550-
assert third.data.points[0].attributes == Attributes.of(stringKey('anotherKey'), 'anotherValue')
551-
552-
assert fourth.name == 'yet-another-long-value-recorder'
553-
assert fourth.description == ''
554-
assert fourth.unit == '1'
555-
assert fourth.type == SUMMARY
525+
assert third.data.points[0].sum == -234
526+
assert third.data.points[0].counts[0] == 1
527+
assert third.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
528+
529+
assert fourth.name == 'my-long-value-recorder'
530+
assert fourth.description == 'another long value-recorder'
531+
assert fourth.unit == 'µs'
532+
assert fourth.type == HISTOGRAM
556533
assert fourth.data.points.size() == 1
557534
assert fourth.data.points[0].count == 1
558-
assert fourth.data.points[0].sum == 456
559-
assert fourth.data.points[0].percentileValues[0].percentile == 0
560-
assert fourth.data.points[0].percentileValues[0].value == 456
561-
assert fourth.data.points[0].percentileValues[1].percentile == 100
562-
assert fourth.data.points[0].percentileValues[1].value == 456
563-
assert fourth.data.points[0].attributes == Attributes.of(stringKey('yetAnotherKey'), 'yetAnotherValue')
535+
assert fourth.data.points[0].sum == -123
536+
assert fourth.data.points[0].counts[0] == 1
537+
assert fourth.data.points[0].attributes == Attributes.of(stringKey('myKey'), 'myValue')
564538
}
565539

566540
def "long value recorder memoization"() {
@@ -580,14 +554,12 @@ class OtelHelperSynchronousMetricTest extends Specification{
580554
assert metric.name == 'lvr'
581555
assert metric.description == 'long value'
582556
assert metric.unit == '1'
583-
assert metric.type == SUMMARY
557+
assert metric.type == HISTOGRAM
584558
assert metric.data.points.size() == 1
585559
assert metric.data.points[0].count == 2
586560
assert metric.data.points[0].sum == 0
587-
assert metric.data.points[0].percentileValues[0].percentile == 0
588-
assert metric.data.points[0].percentileValues[0].value == -10
589-
assert metric.data.points[0].percentileValues[1].percentile == 100
590-
assert metric.data.points[0].percentileValues[1].value == 10
561+
assert metric.data.points[0].counts[0] == 1
562+
assert metric.data.points[0].counts[1] == 1
591563
assert metric.data.points[0].attributes == Attributes.of(stringKey('key'), 'value')
592564
}
593565

0 commit comments

Comments
 (0)