Skip to content

Commit

Permalink
[improve] Upgrade OpenTelemetry library to 1.44.1 version (#23656)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9ed44dd)
  • Loading branch information
lhotari committed Nov 29, 2024
1 parent 4c99912 commit 5d44eba
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 32 deletions.
41 changes: 20 additions & 21 deletions distribution/server/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,11 @@ The Apache Software License, Version 2.0
- io.prometheus-simpleclient_tracer_otel-0.16.0.jar
- io.prometheus-simpleclient_tracer_otel_agent-0.16.0.jar
* Prometheus exporter
- io.prometheus-prometheus-metrics-config-1.2.1.jar
- io.prometheus-prometheus-metrics-exporter-common-1.2.1.jar
- io.prometheus-prometheus-metrics-exporter-httpserver-1.2.1.jar
- io.prometheus-prometheus-metrics-exposition-formats-1.2.1.jar
- io.prometheus-prometheus-metrics-model-1.2.1.jar
- io.prometheus-prometheus-metrics-shaded-protobuf-1.2.1.jar
- io.prometheus-prometheus-metrics-config-1.3.3.jar
- io.prometheus-prometheus-metrics-exporter-common-1.3.3.jar
- io.prometheus-prometheus-metrics-exporter-httpserver-1.3.3.jar
- io.prometheus-prometheus-metrics-exposition-formats-1.3.3.jar
- io.prometheus-prometheus-metrics-model-1.3.3.jar
* Jakarta Bean Validation API
- jakarta.validation-jakarta.validation-api-2.0.2.jar
- javax.validation-validation-api-1.1.0.Final.jar
Expand Down Expand Up @@ -515,21 +514,21 @@ The Apache Software License, Version 2.0
* RoaringBitmap
- org.roaringbitmap-RoaringBitmap-1.2.0.jar
* OpenTelemetry
- io.opentelemetry-opentelemetry-api-1.38.0.jar
- io.opentelemetry-opentelemetry-api-incubator-1.38.0-alpha.jar
- io.opentelemetry-opentelemetry-context-1.38.0.jar
- io.opentelemetry-opentelemetry-exporter-common-1.38.0.jar
- io.opentelemetry-opentelemetry-exporter-otlp-1.38.0.jar
- io.opentelemetry-opentelemetry-exporter-otlp-common-1.38.0.jar
- io.opentelemetry-opentelemetry-exporter-prometheus-1.38.0-alpha.jar
- io.opentelemetry-opentelemetry-exporter-sender-okhttp-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-common-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-extension-autoconfigure-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-extension-autoconfigure-spi-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-logs-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-metrics-1.38.0.jar
- io.opentelemetry-opentelemetry-sdk-trace-1.38.0.jar
- io.opentelemetry-opentelemetry-api-1.44.1.jar
- io.opentelemetry-opentelemetry-api-incubator-1.44.1-alpha.jar
- io.opentelemetry-opentelemetry-context-1.44.1.jar
- io.opentelemetry-opentelemetry-exporter-common-1.44.1.jar
- io.opentelemetry-opentelemetry-exporter-otlp-1.44.1.jar
- io.opentelemetry-opentelemetry-exporter-otlp-common-1.44.1.jar
- io.opentelemetry-opentelemetry-exporter-prometheus-1.44.1-alpha.jar
- io.opentelemetry-opentelemetry-exporter-sender-okhttp-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-common-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-extension-autoconfigure-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-extension-autoconfigure-spi-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-logs-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-metrics-1.44.1.jar
- io.opentelemetry-opentelemetry-sdk-trace-1.44.1.jar
- io.opentelemetry.instrumentation-opentelemetry-instrumentation-api-1.33.3.jar
- io.opentelemetry.instrumentation-opentelemetry-instrumentation-api-semconv-1.33.3-alpha.jar
- io.opentelemetry.instrumentation-opentelemetry-resources-1.33.3-alpha.jar
Expand Down
6 changes: 3 additions & 3 deletions distribution/shell/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ The Apache Software License, Version 2.0
- log4j-slf4j2-impl-2.23.1.jar
- log4j-web-2.23.1.jar
* OpenTelemetry
- opentelemetry-api-1.38.0.jar
- opentelemetry-api-incubator-1.38.0-alpha.jar
- opentelemetry-context-1.38.0.jar
- opentelemetry-api-1.44.1.jar
- opentelemetry-api-incubator-1.44.1-alpha.jar
- opentelemetry-context-1.44.1.jar

* BookKeeper
- bookkeeper-common-allocator-4.17.1.jar
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ flexible messaging model and an intuitive client API.</description>
<disruptor.version>3.4.3</disruptor.version>
<zstd-jni.version>1.5.2-3</zstd-jni.version>
<netty-reactive-streams.version>2.0.6</netty-reactive-streams.version>
<opentelemetry.version>1.38.0</opentelemetry.version>
<opentelemetry.version>1.44.1</opentelemetry.version>
<opentelemetry.alpha.version>${opentelemetry.version}-alpha</opentelemetry.alpha.version>
<opentelemetry.instrumentation.version>1.33.3</opentelemetry.instrumentation.version>
<opentelemetry.instrumentation.alpha.version>${opentelemetry.instrumentation.version}-alpha</opentelemetry.instrumentation.alpha.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.pulsar.broker.stats;

import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.opentelemetry.sdk.metrics.data.MetricData;
Expand Down Expand Up @@ -52,13 +53,14 @@ public static void disableExporters(AutoConfiguredOpenTelemetrySdkBuilder sdkBui

public static void assertMetricDoubleSumValue(Collection<MetricData> metrics, String metricName,
Attributes attributes, Consumer<Double> valueConsumer) {
Map<AttributeKey<?>, Object> attributesMap = attributes.asMap();
assertThat(metrics)
.anySatisfy(metric -> assertThat(metric)
.hasName(metricName)
.hasDoubleSumSatisfying(sum -> sum.satisfies(
sumData -> assertThat(sumData.getPoints()).anySatisfy(
point -> {
assertThat(point.getAttributes()).isEqualTo(attributes);
assertThat(point.getAttributes().asMap()).isEqualTo(attributesMap);
valueConsumer.accept(point.getValue());
}))));
}
Expand All @@ -70,13 +72,14 @@ public static void assertMetricLongSumValue(Collection<MetricData> metrics, Stri

public static void assertMetricLongSumValue(Collection<MetricData> metrics, String metricName,
Attributes attributes, Consumer<Long> valueConsumer) {
Map<AttributeKey<?>, Object> attributesMap = attributes.asMap();
assertThat(metrics)
.anySatisfy(metric -> assertThat(metric)
.hasName(metricName)
.hasLongSumSatisfying(sum -> sum.satisfies(
sumData -> assertThat(sumData.getPoints()).anySatisfy(
point -> {
assertThat(point.getAttributes()).isEqualTo(attributes);
assertThat(point.getAttributes().asMap()).isEqualTo(attributesMap);
valueConsumer.accept(point.getValue());
}))));
}
Expand All @@ -88,13 +91,14 @@ public static void assertMetricLongGaugeValue(Collection<MetricData> metrics, St

public static void assertMetricLongGaugeValue(Collection<MetricData> metrics, String metricName,
Attributes attributes, Consumer<Long> valueConsumer) {
Map<AttributeKey<?>, Object> attributesMap = attributes.asMap();
assertThat(metrics)
.anySatisfy(metric -> assertThat(metric)
.hasName(metricName)
.hasLongGaugeSatisfying(gauge -> gauge.satisfies(
pointData -> assertThat(pointData.getPoints()).anySatisfy(
point -> {
assertThat(point.getAttributes()).isEqualTo(attributes);
assertThat(point.getAttributes().asMap()).isEqualTo(attributesMap);
valueConsumer.accept(point.getValue());
}))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
Expand All @@ -48,7 +48,7 @@
public class ClientMetricsTest extends ProducerConsumerBase {

InMemoryMetricReader reader;
OpenTelemetry otel;
OpenTelemetrySdk otel;

@BeforeMethod
@Override
Expand All @@ -67,6 +67,14 @@ protected void setup() throws Exception {
@Override
protected void cleanup() throws Exception {
super.internalCleanup();
if (otel != null) {
otel.close();
otel = null;
}
if (reader != null) {
reader.close();
reader = null;
}
}

private Map<String, MetricData> collectMetrics() {
Expand All @@ -88,8 +96,9 @@ private long getCounterValue(Map<String, MetricData> metrics, String name,
assertNotNull(md, "metric not found: " + name);
assertEquals(md.getType(), MetricDataType.LONG_SUM);

Map<AttributeKey<?>, Object> expectedAttributesMap = expectedAttributes.asMap();
for (var ex : md.getLongSumData().getPoints()) {
if (ex.getAttributes().equals(expectedAttributes)) {
if (ex.getAttributes().asMap().equals(expectedAttributesMap)) {
return ex.getValue();
}
}
Expand All @@ -109,8 +118,9 @@ private long getHistoCountValue(Map<String, MetricData> metrics, String name,
assertNotNull(md, "metric not found: " + name);
assertEquals(md.getType(), MetricDataType.HISTOGRAM);

Map<AttributeKey<?>, Object> expectedAttributesMap = expectedAttributes.asMap();
for (var ex : md.getHistogramData().getPoints()) {
if (ex.getAttributes().equals(expectedAttributes)) {
if (ex.getAttributes().asMap().equals(expectedAttributesMap)) {
return ex.getCount();
}
}
Expand Down

0 comments on commit 5d44eba

Please sign in to comment.