Skip to content

Commit 8a735ef

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-contrib into jmx-scraper-jetty
2 parents 03b6536 + cdde090 commit 8a735ef

File tree

25 files changed

+644
-834
lines changed

25 files changed

+644
-834
lines changed

CHANGELOG.md

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

33
## Unreleased
44

5+
## Version 1.40.0 (2024-10-18)
6+
7+
### AWS X-Ray SDK support
8+
9+
- Ensure all XRay Sampler functionality is under ParentBased logic
10+
([#1488](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/1488))
11+
12+
### GCP Resources
13+
14+
- Add gcr job support
15+
([#1462](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/1462))
16+
17+
### Inferred spans
18+
19+
- Rename param and description to proper value
20+
([#1486](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/1486))
21+
22+
### JFR connection
23+
24+
- Fix wrong parameter sent to JFR DiagnosticCommand
25+
([#1492](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/1492))
26+
27+
### Span stack traces
28+
29+
- Support autoconfigure
30+
([#1499](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/1499))
31+
532
## Version 1.39.0 (2024-09-17)
633

734
### AWS X-Ray propagator

buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repositories {
1313
dependencies {
1414
// When updating, update above in plugins too
1515
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
16-
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
17-
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0")
16+
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.1.0")
17+
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.1.0")
1818
implementation("com.gradle.enterprise:com.gradle.enterprise.gradle.plugin:3.18.1")
1919
}
2020

consistent-sampling/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# Consistent sampling
22

3-
This component adds various Sampler implementations for consistent sampling as defined by
3+
There are two major components included here.
4+
5+
## Original proposal implementation
6+
7+
The original specification for consistent probability sampling is defined by
48
<https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling.md>
59
and <https://github.com/open-telemetry/opentelemetry-specification/pull/2047>.
10+
It supports sampling probabilities that are power of 2 (1, 1/2, 1/4, ...), and uses 8-bit `r-value` and 8-bit `p-value` in tracestate.
11+
12+
The implementation of this proposal is contained by the package `io/opentelemetry/contrib/sampler/consistent` in this repository and provides various Sampler implementations.
613

714
* **ConsistentSampler**:
815
abstract base class of all consistent sampler implementations below
@@ -23,6 +30,31 @@ and <https://github.com/open-telemetry/opentelemetry-specification/pull/2047>.
2330
a rate limiting sampler based on exponential smoothing that dynamically adjusts the sampling
2431
probability based on the estimated rate of spans occurring to satisfy a given rate of sampled spans
2532

33+
## Current proposal implementation
34+
35+
The current version of the specification for consistent probability sampling is described by
36+
<https://github.com/open-telemetry/oteps/blob/main/text/trace/0235-sampling-threshold-in-trace-state.md>.
37+
It uses **56** bits for representing _rejection threshold_, which corresponds to a much wider range of sampling probabilities than the original proposal.
38+
39+
The implementation of the current proposal is contained by the package `io/opentelemetry/contrib/sampler/consistent56` in this repository and provides implementation for a number of different Samplers.
40+
41+
* **ConsistentSampler**
42+
abstract base class for all consistent sampler implementations
43+
* **ComposableSampler**:
44+
interface used to build hierarchies of Samplers, see [Composite Samplers](https://github.com/open-telemetry/oteps/pull/250)
45+
* **ConsistentAlwaysOffSampler**:
46+
* **ConsistentAlwaysOnSampler**:
47+
* **ConsistentAnyOfSampler**:
48+
allows combining several consistent samplers; it samples when at least one of them would sample,
49+
* **ConsistentParentBasedSampler**:
50+
* **ConsistentFixedThresholdSampler**:
51+
consistent probability sampler that uses a predefined sampling probability
52+
* **ConsistentRateLimitingSampler**:
53+
a rate limiting sampler based on exponential smoothing that dynamically adjusts the sampling
54+
probability based on the estimated rate of spans occurring to satisfy a given rate of sampled spans
55+
* **ConsistentRuleBasedSampler**
56+
a sampler that performs stratified sampling by evaluating qualifying conditions and propagating the sampling decision from one of its delegate samplers
57+
2658
## Component owners
2759

2860
- [Otmar Ertl](https://github.com/oertl), Dynatrace

dependencyManagement/build.gradle.kts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ data class DependencySet(val group: String, val version: String, val modules: Li
77
val dependencyVersions = hashMapOf<String, String>()
88
rootProject.extra["versions"] = dependencyVersions
99

10-
val otelInstrumentationVersion = "2.8.0-alpha"
10+
val otelInstrumentationVersion = "2.9.0-alpha"
1111

1212
val DEPENDENCY_BOMS = listOf(
1313
"com.fasterxml.jackson:jackson-bom:2.18.0",
1414
"com.google.guava:guava-bom:33.3.1-jre",
1515
"com.linecorp.armeria:armeria-bom:1.30.1",
16-
"org.junit:junit-bom:5.11.2",
16+
"org.junit:junit-bom:5.11.3",
1717
"io.grpc:grpc-bom:1.68.0",
1818
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}",
1919
"org.testcontainers:testcontainers-bom:1.20.1"
2020
)
2121

2222
val autoServiceVersion = "1.1.1"
2323
val autoValueVersion = "1.11.0"
24-
val errorProneVersion = "2.33.0"
24+
val errorProneVersion = "2.34.0"
2525
val prometheusVersion = "0.16.0"
2626
val mockitoVersion = "4.11.0"
2727
val slf4jVersion = "2.0.16"
@@ -36,6 +36,8 @@ val CORE_DEPENDENCIES = listOf(
3636
"com.google.errorprone:error_prone_core:${errorProneVersion}",
3737
"io.github.netmikey.logunit:logunit-jul:2.0.0",
3838
"io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha",
39+
// these two constraints can be removed once the opentelemetry-instrumentation-bom-alpha
40+
// is updated to contain the latest version of opentelemetry-semconv
3941
"io.opentelemetry.semconv:opentelemetry-semconv:${semConvVersion}",
4042
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:${semConvVersion}",
4143
"io.prometheus:simpleclient:${prometheusVersion}",
@@ -55,7 +57,7 @@ val DEPENDENCIES = listOf(
5557
"com.google.code.findbugs:annotations:3.0.1u2",
5658
"com.google.code.findbugs:jsr305:3.0.2",
5759
"com.squareup.okhttp3:okhttp:4.12.0",
58-
"com.uber.nullaway:nullaway:0.11.3",
60+
"com.uber.nullaway:nullaway:0.12.0",
5961
"org.assertj:assertj-core:3.26.3",
6062
"org.awaitility:awaitility:4.2.2",
6163
"org.bouncycastle:bcpkix-jdk15on:1.70",
@@ -76,6 +78,12 @@ javaPlatform {
7678

7779
dependencies {
7880
for (bom in DEPENDENCY_BOMS) {
81+
// this is needed until io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha
82+
// is updated to contain the latest version of opentelemetry-semconv
83+
if (bom.equals("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}")) {
84+
api(platform(bom))
85+
continue
86+
}
7987
api(enforcedPlatform(bom))
8088
val split = bom.split(':')
8189
dependencyVersions[split[0]] = split[2]

jfr-events/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Create JFR events that can be recorded and viewed in Java Mission Control (JMC).
66

77
* Creates Open Telemetry Tracing/Span events for spans
8-
* The thread and stracktrace will be of the thead ending the span which might be different than the thread creating the span.
8+
* The thread and stacktrace will be of the thead ending the span which might be different from the thread creating the span.
99
* Has the fields
1010
* Operation Name
1111
* Trace ID

jmx-scraper/build.gradle.kts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,7 @@ otelJava.moduleName.set("io.opentelemetry.contrib.jmxscraper")
1313

1414
application.mainClass.set("io.opentelemetry.contrib.jmxscraper.JmxScraper")
1515

16-
repositories {
17-
mavenCentral()
18-
mavenLocal()
19-
// TODO: remove snapshot repository once 2.9.0 is released
20-
maven {
21-
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
22-
}
23-
}
24-
2516
dependencies {
26-
// TODO remove snapshot dependency on upstream once 2.9.0 is released
27-
api(enforcedPlatform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.9.0-alpha-SNAPSHOT"))
28-
2917
implementation("io.opentelemetry:opentelemetry-api")
3018
implementation("io.opentelemetry:opentelemetry-sdk")
3119
implementation("io.opentelemetry:opentelemetry-sdk-metrics")
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.contrib.jmxscraper.target_systems;
7+
8+
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertGaugeWithAttributes;
9+
import static io.opentelemetry.contrib.jmxscraper.target_systems.MetricAssertions.assertSumWithAttributes;
10+
import static org.assertj.core.api.Assertions.entry;
11+
12+
import io.opentelemetry.contrib.jmxscraper.JmxScraperContainer;
13+
import java.time.Duration;
14+
import org.testcontainers.containers.GenericContainer;
15+
import org.testcontainers.containers.wait.strategy.Wait;
16+
import org.testcontainers.images.builder.ImageFromDockerfile;
17+
18+
public class ActiveMqIntegrationTest extends TargetSystemIntegrationTest {
19+
20+
@Override
21+
protected GenericContainer<?> createTargetContainer(int jmxPort) {
22+
return new GenericContainer<>(
23+
new ImageFromDockerfile()
24+
.withDockerfileFromBuilder(
25+
builder -> builder.from("apache/activemq-classic:5.18.6").build()))
26+
.withEnv(
27+
"JAVA_TOOL_OPTIONS",
28+
"-Dcom.sun.management.jmxremote.port="
29+
+ jmxPort
30+
+ " -Dcom.sun.management.jmxremote.rmi.port="
31+
+ jmxPort
32+
+ " -Dcom.sun.management.jmxremote.ssl=false"
33+
+ " -Dcom.sun.management.jmxremote.authenticate=false")
34+
.withStartupTimeout(Duration.ofMinutes(2))
35+
.waitingFor(Wait.forListeningPort());
36+
}
37+
38+
@Override
39+
protected JmxScraperContainer customizeScraperContainer(JmxScraperContainer scraper) {
40+
return scraper.withTargetSystem("activemq");
41+
}
42+
43+
@Override
44+
protected void verifyMetrics() {
45+
waitAndAssertMetrics(
46+
metric ->
47+
assertSumWithAttributes(
48+
metric,
49+
"activemq.consumer.count",
50+
"The number of consumers currently reading from the broker.",
51+
"consumers",
52+
/* isMonotonic= */ false,
53+
attrs ->
54+
attrs.containsOnly(
55+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
56+
entry("broker", "localhost"))),
57+
metric ->
58+
assertSumWithAttributes(
59+
metric,
60+
"activemq.producer.count",
61+
"The number of producers currently attached to the broker.",
62+
"producers",
63+
/* isMonotonic= */ false,
64+
attrs ->
65+
attrs.containsOnly(
66+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
67+
entry("broker", "localhost"))),
68+
metric ->
69+
assertSumWithAttributes(
70+
metric,
71+
"activemq.connection.count",
72+
"The total number of current connections.",
73+
"connections",
74+
/* isMonotonic= */ false,
75+
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
76+
metric ->
77+
assertGaugeWithAttributes(
78+
metric,
79+
"activemq.memory.usage",
80+
"The percentage of configured memory used.",
81+
"%",
82+
attrs ->
83+
attrs.containsOnly(
84+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
85+
entry("broker", "localhost"))),
86+
metric ->
87+
assertGaugeWithAttributes(
88+
metric,
89+
"activemq.disk.store_usage",
90+
"The percentage of configured disk used for persistent messages.",
91+
"%",
92+
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
93+
metric ->
94+
assertGaugeWithAttributes(
95+
metric,
96+
"activemq.disk.temp_usage",
97+
"The percentage of configured disk used for non-persistent messages.",
98+
"%",
99+
attrs -> attrs.containsOnly(entry("broker", "localhost"))),
100+
metric ->
101+
assertSumWithAttributes(
102+
metric,
103+
"activemq.message.current",
104+
"The current number of messages waiting to be consumed.",
105+
"messages",
106+
/* isMonotonic= */ false,
107+
attrs ->
108+
attrs.containsOnly(
109+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
110+
entry("broker", "localhost"))),
111+
metric ->
112+
assertSumWithAttributes(
113+
metric,
114+
"activemq.message.expired",
115+
"The total number of messages not delivered because they expired.",
116+
"messages",
117+
attrs ->
118+
attrs.containsOnly(
119+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
120+
entry("broker", "localhost"))),
121+
metric ->
122+
assertSumWithAttributes(
123+
metric,
124+
"activemq.message.enqueued",
125+
"The total number of messages received by the broker.",
126+
"messages",
127+
attrs ->
128+
attrs.containsOnly(
129+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
130+
entry("broker", "localhost"))),
131+
metric ->
132+
assertSumWithAttributes(
133+
metric,
134+
"activemq.message.dequeued",
135+
"The total number of messages delivered to consumers.",
136+
"messages",
137+
attrs ->
138+
attrs.containsOnly(
139+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
140+
entry("broker", "localhost"))),
141+
metric ->
142+
assertGaugeWithAttributes(
143+
metric,
144+
"activemq.message.wait_time.avg",
145+
"The average time a message was held on a destination.",
146+
"ms",
147+
attrs ->
148+
attrs.containsOnly(
149+
entry("destination", "ActiveMQ.Advisory.MasterBroker"),
150+
entry("broker", "localhost"))));
151+
}
152+
}

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/MetricAssertions.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,23 @@ static void assertSumWithAttributes(
7272
String description,
7373
String unit,
7474
Consumer<MapAssert<String, String>>... attributeGroupAssertions) {
75+
assertSumWithAttributes(
76+
metric, name, description, unit, /* isMonotonic= */ true, attributeGroupAssertions);
77+
}
78+
79+
@SafeVarargs
80+
static void assertSumWithAttributes(
81+
Metric metric,
82+
String name,
83+
String description,
84+
String unit,
85+
boolean isMonotonic,
86+
Consumer<MapAssert<String, String>>... attributeGroupAssertions) {
7587
assertThat(metric.getName()).isEqualTo(name);
7688
assertThat(metric.getDescription()).isEqualTo(description);
7789
assertThat(metric.getUnit()).isEqualTo(unit);
7890
assertThat(metric.hasSum()).isTrue();
91+
assertThat(metric.getSum().getIsMonotonic()).isEqualTo(isMonotonic);
7992
assertAttributedPoints(metric.getSum().getDataPointsList(), attributeGroupAssertions);
8093
}
8194

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TomcatIntegrationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ protected GenericContainer<?> createTargetContainer(int jmxPort) {
3030
"https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/sample.war",
3131
"/usr/local/tomcat/webapps/ROOT.war")
3232
.build()))
33-
.withEnv("LOCAL_JMX", "no")
3433
.withEnv("CATALINA_OPTS", genericJmxJvmArguments(jmxPort))
3534
.withStartupTimeout(Duration.ofMinutes(2))
3635
.waitingFor(Wait.forListeningPort());

jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void main(String[] args) {
7878
System.err.println("Unable to connect " + e.getMessage());
7979
System.exit(2);
8080
} catch (RuntimeException e) {
81-
System.err.println("ERROR: " + e.getMessage());
81+
e.printStackTrace(System.err);
8282
System.exit(3);
8383
}
8484
}

0 commit comments

Comments
 (0)