Skip to content

Commit 71bc65d

Browse files
jack-bergtrask
andauthored
Update to 1.15.0 (#358)
* Update to 1.15.0 * Fix * Upgrade to opentelemetry-instrumentation 1.15.0 * Fix jmx-metrics integration test * Fix InstrumenterHelperTest Co-authored-by: Trask Stalnaker <[email protected]>
1 parent a26d441 commit 71bc65d

File tree

7 files changed

+45
-27
lines changed

7 files changed

+45
-27
lines changed

dependencyManagement/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ val DEPENDENCY_BOMS = listOf(
1818
"org.junit:junit-bom:5.8.2",
1919
"com.linecorp.armeria:armeria-bom:1.9.1",
2020
"io.grpc:grpc-bom:1.42.1",
21-
"io.opentelemetry:opentelemetry-bom:1.14.0",
22-
"io.opentelemetry:opentelemetry-bom-alpha:1.14.0-alpha",
23-
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0-alpha",
21+
"io.opentelemetry:opentelemetry-bom:1.15.0",
22+
"io.opentelemetry:opentelemetry-bom-alpha:1.15.0-alpha",
23+
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.15.0-alpha",
2424
"org.testcontainers:testcontainers-bom:1.16.3"
2525
)
2626

jmx-metrics/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies {
4040
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
4141
implementation("io.opentelemetry:opentelemetry-sdk-testing")
4242
implementation("io.opentelemetry:opentelemetry-exporter-logging")
43-
implementation("io.opentelemetry:opentelemetry-exporter-otlp-metrics")
43+
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
4444
implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
4545
implementation("org.slf4j:slf4j-api")
4646
implementation("org.slf4j:slf4j-simple")

jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
import org.junit.jupiter.api.BeforeAll;
3737
import org.junit.jupiter.api.BeforeEach;
3838
import org.junit.jupiter.api.TestInstance;
39+
import org.slf4j.Logger;
40+
import org.slf4j.LoggerFactory;
3941
import org.testcontainers.containers.GenericContainer;
4042
import org.testcontainers.containers.Network;
43+
import org.testcontainers.containers.output.Slf4jLogConsumer;
4144
import org.testcontainers.containers.wait.strategy.Wait;
4245
import org.testcontainers.junit.jupiter.Testcontainers;
4346
import org.testcontainers.utility.MountableFile;
@@ -46,6 +49,8 @@
4649
@Testcontainers(disabledWithoutDocker = true)
4750
public abstract class AbstractIntegrationTest {
4851

52+
private static final Logger logger = LoggerFactory.getLogger(AbstractIntegrationTest.class);
53+
4954
private final boolean configFromStdin;
5055
private final String configName;
5156

@@ -110,6 +115,7 @@ protected GenericContainer<?> buildScraper(String otlpEndpoint) {
110115
.withCopyFileToContainer(
111116
MountableFile.forClasspathResource(configName), "/app/" + configName)
112117
.withCommand(scraperCommand.toArray(new String[0]))
118+
.withLogConsumer(new Slf4jLogConsumer(logger))
113119
.withStartupTimeout(Duration.ofMinutes(2))
114120
.waitingFor(Wait.forLogMessage(".*Started GroovyRunner.*", 1));
115121
}

jmx-metrics/src/integrationTest/resources/activemq/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rmohr/activemq:5.15.9-alpine
1+
FROM rmohr/activemq:5.15.9
22

33

44
COPY --chown=activemq config/env /opt/activemq/bin/env

jmx-metrics/src/main/groovy/io/opentelemetry/contrib/jmxmetrics/InstrumentHelper.groovy

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class InstrumentHelper {
118118
def description = tuple.getAt(2)
119119
def unit = tuple.getAt(3)
120120

121-
if (instrumentIsObserver(instrument)) {
121+
if (instrumentIsDoubleObserver(instrument) || instrumentIsLongObserver(instrument)) {
122122
// Though the instrument updater is only set at build time,
123123
// our GroovyMetricEnvironment helpers ensure the updater
124124
// uses the Closure specified here.
@@ -149,9 +149,13 @@ class InstrumentHelper {
149149

150150
private static Closure prepareUpdateClosure(inst, value, labels) {
151151
def labelMap = GroovyMetricEnvironment.mapToAttributes(labels)
152-
if (instrumentIsObserver(inst)) {
152+
if (instrumentIsLongObserver(inst)) {
153153
return { result ->
154-
result.record(value, labelMap)
154+
result.record((long) value, labelMap)
155+
}
156+
} else if (instrumentIsDoubleObserver(inst)) {
157+
return { result ->
158+
result.record((double) value, labelMap)
155159
}
156160
} else if (instrumentIsCounter(inst)) {
157161
return { i -> i.add(value, labelMap) }
@@ -160,14 +164,19 @@ class InstrumentHelper {
160164
}
161165
}
162166

163-
@PackageScope static boolean instrumentIsObserver(inst) {
167+
@PackageScope static boolean instrumentIsDoubleObserver(inst) {
164168
return [
165169
"doubleCounterCallback",
166170
"doubleUpDownCounterCallback",
171+
"doubleValueCallback",
172+
].contains(inst.method)
173+
}
174+
175+
@PackageScope static boolean instrumentIsLongObserver(inst) {
176+
return [
167177
"longCounterCallback",
168178
"longUpDownCounterCallback",
169-
"doubleValueCallback" ,
170-
"longValueCallback"
179+
"longValueCallback",
171180
].contains(inst.method)
172181
}
173182

jmx-metrics/src/test/java/io/opentelemetry/contrib/jmxmetrics/InstrumenterHelperTest.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -612,22 +612,27 @@ void handlesNulls(boolean isSingle) throws Exception {
612612

613613
@ParameterizedTest
614614
@CsvSource({
615-
"doubleCounter,false,true",
616-
"longCounter,false,true",
617-
"doubleCounterCallback,true,false",
618-
"longCounterCallback,true,false",
619-
"doubleUpDownCounter,false,true",
620-
"longUpDownCounter,false,true",
621-
"doubleUpDownCounterCallback,true,false",
622-
"longUpDownCounterCallback,true,false",
623-
"doubleValueCallback,true,false",
624-
"longValueCallback,true,false",
625-
"doubleHistogram,false,false",
626-
"longHistogram,false,false",
615+
"doubleCounter,false,false,true",
616+
"longCounter,false,false,true",
617+
"doubleCounterCallback,true,false,false",
618+
"longCounterCallback,false,true,false",
619+
"doubleUpDownCounter,false,false,true",
620+
"longUpDownCounter,false,false,true",
621+
"doubleUpDownCounterCallback,true,false,false",
622+
"longUpDownCounterCallback,false,true,false",
623+
"doubleValueCallback,true,false,false",
624+
"longValueCallback,false,true,false",
625+
"doubleHistogram,false,false,false",
626+
"longHistogram,false,false,false",
627627
})
628-
void correctlyClassified(String instrumentMethod, boolean isObserver, boolean isCounter) {
628+
void correctlyClassified(
629+
String instrumentMethod,
630+
boolean isDoubleObserver,
631+
boolean isLongObserver,
632+
boolean isCounter) {
629633
Closure<?> instrument = (Closure<?>) Eval.me("otel", otel, "otel.&" + instrumentMethod);
630-
assertThat(InstrumentHelper.instrumentIsObserver(instrument)).isEqualTo(isObserver);
634+
assertThat(InstrumentHelper.instrumentIsDoubleObserver(instrument)).isEqualTo(isDoubleObserver);
635+
assertThat(InstrumentHelper.instrumentIsLongObserver(instrument)).isEqualTo(isLongObserver);
631636
assertThat(InstrumentHelper.instrumentIsCounter(instrument)).isEqualTo(isCounter);
632637
}
633638

maven-extension/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ dependencies {
2121
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
2222
implementation("io.opentelemetry:opentelemetry-semconv")
2323
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
24-
implementation("io.opentelemetry:opentelemetry-exporter-otlp-metrics")
25-
implementation("io.opentelemetry:opentelemetry-exporter-otlp-trace")
2624

2725
implementation("io.grpc:grpc-netty-shaded")
2826

0 commit comments

Comments
 (0)