Skip to content

Commit

Permalink
Merge branch 'main' into dev/PIP-363
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Aug 19, 2024
2 parents a095484 + a5ca781 commit aa745a0
Show file tree
Hide file tree
Showing 47 changed files with 751 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
java-version-file: .java-version

- name: Initialize CodeQL
uses: github/codeql-action/init@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0
uses: github/codeql-action/init@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
with:
languages: java
# using "latest" helps to keep up with the latest Kotlin support
Expand All @@ -45,7 +45,7 @@ jobs:
run: ./gradlew assemble -x javadoc --no-build-cache --no-daemon

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0
uses: github/codeql-action/analyze@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2

workflow-notification:
needs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0
uses: github/codeql-action/upload-sarif@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
with:
sarif_file: results.sarif
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@

## Unreleased

## Version 2.7.0 (2024-08-16)

### 📈 Enhancements

- Add span baggage processor
([#11697](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11697))
- Improve tomcat version detection
([#11936](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11936))
- Improve akka route handling with java dsl
([#11926](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11926))
- Ignore Alibaba fastjson ASMClassLoader
([#11954](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11954))
- Use `aws-lambda-java-serialization` library, which is available by default, while deserializing input and serializing output
([#11868](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11868))
- Logback appender: map timestamp in nanoseconds if possible
([#11974](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11974))
- Save ILoggingEvent.getArgumentArray() arguments from Logback
([#11865](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11865))
- Update Java 17-based metrics to stable semconv
([#11914](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11914))
- Add Pulsar Consumer metrics
([#11891](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11891))

### 🛠️ Bug fixes

- Fix missing throw statement in RestClientWrapper
([#11893](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11893))
- Fix ClickHouse tracing when database name not included in connection string
([#11852](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11852))
- Fix class cast exception, noop meter does not implement incubating API
([#11934](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11934))
- Closing a kafka producer/consumer should not disable metrics from other consumers/producers
([#11975](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11975))
- Fix ending span in Ktor plugin
([#11726](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11726))
- Fix netty memory leak
([#12003](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/12003))

## Version 1.33.5 (2024-07-25)

### 📈 Enhancements
Expand Down
2 changes: 1 addition & 1 deletion benchmark-overhead/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
}

dependencies {
implementation(enforcedPlatform("org.junit:junit-bom:5.10.3"))
implementation(enforcedPlatform("org.junit:junit-bom:5.11.0"))

testImplementation("org.testcontainers:testcontainers:1.20.1")
testImplementation("org.testcontainers:postgresql:1.20.1")
Expand Down
8 changes: 4 additions & 4 deletions conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ dependencies {

// When updating, update above in plugins too
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.google.guava:guava:33.2.1-jre")
implementation("com.google.guava:guava:33.3.0-jre")
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.0")
implementation("org.apache.httpcomponents:httpclient:4.5.14")
implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:3.17.6")
implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:3.18")
implementation("org.owasp:dependency-check-gradle:10.0.3")
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.1")
implementation("org.spdx:spdx-gradle-plugin:0.8.0")
// When updating, also update dependencyManagement/build.gradle.kts
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.14.18")
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.14.19")
implementation("gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.6")
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0")
implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.3")

testImplementation(enforcedPlatform("org.junit:junit-bom:5.10.3"))
testImplementation(enforcedPlatform("org.junit:junit-bom:5.11.0"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.assertj:assertj-core:3.26.3")
Expand Down
6 changes: 3 additions & 3 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ val groovyVersion = "4.0.22"
val DEPENDENCY_BOMS = listOf(
"com.fasterxml.jackson:jackson-bom:2.17.2",
"com.squareup.okio:okio-bom:3.9.0", // see https://github.com/open-telemetry/opentelemetry-java/issues/5637
"com.google.guava:guava-bom:33.2.1-jre",
"com.google.guava:guava-bom:33.3.0-jre",
"org.apache.groovy:groovy-bom:${groovyVersion}",
"io.opentelemetry:opentelemetry-bom:${otelSdkVersion}",
"io.opentelemetry:opentelemetry-bom-alpha:${otelSdkAlphaVersion}",
"org.junit:junit-bom:5.10.3",
"org.junit:junit-bom:5.11.0",
"org.testcontainers:testcontainers-bom:1.20.1",
"org.spockframework:spock-bom:2.4-M4-groovy-4.0"
)

val autoServiceVersion = "1.1.1"
val autoValueVersion = "1.11.0"
val errorProneVersion = "2.30.0"
val byteBuddyVersion = "1.14.18"
val byteBuddyVersion = "1.14.19"
val asmVersion = "9.7"
val jmhVersion = "1.37"
val mockitoVersion = "4.11.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Comparing source compatibility of opentelemetry-instrumentation-annotations-2.7.0-SNAPSHOT.jar against opentelemetry-instrumentation-annotations-2.6.0.jar
Comparing source compatibility of opentelemetry-instrumentation-annotations-2.8.0-SNAPSHOT.jar against opentelemetry-instrumentation-annotations-2.7.0.jar
No changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Comparing source compatibility of opentelemetry-instrumentation-api-2.7.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.6.0.jar
Comparing source compatibility of opentelemetry-instrumentation-api-2.8.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.7.0.jar
No changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.7.0-SNAPSHOT.jar against opentelemetry-spring-boot-autoconfigure-2.6.0.jar
Comparing source compatibility of opentelemetry-spring-boot-autoconfigure-2.8.0-SNAPSHOT.jar against opentelemetry-spring-boot-autoconfigure-2.7.0.jar
No changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Comparing source compatibility of opentelemetry-spring-boot-starter-2.7.0-SNAPSHOT.jar against opentelemetry-spring-boot-starter-2.6.0.jar
Comparing source compatibility of opentelemetry-spring-boot-starter-2.8.0-SNAPSHOT.jar against opentelemetry-spring-boot-starter-2.7.0.jar
No changes.
8 changes: 4 additions & 4 deletions examples/distro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
classpath "com.gradleup.shadow:shadow-gradle-plugin:8.3.0"
classpath "io.opentelemetry.instrumentation:gradle-plugins:2.7.0-alpha-SNAPSHOT"
classpath "io.opentelemetry.instrumentation:gradle-plugins:2.8.0-alpha-SNAPSHOT"
}
}

Expand All @@ -30,11 +30,11 @@ subprojects {
opentelemetrySdk : "1.41.0",

// these lines are managed by .github/scripts/update-version.sh
opentelemetryJavaagent : "2.7.0-SNAPSHOT",
opentelemetryJavaagentAlpha: "2.7.0-alpha-SNAPSHOT",
opentelemetryJavaagent : "2.8.0-SNAPSHOT",
opentelemetryJavaagentAlpha: "2.8.0-alpha-SNAPSHOT",

autoservice : "1.1.1",
junit : "5.10.3"
junit : "5.11.0"
]

deps = [
Expand Down
2 changes: 1 addition & 1 deletion examples/distro/smoke-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
testImplementation("io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha")
testImplementation("io.opentelemetry:opentelemetry-api")

testImplementation("ch.qos.logback:logback-classic:1.5.6")
testImplementation("ch.qos.logback:logback-classic:1.5.7")
}

tasks.test {
Expand Down
12 changes: 6 additions & 6 deletions examples/extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ plugins {
id "com.gradleup.shadow" version "8.3.0"
id "com.diffplug.spotless" version "6.25.0"

id "io.opentelemetry.instrumentation.muzzle-generation" version "2.7.0-alpha-SNAPSHOT"
id "io.opentelemetry.instrumentation.muzzle-check" version "2.7.0-alpha-SNAPSHOT"
id "io.opentelemetry.instrumentation.muzzle-generation" version "2.8.0-alpha-SNAPSHOT"
id "io.opentelemetry.instrumentation.muzzle-check" version "2.8.0-alpha-SNAPSHOT"
}

group 'io.opentelemetry.example'
Expand All @@ -26,10 +26,10 @@ ext {
opentelemetrySdk : "1.41.0",

// these lines are managed by .github/scripts/update-version.sh
opentelemetryJavaagent : "2.7.0-SNAPSHOT",
opentelemetryJavaagentAlpha: "2.7.0-alpha-SNAPSHOT",
opentelemetryJavaagent : "2.8.0-SNAPSHOT",
opentelemetryJavaagentAlpha: "2.8.0-alpha-SNAPSHOT",

junit : "5.10.3"
junit : "5.11.0"
]

deps = [
Expand Down Expand Up @@ -108,7 +108,7 @@ dependencies {

testImplementation("org.junit.jupiter:junit-jupiter-api:${versions.junit}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${versions.junit}")
testRuntimeOnly("ch.qos.logback:logback-classic:1.5.6")
testRuntimeOnly("ch.qos.logback:logback-classic:1.5.7")

//Otel Java instrumentation that we use and extend during integration tests
otel("io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}")
Expand Down
6 changes: 3 additions & 3 deletions gradle-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ configurations.named("compileOnly") {
extendsFrom(bbGradlePlugin)
}

val byteBuddyVersion = "1.14.18"
val byteBuddyVersion = "1.14.19"
val aetherVersion = "1.1.0"

dependencies {
implementation("com.google.guava:guava:33.2.1-jre")
implementation("com.google.guava:guava:33.3.0-jre")
// we need to use byte buddy variant that does not shade asm
implementation("net.bytebuddy:byte-buddy-gradle-plugin:${byteBuddyVersion}") {
exclude(group = "net.bytebuddy", module = "byte-buddy")
Expand All @@ -43,7 +43,7 @@ dependencies {

testImplementation("org.assertj:assertj-core:3.26.3")

testImplementation(enforcedPlatform("org.junit:junit-bom:5.10.3"))
testImplementation(enforcedPlatform("org.junit:junit-bom:5.11.0"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
AttributeKey.booleanKey("messaging.destination.anonymous");
private static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
AttributeKey.stringKey("messaging.destination.name");
private static final AttributeKey<String> MESSAGING_DESTINATION_PARTITION_ID =
AttributeKey.stringKey("messaging.destination.partition.id");
private static final AttributeKey<String> MESSAGING_DESTINATION_TEMPLATE =
AttributeKey.stringKey("messaging.destination.template");
private static final AttributeKey<Boolean> MESSAGING_DESTINATION_TEMPORARY =
Expand Down Expand Up @@ -98,6 +100,8 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
internalSet(
attributes, MESSAGING_DESTINATION_TEMPLATE, getter.getDestinationTemplate(request));
}
internalSet(
attributes, MESSAGING_DESTINATION_PARTITION_ID, getter.getDestinationPartitionId(request));
boolean isAnonymousDestination = getter.isAnonymousDestination(request);
if (isAnonymousDestination) {
internalSet(attributes, MESSAGING_DESTINATION_ANONYMOUS, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ default Long getMessagePayloadCompressedSize(REQUEST request) {
@Nullable
Long getBatchMessageCount(REQUEST request, @Nullable RESPONSE response);

@Nullable
default String getDestinationPartitionId(REQUEST request) {
return null;
}

/**
* Extracts all values of header named {@code name} from the request, or an empty list if there
* were none.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.api.incubator.semconv.messaging;

import static java.util.logging.Level.FINE;

import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.DoubleHistogram;
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
import io.opentelemetry.api.metrics.LongCounter;
import io.opentelemetry.api.metrics.LongCounterBuilder;
import io.opentelemetry.api.metrics.Meter;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.ContextKey;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.instrumenter.OperationMetrics;
import io.opentelemetry.instrumentation.api.internal.OperationMetricsUtil;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
* {@link OperationListener} which keeps track of <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/v1.26.0/docs/messaging/messaging-metrics.md#consumer-metrics">Consumer
* metrics</a>.
*/
public final class MessagingConsumerMetrics implements OperationListener {
private static final double NANOS_PER_S = TimeUnit.SECONDS.toNanos(1);

// copied from MessagingIncubatingAttributes
private static final AttributeKey<Long> MESSAGING_BATCH_MESSAGE_COUNT =
AttributeKey.longKey("messaging.batch.message_count");
private static final ContextKey<MessagingConsumerMetrics.State> MESSAGING_CONSUMER_METRICS_STATE =
ContextKey.named("messaging-consumer-metrics-state");
private static final Logger logger = Logger.getLogger(MessagingConsumerMetrics.class.getName());

private final DoubleHistogram receiveDurationHistogram;
private final LongCounter receiveMessageCount;

private MessagingConsumerMetrics(Meter meter) {
DoubleHistogramBuilder durationBuilder =
meter
.histogramBuilder("messaging.receive.duration")
.setDescription("Measures the duration of receive operation.")
.setExplicitBucketBoundariesAdvice(MessagingMetricsAdvice.DURATION_SECONDS_BUCKETS)
.setUnit("s");
MessagingMetricsAdvice.applyReceiveDurationAdvice(durationBuilder);
receiveDurationHistogram = durationBuilder.build();

LongCounterBuilder longCounterBuilder =
meter
.counterBuilder("messaging.receive.messages")
.setDescription("Measures the number of received messages.")
.setUnit("{message}");
MessagingMetricsAdvice.applyReceiveMessagesAdvice(longCounterBuilder);
receiveMessageCount = longCounterBuilder.build();
}

public static OperationMetrics get() {
return OperationMetricsUtil.create("messaging consumer", MessagingConsumerMetrics::new);
}

@Override
@CanIgnoreReturnValue
public Context onStart(Context context, Attributes startAttributes, long startNanos) {
return context.with(
MESSAGING_CONSUMER_METRICS_STATE,
new AutoValue_MessagingConsumerMetrics_State(startAttributes, startNanos));
}

@Override
public void onEnd(Context context, Attributes endAttributes, long endNanos) {
MessagingConsumerMetrics.State state = context.get(MESSAGING_CONSUMER_METRICS_STATE);
if (state == null) {
logger.log(
FINE,
"No state present when ending context {0}. Cannot record consumer receive metrics.",
context);
return;
}

Attributes attributes = state.startAttributes().toBuilder().putAll(endAttributes).build();
receiveDurationHistogram.record(
(endNanos - state.startTimeNanos()) / NANOS_PER_S, attributes, context);

long receiveMessagesCount = getReceiveMessagesCount(state.startAttributes(), endAttributes);
receiveMessageCount.add(receiveMessagesCount, attributes, context);
}

private static long getReceiveMessagesCount(Attributes... attributesList) {
for (Attributes attributes : attributesList) {
Long value = attributes.get(MESSAGING_BATCH_MESSAGE_COUNT);
if (value != null) {
return value;
}
}
return 1;
}

@AutoValue
abstract static class State {

abstract Attributes startAttributes();

abstract long startTimeNanos();
}
}
Loading

0 comments on commit aa745a0

Please sign in to comment.