Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt new io.opentelemetry.semconv:opentelemetry-semconv lib #1059

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions maven-extension/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-sdk-trace")
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
implementation("io.opentelemetry:opentelemetry-semconv")
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")

annotationProcessor("com.google.auto.value:auto-value")
Expand Down Expand Up @@ -60,10 +60,3 @@ tasks {
}

tasks.getByName("test").dependsOn("shadowJar")

configurations.all {
resolutionStrategy {
// TODO this module still needs to be updated to the latest semconv
force("io.opentelemetry:opentelemetry-semconv:1.28.0-alpha")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.maven.MavenGoal;
import io.opentelemetry.maven.semconv.MavenOtelSemanticAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -19,7 +19,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** See https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin */
/**
* See <a href="https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin">Jit Maven
* Plugin</a>
*/
final class GoogleJibBuildHandler implements MojoGoalExecutionHandler {
private static final Logger logger = LoggerFactory.getLogger(GoogleJibBuildHandler.class);

Expand All @@ -29,6 +32,7 @@ public List<MavenGoal> getSupportedGoals() {
MavenGoal.create("com.google.cloud.tools", "jib-maven-plugin", "build"));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mateuszrzeszutek @jack-berg @laurit we haven't discussed bumping the contrib repo to 2.0 when we bump the instrumentation repo, but it could make sense to keep the -instrumentation and -contrib repos version aligned

@srprash @wangzlei would you want to follow this approach instead of the clean break that was merged in #1050? (we have time before the next release to revert that change if you want)

@Override
public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {
spanBuilder.setSpanKind(SpanKind.CLIENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.maven.MavenGoal;
import io.opentelemetry.maven.semconv.MavenOtelSemanticAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.MalformedURLException;
import java.net.URL;
import io.opentelemetry.semconv.SemanticAttributes;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.Artifact;
Expand All @@ -29,6 +29,7 @@
final class MavenDeployHandler implements MojoGoalExecutionHandler {
private static final Logger logger = LoggerFactory.getLogger(MavenDeployHandler.class);

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@Override
public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent execution) {
spanBuilder.setSpanKind(SpanKind.CLIENT);
Expand All @@ -53,8 +54,8 @@ public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent execution) {
// may not fully comply with the OTel "peer.service" spec as we don't know if the remote
// service will be instrumented and what it "service.name" would be
spanBuilder.setAttribute(
SemanticAttributes.PEER_SERVICE, new URL(artifactRepositoryUrl).getHost());
} catch (MalformedURLException e) {
SemanticAttributes.PEER_SERVICE, new URI(artifactRepositoryUrl).getHost());
} catch (URISyntaxException e) {
logger.debug("Ignore exception parsing artifact repository URL", e);
}
Artifact artifact = project.getArtifact();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.maven.MavenGoal;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.Collections;
import java.util.List;
import org.apache.maven.execution.ExecutionEvent;

/** See https://github.com/snyk/snyk-maven-plugin */
/** See <a href="https://github.com/snyk/snyk-maven-plugin">Snyk Maven Plugin</a> */
final class SnykMonitorHandler implements MojoGoalExecutionHandler {

/**
* Snyk command "reversed engineered" invoking the Snyk CLI on a Maven project with the `-d` debug
* flag `snyk -d monitor`. See <a href="https://snyk.io/blog/snyk-cli-cheat-sheet/">Snyk CLI Cheat
* Sheet</a>
*/
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@Override
public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {
spanBuilder.setSpanKind(SpanKind.CLIENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.maven.MavenGoal;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.Collections;
import java.util.List;
import org.apache.maven.execution.ExecutionEvent;

/** See https://github.com/snyk/snyk-maven-plugin */
/** See <a href="https://github.com/snyk/snyk-maven-plugin">Snyk Maven Plugin</a> */
final class SnykTestHandler implements MojoGoalExecutionHandler {

/**
* Snyk command "reversed engineered" invoking the Snyk CLI on a Maven project with the `-d` debug
* flag `snyk -d test`. See <a href="https://snyk.io/blog/snyk-cli-cheat-sheet/">Snyk CLI Cheat
* Sheet</a>
*/
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@Override
public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {
spanBuilder.setSpanKind(SpanKind.CLIENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.maven.MavenGoal;
import io.opentelemetry.maven.semconv.MavenOtelSemanticAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.MalformedURLException;
import java.net.URL;
import io.opentelemetry.semconv.SemanticAttributes;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.List;
import org.apache.maven.execution.ExecutionEvent;
Expand Down Expand Up @@ -40,6 +40,7 @@ public List<MavenGoal> getSupportedGoals() {
MavenGoal.create("org.springframework.boot", "spring-boot-maven-plugin", "build-image"));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@Override
public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {

Expand Down Expand Up @@ -106,8 +107,8 @@ public void enrichSpan(SpanBuilder spanBuilder, ExecutionEvent executionEvent) {
// may not fully comply with the OTel "peer.service" spec as we don't know if the remote
// service will be instrumented and what it "service.name" would be
spanBuilder.setAttribute(
SemanticAttributes.PEER_SERVICE, new URL(registryUrl).getHost());
} catch (MalformedURLException e) {
SemanticAttributes.PEER_SERVICE, new URI(registryUrl).getHost());
} catch (URISyntaxException e) {
logger.debug("Ignore exception parsing container registry URL", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import io.opentelemetry.semconv.ResourceAttributes;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.rtinfo.internal.DefaultRuntimeInformation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import io.opentelemetry.semconv.ResourceAttributes;
import java.util.List;

/**
* Semantic attributes for Maven executions.
*
* @see io.opentelemetry.api.common.Attributes
* @see io.opentelemetry.semconv.trace.attributes.SemanticAttributes
* @see io.opentelemetry.semconv.SemanticAttributes
*/
public class MavenOtelSemanticAttributes {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.opentelemetry.maven.semconv.MavenOtelSemanticAttributes;
import io.opentelemetry.sdk.trace.ReadableSpan;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
Expand All @@ -40,8 +40,10 @@
import org.junit.jupiter.api.Test;

/**
* TODO Find a better solution to instantiate a MavenProject and a MojoExecutionEvent. See
* https://github.com/takari/takari-lifecycle/blob/master/takari-lifecycle-plugin/src/test/java/io/takari/maven/plugins/plugin/PluginDescriptorMojoTest.java
* TODO Find a better solution to instantiate a MavenProject and a MojoExecutionEvent. Unfortunately
* the <a
* href="https://github.com/takari/takari-lifecycle/blob/master/takari-lifecycle-plugin/src/test/java/io/takari/maven/plugins/plugin/PluginDescriptorMojoTest.java">Takari
* testing framework</a> can't test Maven extensions.
*/
@SuppressWarnings({"DeduplicateConstants", "deprecation"})
public class MojoGoalExecutionHandlerTest {
Expand Down
Loading