Skip to content

Commit

Permalink
Bump to OTEL 0.10.0 (#120)
Browse files Browse the repository at this point in the history
* Bump to OTEL 0.10.0

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

* fully working

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

* Cleanup

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

* Fix

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay authored Nov 17, 2020
1 parent f301e05 commit 312d34e
Show file tree
Hide file tree
Showing 45 changed files with 136 additions and 186 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/groovy/MuzzlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MuzzlePlugin implements Plugin<Project> {
println "Muzzle executing for $project"
}
}
def printReferences = project.task('printReferences') {
def printReferences = project.task('printMuzzleReferences') {
group = 'Muzzle'
description = "Print references created by instrumentation muzzle"
doLast {
Expand All @@ -101,7 +101,7 @@ class MuzzlePlugin implements Plugin<Project> {
}
}
project.tasks.muzzle.dependsOn(project.tasks.compileMuzzle)
project.tasks.printReferences.dependsOn(project.tasks.compileMuzzle)
project.tasks.printMuzzleReferences.dependsOn(project.tasks.compileMuzzle)

def hasRelevantTask = project.gradle.startParameter.taskNames.any { taskName ->
// removing leading ':' if present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,8 @@ public class AutoInstrumentationPlugin implements Plugin<Project> {
static {
String[] testBS = {
"io.opentelemetry.instrumentation.api",
"io.opentelemetry.OpenTelemetry", // OpenTelemetry API
"io.opentelemetry.common", // OpenTelemetry API
"io.opentelemetry.baggage", // OpenTelemetry API
"io.opentelemetry.context", // OpenTelemetry API (context prop)
"io.opentelemetry.internal", // OpenTelemetry API
"io.opentelemetry.metrics", // OpenTelemetry API
"io.opentelemetry.trace", // OpenTelemetry API
"io.grpc.Context", // OpenTelemetry API dependency
"io.grpc.Deadline", // OpenTelemetry API dependency
"io.grpc.PersistentHashArrayMappedTrie", // OpenTelemetry API dependency
"io.grpc.ThreadLocalContextStorage", // OpenTelemetry API dependency
"io.opentelemetry.api", // OpenTelemetry API
"io.opentelemetry.context", // OpenTelemetry API
"org.slf4j",
"ch.qos.logback",
// Tomcat's servlet classes must be on boostrap
Expand All @@ -77,8 +68,6 @@ public class AutoInstrumentationPlugin implements Plugin<Project> {
}
}

private static final String[] NOT_BOOTSTRAP_PREFIXES = {"io/grpc/Contexts"};

@Override
public void apply(Project project) {
project.getPlugins().apply(JavaLibraryPlugin.class);
Expand Down Expand Up @@ -163,11 +152,6 @@ public Iterable<String> asArguments() {
}

private static boolean isBootstrapClass(String filePath) {
for (String notBootstrapName : NOT_BOOTSTRAP_PREFIXES) {
if (filePath.startsWith(notBootstrapName)) {
return false;
}
}
for (String testBootstrapPrefix : TEST_BOOTSTRAP_PREFIXES) {
if (filePath.startsWith(testBootstrapPrefix)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion filter-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
api("io.opentelemetry:opentelemetry-api:0.9.1")
api("io.opentelemetry:opentelemetry-api:0.10.0")
api(project(":javaagent-core"))
implementation("com.google.auto.service:auto-service:1.0-rc7")
annotationProcessor("com.google.auto.service:auto-service:1.0-rc7")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.hypertrace.agent.filter;

import io.opentelemetry.trace.Span;
import io.opentelemetry.api.trace.Span;
import java.util.List;
import java.util.Map;
import org.hypertrace.agent.filter.api.ExecutionBlocked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.hypertrace.agent.filter.api;

import io.opentelemetry.trace.Span;
import io.opentelemetry.api.trace.Span;
import java.util.Map;
import org.hypertrace.agent.filter.FilterRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.hypertrace.agent.filter.mock;

import io.opentelemetry.trace.Span;
import io.opentelemetry.api.trace.Span;
import java.util.Map;
import org.hypertrace.agent.filter.api.ExecutionBlocked;
import org.hypertrace.agent.filter.api.ExecutionNotBlocked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.hypertrace.agent.filter.opa.custom;

import com.google.auto.service.AutoService;
import io.opentelemetry.api.trace.Span;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -86,8 +87,7 @@ public void run() {
// }

@Override
public FilterResult evaluateRequestHeaders(
io.opentelemetry.trace.Span span, Map<String, String> headers) {
public FilterResult evaluateRequestHeaders(Span span, Map<String, String> headers) {
// currently as per policy.rego, allowed list has precedence over denylist
boolean allow =
policyEvaluators.stream()
Expand All @@ -99,7 +99,7 @@ public FilterResult evaluateRequestHeaders(
}

@Override
public FilterResult evaluateRequestBody(io.opentelemetry.trace.Span span, String body) {
public FilterResult evaluateRequestBody(Span span, String body) {
return ExecutionNotBlocked.INSTANCE;
}
}
23 changes: 6 additions & 17 deletions instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ subprojects {
annotationProcessor("com.google.auto.service:auto-service:1.0-rc7")
implementation("net.bytebuddy:byte-buddy:1.10.10")

implementation("io.opentelemetry:opentelemetry-api:0.9.1")
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:0.9.0")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:0.9.0")
implementation("io.opentelemetry:opentelemetry-api:0.10.0")
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:0.10.1")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:0.10.1")
implementation(project(":javaagent-core"))
implementation(project(":filter-api"))
}
Expand Down Expand Up @@ -55,32 +55,21 @@ tasks {

exclude("**/module-info.class")

// Prevents conflict with other SLF4J instances. Important for premain.
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")
// rewrite dependencies calling Logger.getLogger
relocate("java.util.logging.Logger", "io.opentelemetry.javaagent.bootstrap.PatchLogger")

// prevents conflict with library instrumentation
relocate("io.opentelemetry.instrumentation.api", "io.opentelemetry.javaagent.shaded.instrumentation.api")
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")

// relocate OpenTelemetry API
relocate("io.opentelemetry.OpenTelemetry", "io.opentelemetry.javaagent.shaded.io.opentelemetry.OpenTelemetry")
relocate("io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common")
relocate("io.opentelemetry.baggage", "io.opentelemetry.javaagent.shaded.io.opentelemetry.baggage")
relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.internal", "io.opentelemetry.javaagent.shaded.io.opentelemetry.internal")
relocate("io.opentelemetry.metrics", "io.opentelemetry.javaagent.shaded.io.opentelemetry.metrics")
relocate("io.opentelemetry.trace", "io.opentelemetry.javaagent.shaded.io.opentelemetry.trace")

relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")

//opentelemetry rewrite library instrumentation dependencies
relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation") {
exclude("io.opentelemetry.instrumentation.auto.**")
exclude("io.opentelemetry.javaagent.instrumentation.**")
exclude("io.opentelemetry.instrumentation.hypertrace.**")
}

// relocate OpenTelemetry API dependency
relocate("io.grpc", "io.opentelemetry.javaagent.shaded.io.grpc")
}
}
4 changes: 2 additions & 2 deletions instrumentation/grpc-1.5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protobuf {
}

dependencies {
api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.5:0.9.0")
api("io.opentelemetry.instrumentation:opentelemetry-grpc-1.5:0.9.0")
api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.5:0.10.1")
api("io.opentelemetry.instrumentation:opentelemetry-grpc-1.5:0.10.1")

compileOnly("io.grpc:grpc-core:1.5.0")
compileOnly("io.grpc:grpc-protobuf:1.5.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.google.protobuf.util.JsonFormat;
import io.grpc.Metadata;
import io.grpc.Metadata.Key;
import io.opentelemetry.common.AttributeKey;
import io.opentelemetry.trace.Span;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ public int getOrder() {
@Override
public String[] helperClassNames() {
return new String[] {
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcTracer",
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcSpanDecorator",
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.InstrumentationName",
packageName + ".GrpcClientInterceptor"
packageName + ".GrpcClientInterceptor",
packageName + ".GrpcClientInterceptor$TracingClientCall",
packageName + ".GrpcClientInterceptor$TracingClientCallListener"
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@
import io.grpc.ForwardingClientCallListener;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcSpanDecorator;
import io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.InstrumentationName;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import org.hypertrace.agent.core.HypertraceConfig;
import org.hypertrace.agent.core.HypertraceSemanticAttributes;

public class GrpcClientInterceptor implements ClientInterceptor {

private static final Tracer TRACER = OpenTelemetry.getTracer("org.hypertrace.agent.grpc");

@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
if (!HypertraceConfig.isInstrumentationEnabled(InstrumentationName.INSTRUMENTATION_NAME)) {
return next.newCall(method, callOptions);
}

Span currentSpan = TRACER.getCurrentSpan();
Span currentSpan = Span.current();
ClientCall<ReqT, RespT> clientCall = next.newCall(method, callOptions);
return new GrpcClientInterceptor.TracingClientCall<>(clientCall, currentSpan);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public int getOrder() {
@Override
public String[] helperClassNames() {
return new String[] {
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcTracer",
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcSpanDecorator",
"io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.InstrumentationName",
packageName + ".GrpcServerInterceptor",
packageName + ".GrpcServerInterceptor$TracingServerCall",
packageName + ".GrpcServerInterceptor$TracingServerCallListener",
packageName + ".NoopServerCallListener"
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.Status;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcSpanDecorator;
import io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.InstrumentationName;
import io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.server.GrpcServerInterceptor.TracingServerCall.TracingServerCallListener;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import java.util.Map;
import org.hypertrace.agent.core.HypertraceConfig;
import org.hypertrace.agent.core.HypertraceSemanticAttributes;
Expand All @@ -38,16 +35,14 @@

public class GrpcServerInterceptor implements ServerInterceptor {

private static final Tracer TRACER = OpenTelemetry.getTracer("org.hypertrace.agent.grpc");

@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
if (!HypertraceConfig.isInstrumentationEnabled(InstrumentationName.INSTRUMENTATION_NAME)) {
return next.startCall(call, headers);
}

Span currentSpan = TRACER.getCurrentSpan();
Span currentSpan = Span.current();

Map<String, String> mapHeaders = GrpcSpanDecorator.metadataToMap(headers);

Expand Down Expand Up @@ -96,24 +91,24 @@ public void sendHeaders(Metadata headers) {
headers, span, HypertraceSemanticAttributes::rpcResponseMetadata);
}
}
}

static final class TracingServerCallListener<ReqT>
extends ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT> {
static final class TracingServerCallListener<ReqT>
extends ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT> {

private final Span span;
private final Span span;

TracingServerCallListener(Listener<ReqT> delegate, Span span) {
super(delegate);
this.span = span;
}
TracingServerCallListener(Listener<ReqT> delegate, Span span) {
super(delegate);
this.span = span;
}

@Override
public void onMessage(ReqT message) {
delegate().onMessage(message);
if (HypertraceConfig.get().getDataCapture().getRpcBody().getRequest().getValue()) {
GrpcSpanDecorator.addMessageAttribute(
message, span, HypertraceSemanticAttributes.RPC_REQUEST_BODY);
}
@Override
public void onMessage(ReqT message) {
delegate().onMessage(message);
if (HypertraceConfig.get().getDataCapture().getRpcBody().getRequest().getValue()) {
GrpcSpanDecorator.addMessageAttribute(
message, span, HypertraceSemanticAttributes.RPC_REQUEST_BODY);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void serverRequestBlocking() throws TimeoutException, InterruptedExceptio

@Test
public void disabledInstrumentation_dynamicConfig()
throws TimeoutException, InterruptedException, IOException {
throws TimeoutException, InterruptedException {
URL configUrl = getClass().getClassLoader().getResource("ht-config-all-disabled.yaml");
System.setProperty(EnvironmentConfig.CONFIG_FILE_PROPERTY, configUrl.getPath());
HypertraceConfig.reset();
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/okhttp/okhttp-3.0/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ afterEvaluate{
}

dependencies {
api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-okhttp-3.0:0.9.0")
api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-okhttp-3.0:0.10.1")

compileOnly("com.squareup.okhttp3:okhttp:3.0.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

package io.opentelemetry.instrumentation.hypertrace.okhttp.v3_0;

import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.common.AttributeKey;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import java.io.IOException;
import java.util.function.Function;
import okhttp3.Headers;
Expand All @@ -39,15 +37,13 @@
public class OkHttpTracingInterceptor implements Interceptor {
private static final Logger log = LoggerFactory.getLogger(OkHttpTracingInterceptor.class);

private static final Tracer TRACER = OpenTelemetry.getTracer("org.hypertrace.agent.okhttp");

@Override
public Response intercept(Chain chain) throws IOException {
if (!HypertraceConfig.isInstrumentationEnabled(InstrumentationName.INSTRUMENTATION_NAME)) {
return chain.proceed(chain.request());
}

Span span = TRACER.getCurrentSpan();
Span span = Span.current();

Request request = chain.request();
if (HypertraceConfig.get().getDataCapture().getHttpHeaders().getRequest().getValue()) {
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/servlet/servlet-2.3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ afterEvaluate{
dependencies {
api(project(":instrumentation:servlet:servlet-common"))

api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-2.2:0.9.0")
api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-2.2:0.10.1")

compileOnly("javax.servlet:servlet-api:2.3")

Expand Down
Loading

0 comments on commit 312d34e

Please sign in to comment.