Skip to content

Commit

Permalink
Update to OTel 0.14.1 (#2059)
Browse files Browse the repository at this point in the history
* Update SDK dependency to 0.14.1

* WIP

* Finish

* Cleanup
  • Loading branch information
Anuraag Agrawal authored Jan 18, 2021
1 parent c16967d commit afdde03
Show file tree
Hide file tree
Showing 243 changed files with 640 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

package io.opentelemetry.perftest;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
import java.util.concurrent.TimeUnit;

public class Worker {

private static final Tracer tracer = OpenTelemetry.getGlobalTracer("io.opentelemetry.auto");
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("io.opentelemetry.auto");

/** Simulate work for the give number of milliseconds. */
public static void doWork(long workTimeMillis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.perftest.jetty;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
Expand All @@ -25,7 +25,7 @@ public class JettyPerftest {
private static final Server jettyServer = new Server(PORT);
private static final ServletContextHandler servletContext = new ServletContextHandler();

private static final Tracer tracer = OpenTelemetry.getGlobalTracer("io.opentelemetry.auto");
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("io.opentelemetry.auto");

public static void main(String[] args) throws Exception {
servletContext.addServlet(PerfServlet.class, PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

package io.opentelemetry.benchmark.classes;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Tracer;

public class TracedClass extends UntracedClass {
private static final Tracer tracer = OpenTelemetry.getGlobalTracer("io.opentelemetry.auto");
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("io.opentelemetry.auto");

@Override
public void f() {
Expand Down
8 changes: 5 additions & 3 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ configurations.all {

ext {
versions = [
opentelemetry : '0.13.1',
opentelemetryAlpha: "0.13.1-alpha",
opentelemetry : '0.14.1',
opentelemetryAlpha: "0.14.1-alpha",

slf4j : "1.7.30",
guava : "20.0", // Last version to support Java 7
Expand All @@ -35,6 +35,7 @@ ext {
deps = [
// OpenTelemetry
opentelemetryApi : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api', version: versions.opentelemetry),
opentelemetryApiMetrics : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-api-metrics', version: versions.opentelemetryAlpha),
opentelemetryExtAnnotations: dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-annotations', version: versions.opentelemetry),
opentelemetryContext : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-context', version: versions.opentelemetry),
opentelemetryKotlin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-extension-kotlin', version: versions.opentelemetry),
Expand All @@ -46,11 +47,12 @@ ext {
opentelemetryOtlp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp', version: versions.opentelemetry),
opentelemetryOtlpMetrics : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-otlp-metrics', version: versions.opentelemetryAlpha),
opentelemetryZipkin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-zipkin', version: versions.opentelemetry),
opentelemetryPrometheus : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-prometheus', version: versions.opentelemetry),
opentelemetryPrometheus : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-prometheus', version: versions.opentelemetryAlpha),
opentelemetryLogging : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporter-logging', version: versions.opentelemetry),
opentelemetryProto : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-proto', version: versions.opentelemetry),
opentelemetryResources : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-extension-resources', version: versions.opentelemetry),
opentelemetrySdkTesting : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-testing', version: versions.opentelemetry),
opentelemetrySemConv : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-semconv', version: versions.opentelemetry),

// General
slf4j : "org.slf4j:slf4j-api:${versions.slf4j}",
Expand Down
1 change: 1 addition & 0 deletions gradle/instrumentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ shadowJar {

// relocate OpenTelemetry API usage
relocate "io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api"
relocate "io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv"
relocate "io.opentelemetry.spi", "io.opentelemetry.javaagent.shaded.io.opentelemetry.spi"
relocate "io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context"

Expand Down
1 change: 1 addition & 0 deletions instrumentation-api/instrumentation-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ apply from: "$rootDir/gradle/publish.gradle"
dependencies {
api deps.opentelemetryApi
api deps.opentelemetryContext
api deps.opentelemetrySemConv
implementation deps.slf4j

compileOnly deps.autoValueAnnotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

package io.opentelemetry.instrumentation.api.tracer;

import static io.opentelemetry.api.OpenTelemetry.getGlobalPropagators;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Span.Kind;
import io.opentelemetry.api.trace.StatusCode;
Expand Down Expand Up @@ -46,7 +44,7 @@ public abstract class BaseTracer {
protected final Tracer tracer;

public BaseTracer() {
tracer = OpenTelemetry.getGlobalTracer(getInstrumentationName(), getVersion());
tracer = GlobalOpenTelemetry.getTracer(getInstrumentationName(), getVersion());
}

public BaseTracer(Tracer tracer) {
Expand Down Expand Up @@ -173,7 +171,9 @@ public static <C> Context extract(C carrier, TextMapPropagator.Getter<C> getter)
// Using Context.ROOT here may be quite unexpected, but the reason is simple.
// We want either span context extracted from the carrier or invalid one.
// We DO NOT want any span context potentially lingering in the current context.
return getGlobalPropagators().getTextMapPropagator().extract(Context.root(), carrier, getter);
return GlobalOpenTelemetry.getPropagators()
.getTextMapPropagator()
.extract(Context.root(), carrier, getter);
}

private static void debugContextLeak() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import static io.opentelemetry.api.trace.Span.Kind.CLIENT;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.tracer.utils.NetPeerUtils;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;

Expand All @@ -24,7 +24,7 @@ public abstract class DatabaseClientTracer<CONNECTION, QUERY> extends BaseTracer
protected final Tracer tracer;

public DatabaseClientTracer() {
tracer = OpenTelemetry.getGlobalTracer(getInstrumentationName(), getVersion());
tracer = GlobalOpenTelemetry.getTracer(getInstrumentationName(), getVersion());
}

public boolean shouldStartSpan(Context parentContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

package io.opentelemetry.instrumentation.api.tracer;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Span.Kind;
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import io.opentelemetry.instrumentation.api.tracer.utils.NetPeerUtils;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -82,7 +82,7 @@ private void inject(Context context, CARRIER carrier) {
throw new IllegalStateException(
"getSetter() not defined but calling startScope(), either getSetter must be implemented or the scope should be setup manually");
}
OpenTelemetry.getGlobalPropagators().getTextMapPropagator().inject(context, carrier, setter);
GlobalOpenTelemetry.getPropagators().getTextMapPropagator().inject(context, carrier, setter);
}

public void end(Context context, RESPONSE response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.instrumentation.api.tracer

import io.opentelemetry.api.trace.Span
import io.opentelemetry.api.trace.attributes.SemanticAttributes
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.context.propagation.TextMapPropagator
import io.opentelemetry.instrumentation.api.config.Config
import io.opentelemetry.instrumentation.api.config.ConfigBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.instrumentation.api.tracer.utils

import io.opentelemetry.api.trace.attributes.SemanticAttributes
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.instrumentation.api.config.Config
import io.opentelemetry.instrumentation.api.config.ConfigBuilder
import io.opentelemetry.instrumentation.api.tracer.BaseTracerTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package io.opentelemetry.instrumentation.reactor

import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan

import io.opentelemetry.api.GlobalOpenTelemetry
import io.opentelemetry.api.OpenTelemetry
import io.opentelemetry.api.trace.Tracer
import io.opentelemetry.context.Context
Expand All @@ -25,7 +26,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {
public static final String EXCEPTION_MESSAGE = "test exception"

private static final Tracer testTracer =
OpenTelemetry.getGlobalTracer("io.opentelemetry.auto.reactor")
GlobalOpenTelemetry.getTracer("io.opentelemetry.auto.reactor")

def setupSpec() {
TracingOperator.registerOnEachOperator()
Expand Down Expand Up @@ -234,7 +235,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {
// The "add one" operations in the publisher created here should be children of the publisher-parent
Publisher<Integer> publisher = publisherSupplier()

def tracer = OpenTelemetry.getGlobalTracer("test")
def tracer = GlobalOpenTelemetry.getTracer("test")
def intermediate = tracer.spanBuilder("intermediate").startSpan()
// After this activation, the "add two" operations below should be children of this span
def scope = Context.current().with(intermediate).makeCurrent()
Expand Down Expand Up @@ -273,7 +274,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {

def runUnderTrace(def publisherSupplier) {
TraceUtils.runUnderTrace("trace-parent") {
def tracer = OpenTelemetry.getGlobalTracer("test")
def tracer = GlobalOpenTelemetry.getTracer("test")
def span = tracer.spanBuilder("publisher-parent").startSpan()
def scope = Context.current().with(span).makeCurrent()
try {
Expand All @@ -295,7 +296,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {

def cancelUnderTrace(def publisherSupplier) {
TraceUtils.runUnderTrace("trace-parent") {
def tracer = OpenTelemetry.getGlobalTracer("test")
def tracer = GlobalOpenTelemetry.getTracer("test")
def span = tracer.spanBuilder("publisher-parent").startSpan()
def scope = Context.current().with(span).makeCurrent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
package io.opentelemetry.instrumentation.servlet;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath;
import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.Principal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/

import akka.dispatch.forkjoin.ForkJoinTask;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Tracer;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;

public class AkkaAsyncChild extends ForkJoinTask implements Runnable, Callable {
private static final Tracer tracer = OpenTelemetry.getGlobalTracer("io.opentelemetry.auto");
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("io.opentelemetry.auto");

private final AtomicBoolean blockThread;
private final boolean doTraceableWork;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.apachecamel;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
Expand All @@ -16,13 +16,13 @@ final class CamelPropagationUtil {
private CamelPropagationUtil() {}

static Context extractParent(final Map<String, Object> exchangeHeaders) {
return OpenTelemetry.getGlobalPropagators()
return GlobalOpenTelemetry.getPropagators()
.getTextMapPropagator()
.extract(Context.current(), exchangeHeaders, MapGetter.INSTANCE);
}

static void injectParent(Context context, final Map<String, Object> exchangeHeaders) {
OpenTelemetry.getGlobalPropagators()
GlobalOpenTelemetry.getPropagators()
.getTextMapPropagator()
.inject(context, exchangeHeaders, MapSetter.INSTANCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.URI;
import java.util.Map;
import org.apache.camel.Endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;

import io.opentelemetry.api.trace.attributes.SemanticAttributes.DbSystemValues;
import io.opentelemetry.javaagent.instrumentation.apachecamel.SpanDecorator;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValues;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.tracer.BaseTracer;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.camel.Endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Map;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Span.Kind;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.URI;
import java.util.Map;
import org.apache.camel.Endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import static io.opentelemetry.api.trace.Span.Kind.INTERNAL
import static io.opentelemetry.api.trace.Span.Kind.SERVER

import com.google.common.collect.ImmutableMap
import io.opentelemetry.api.trace.attributes.SemanticAttributes
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.instrumentation.test.AgentTestRunner
import io.opentelemetry.instrumentation.test.utils.PortUtils
import org.apache.camel.CamelContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package test
import static io.opentelemetry.api.trace.Span.Kind.SERVER

import com.google.common.collect.ImmutableMap
import io.opentelemetry.api.trace.attributes.SemanticAttributes
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.instrumentation.test.AgentTestRunner
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
import io.opentelemetry.instrumentation.test.utils.PortUtils
Expand Down
Loading

0 comments on commit afdde03

Please sign in to comment.