Skip to content

Commit

Permalink
Mark instrumentation version nullable in MeterProvider and TracerProv…
Browse files Browse the repository at this point in the history
…ider

The spec dictates this to be optional, and the implementations treat it as nullable already.
  • Loading branch information
MariusVolkhart committed Nov 1, 2020
1 parent 7f4b5a0 commit 4b28eaf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/src/main/java/io/opentelemetry/api/OpenTelemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.context.propagation.ContextPropagators;
import javax.annotation.Nullable;

/**
* The entrypoint to telemetry functionality for tracing, metrics and baggage.
Expand Down Expand Up @@ -169,7 +170,7 @@ default Tracer getTracer(String instrumentationName) {
* "semver:1.0.0").
* @return a tracer instance.
*/
default Tracer getTracer(String instrumentationName, String instrumentationVersion) {
default Tracer getTracer(String instrumentationName, @Nullable String instrumentationVersion) {
return getGlobalTracerProvider().get(instrumentationName, instrumentationVersion);
}

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

package io.opentelemetry.api.metrics;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

@ThreadSafe
Expand All @@ -22,7 +23,7 @@ public Meter get(String instrumentationName) {
}

@Override
public Meter get(String instrumentationName, String instrumentationVersion) {
public Meter get(String instrumentationName, @Nullable String instrumentationVersion) {
return Meter.getDefault();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.api.metrics;

import io.opentelemetry.api.OpenTelemetry;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -43,5 +44,5 @@ static MeterProvider getDefault() {
* @param instrumentationVersion The version of the instrumentation library.
* @return a tracer instance.
*/
Meter get(String instrumentationName, String instrumentationVersion);
Meter get(String instrumentationName, @Nullable String instrumentationVersion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.api.trace;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

@ThreadSafe
Expand All @@ -22,7 +23,7 @@ public Tracer get(String instrumentationName) {
}

@Override
public Tracer get(String instrumentationName, String instrumentationVersion) {
public Tracer get(String instrumentationName, @Nullable String instrumentationVersion) {
return Tracer.getDefault();
}

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

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.spi.TracerProviderFactory;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -45,5 +46,5 @@ static TracerProvider getDefault() {
* "semver:1.0.0").
* @return a tracer instance.
*/
Tracer get(String instrumentationName, String instrumentationVersion);
Tracer get(String instrumentationName, @Nullable String instrumentationVersion);
}
6 changes: 3 additions & 3 deletions api/src/test/java/io/opentelemetry/api/OpenTelemetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public Tracer get(String instrumentationName) {
}

@Override
public Tracer get(String instrumentationName, String instrumentationVersion) {
public Tracer get(String instrumentationName, @Nullable String instrumentationVersion) {
return get(instrumentationName);
}

Expand All @@ -230,7 +230,7 @@ public Meter get(String instrumentationName) {
}

@Override
public Meter get(String instrumentationName, String instrumentationVersion) {
public Meter get(String instrumentationName, @Nullable String instrumentationVersion) {
return get(instrumentationName);
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public Meter get(String instrumentationName) {
}

@Override
public Meter get(String instrumentationName, String instrumentationVersion) {
public Meter get(String instrumentationName, @Nullable String instrumentationVersion) {
return get(instrumentationName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public Tracer get(String instrumentationName) {
}

@Override
public Tracer get(String instrumentationName, String instrumentationVersion) {
public Tracer get(String instrumentationName, @Nullable String instrumentationVersion) {
return delegate.get(instrumentationName, instrumentationVersion);
}

Expand Down

0 comments on commit 4b28eaf

Please sign in to comment.