Skip to content

Commit

Permalink
Bump OTEL dependency to 0.17.0 (#280)
Browse files Browse the repository at this point in the history
* Bump OTEL to 0.17.0

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix smoke tests

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Revert path

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Rename image

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* remove

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* fmt

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix traces exporter env var

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix grpc test

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Small revert

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* enable test

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* Fix propagators

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>

* x2

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay authored Mar 3, 2021
1 parent ab7de69 commit 8e5e87a
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 42 deletions.
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ subprojects {
description = "Hypertrace OpenTelemetry Javaagent"

extra.set("versions", mapOf(
"opentelemetry" to "0.15.0",
"opentelemetry_java_agent" to "0.15.1",
"byte_buddy" to "1.10.18",
"opentelemetry" to "0.17.1",
"opentelemetry_java_agent" to "0.17.0-alpha",
"opentelemetry_java_agent_all" to "0.17.0",
"byte_buddy" to "1.10.18",
"slf4j" to "1.7.30"
))

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ tasks {
relocate("io.opentelemetry.spi", "io.opentelemetry.javaagent.shaded.io.opentelemetry.spi")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin")
relocate ("io.opentelemetry.extension.trace.propagation", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.trace.propagation")
relocate("io.opentelemetry.extension.aws", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.aws")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise prm) {
Channel channel = ctx.channel();
Context context =
channel
.attr(
io.opentelemetry.javaagent.instrumentation.netty.v4_1.AttributeKeys.CLIENT_CONTEXT)
.attr(io.opentelemetry.instrumentation.netty.v4_1.AttributeKeys.CLIENT_CONTEXT)
.get();
if (context == null) {
ctx.write(msg, prm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
Channel channel = ctx.channel();
Context context =
channel
.attr(
io.opentelemetry.javaagent.instrumentation.netty.v4_1.AttributeKeys.CLIENT_CONTEXT)
.attr(io.opentelemetry.instrumentation.netty.v4_1.AttributeKeys.CLIENT_CONTEXT)
.get();
if (context == null) {
ctx.fireChannelRead(msg);
Expand Down
4 changes: 2 additions & 2 deletions javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
// update the dependencies also in the instrumentations sub-projects
// https://oss.jfrog.org/artifactory/oss-snapshot-local/io/opentelemetry/instrumentation/auto/
// https://dl.bintray.com/open-telemetry/maven/
implementation("io.opentelemetry.javaagent", "opentelemetry-javaagent", version = "${versions["opentelemetry_java_agent"]}", classifier = "all")
implementation("io.opentelemetry.javaagent", "opentelemetry-javaagent", version = "${versions["opentelemetry_java_agent_all"]}", classifier = "all")
implementation(project(":filter-api"))
}

Expand Down Expand Up @@ -60,7 +60,7 @@ tasks {
relocate("io.opentelemetry.spi", "io.opentelemetry.javaagent.shaded.io.opentelemetry.spi")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin")
relocate("io.opentelemetry.extension.trace.propagation", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.trace.propagation")
relocate("io.opentelemetry.extension.aws", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.aws")

mergeServiceFiles {
include("inst/META-INF/services/*")
Expand Down
1 change: 1 addition & 0 deletions otel-extensions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dependencies {
implementation("net.bytebuddy:byte-buddy:${versions["byte_buddy"]}")
annotationProcessor("com.google.auto.service:auto-service:1.0-rc7")

testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${versions["opentelemetry"]}-alpha")
testImplementation("io.opentelemetry:opentelemetry-sdk:${versions["opentelemetry"]}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class HypertraceAgentConfiguration implements PropertySource {

// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-environment-variables.md
private static final String OTEL_TRACE_EXPORTER = "otel.trace.exporter";
private static final String OTEL_TRACE_EXPORTER = "otel.traces.exporter";
private static final String OTEL_METRICS_EXPORTER = "otel.metrics.exporter";
private static final String OTEL_PROPAGATORS = "otel.propagators";
private static final String OTEL_EXPORTER_ZIPKIN_ENDPOINT = "otel.exporter.zipkin.endpoint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.sdk.resources.ResourceAttributes;
import io.opentelemetry.sdk.resources.ResourceProvider;
import io.opentelemetry.sdk.autoconfigure.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import org.hypertrace.agent.config.Config.AgentConfig;
import org.hypertrace.agent.core.config.HypertraceConfig;

@AutoService(ResourceProvider.class)
public class HypertraceResourceProvider extends ResourceProvider {
public class HypertraceResourceProvider implements ResourceProvider {

private final CgroupsReader cgroupsReader = new CgroupsReader();
private final AgentConfig agentConfig = HypertraceConfig.get();

@Override
protected Attributes getAttributes() {
public Resource createResource(ConfigProperties config) {
AttributesBuilder builder = Attributes.builder();
String containerId = this.cgroupsReader.readContainerId();
if (containerId != null && !containerId.isEmpty()) {
builder.put(ResourceAttributes.CONTAINER_ID, containerId);
}
builder.put(ResourceAttributes.SERVICE_NAME, agentConfig.getServiceName().getValue());
return builder.build();
return Resource.create(builder.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.resources.ResourceAttributes;
import io.opentelemetry.sdk.trace.ReadWriteSpan;
import io.opentelemetry.sdk.trace.ReadableSpan;
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import org.hypertrace.agent.otel.extensions.CgroupsReader;

public class AddTagsSpanProcessor implements SpanProcessor {
Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ tasks.test {
doFirst {
jvmArgs("-Dsmoketest.javaagent.path=${shadowTask.archiveFile.get()}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.hypertrace.agent.smoketest

import okhttp3.MediaType
import okhttp3.RequestBody
import spock.lang.Ignore

import static org.junit.Assume.assumeTrue

Expand Down Expand Up @@ -358,4 +359,4 @@ abstract class AppServerTest extends SmokeTest {
[serverVersion, jdk]
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import spock.lang.Unroll
class GrpcSmokeTest extends SmokeTest {

protected String getTargetImage(String jdk, String serverVersion) {
"ghcr.io/open-telemetry/java-test-containers:smoke-grpc-jdk$jdk-20210129.520311770"
"ghcr.io/open-telemetry/java-test-containers:smoke-grpc-jdk$jdk-20210218.577304952"
}

@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ class JettySmokeTest extends AppServerTest {
}

def getJettySpanName() {
if (serverVersion == "9.4.35") {
//this need to be present till we sync HT java agent with at least v.0.18.x of OTEL which uniformly returns
//HandlerWrapper.handle
"HandlerCollection.handle"
}
else {
"HandlerList.handle"
}
"HandlerWrapper.handle"
}

@Override
Expand All @@ -39,4 +32,4 @@ class JettySmokeTest extends AppServerTest {
}
return path
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class PropagationTest extends SmokeTest {

@Override
protected String getTargetImage(String jdk, String serverVersion) {
"ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210129.520311771"
"ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210218.577304949"
}

def "Should propagate test"() {
Expand Down Expand Up @@ -78,7 +78,7 @@ class JaegerPropagationTest extends PropagationTest {
class OtTracerPropagationTest extends SmokeTest {
@Override
protected String getTargetImage(String jdk, String serverVersion) {
"ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210129.520311771"
"ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk$jdk-20210218.577304949"
}

// OtTracer only propagates lower half of trace ID so we have to mangle the trace IDs similar to
Expand Down Expand Up @@ -109,7 +109,7 @@ class OtTracerPropagationTest extends SmokeTest {

@Override
protected Map<String, String> getExtraEnv() {
return ["otel.propagators": "ottracer"]
return ["otel.propagators": "ottrace"]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ abstract class SmokeTest extends Specification {
private Backend backend = Backend.getInstance()

@Shared
protected String agentPath = System.getProperty("smoketest.javaagent.path")
// protected String agentPath = "/Users/ploffay/projects/hypertrace/javaagent/javaagent/build/libs/hypertrace-agent-0.10.4-SNAPSHOT-all.jar"// System.getProperty("smoketest.javaagent.path")
protected String agentPath = System.getProperty("smoketest.javaagent.path")

@Shared
protected GenericContainer target
Expand Down Expand Up @@ -84,7 +85,7 @@ abstract class SmokeTest extends Specification {
.withEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector:55680")
.withEnv("HT_SERVICE_NAME", "CIService")
.withEnv("HT_REPORTING_ENDPOINT", "http://collector:9411/api/v2/spans")
.withEnv("OTEL_TRACE_EXPORTER", "otlp")
.withEnv("OTEL_TRACES_EXPORTER", "otlp")
.withImagePullPolicy(PullPolicy.alwaysPull())
.withEnv(extraEnv)
customizeContainer(target)
Expand Down Expand Up @@ -278,4 +279,4 @@ abstract class SmokeTest extends Specification {
network?.close()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SpringBootDiabledAgentSmokeTest extends AbstractSmokeTest {
protected String getTargetImage(int jdk) {
return "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk"
+ jdk
+ "-20210209.550405798";
+ "-20210218.577304949";
}

private GenericContainer app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SpringBootDisabledBodyCaptureSmokeTest extends AbstractSmokeTest {
protected String getTargetImage(int jdk) {
return "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk"
+ jdk
+ "-20210209.550405798";
+ "-20210218.577304949";
}

private GenericContainer app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.hypertrace.agent.smoketest;

import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.sdk.resources.ResourceAttributes;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -35,14 +35,14 @@
// key = "SMOKETEST_JAVAAGENT_PATH",
// value =
//
// "/Users/ploffay/projects/hypertrace/javaagent/javaagent/build/libs/hypertrace-agent-0.3.3-SNAPSHOT-all.jar")
// "/Users/ploffay/projects/hypertrace/javaagent/javaagent/build/libs/hypertrace-agent-0.10.4-SNAPSHOT-all.jar")
public class SpringBootSmokeTest extends AbstractSmokeTest {

@Override
protected String getTargetImage(int jdk) {
return "ghcr.io/open-telemetry/java-test-containers:smoke-springboot-jdk"
+ jdk
+ "-20210209.550405798";
+ "-20210218.577304949";
}

private static GenericContainer app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public void onStart(Context context, ReadWriteSpan readWriteSpan) {
sd.getParentSpanId(),
sd.getInstrumentationLibraryInfo());
synchronized (tracesLock) {
spanOrders.put(
readWriteSpan.getSpanContext().getSpanIdAsHexString(), nextSpanOrder.getAndIncrement());
spanOrders.put(readWriteSpan.getSpanContext().getSpanId(), nextSpanOrder.getAndIncrement());
}
}

Expand Down

0 comments on commit 8e5e87a

Please sign in to comment.