Add default implementations for getInstrumentationScopeInfo methods (#4640)

This commit is contained in:
jack-berg 2022-07-27 17:54:29 -05:00 committed by GitHub
parent 467a275825
commit facbf4fb9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 5 deletions

View File

@ -39,6 +39,11 @@ class AllowDefaultMethodRule : AbstractRecordingSeenMembers() {
// semver.
continue
}
if (change == JApiCompatibilityChange.METHOD_ABSTRACT_NOW_DEFAULT) {
// Adding default implementations to interface methods previously abstract is not a breaking
// change.
continue
}
if (!change.isBinaryCompatible) {
return Violation.notBinaryCompatible(member, Severity.error)
}
@ -101,7 +106,8 @@ if (!project.hasProperty("otel.release") && !project.name.startsWith("bom")) {
// Reproduce defaults from https://github.com/melix/japicmp-gradle-plugin/blob/09f52739ef1fccda6b4310cf3f4b19dc97377024/src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java#L130
// only changing the BinaryIncompatibleRule to our custom one that allows new default methods
// on interfaces.
// on interfaces, and adding default implementations to interface methods previously
// abstract.
richReport {
addSetupRule(RecordSeenMembersSetup::class.java)
addRule(JApiChangeStatus.NEW, SourceCompatibleRule::class.java)

View File

@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
**** MODIFIED CLASS: PUBLIC ABSTRACT io.opentelemetry.sdk.testing.trace.TestSpanData (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++* NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.common.InstrumentationScopeInfo getInstrumentationScopeInfo()

View File

@ -1,2 +1,7 @@
Comparing source compatibility of against
No changes.
***! MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.trace.data.SpanData (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
***! MODIFIED METHOD: PUBLIC NON_ABSTRACT (<- ABSTRACT) io.opentelemetry.sdk.common.InstrumentationScopeInfo getInstrumentationScopeInfo()
***! MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.trace.ReadableSpan (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
***! MODIFIED METHOD: PUBLIC NON_ABSTRACT (<- ABSTRACT) io.opentelemetry.sdk.common.InstrumentationScopeInfo getInstrumentationScopeInfo()

View File

@ -63,6 +63,9 @@ public abstract class TestSpanData implements SpanData {
return InstrumentationScopeUtil.toInstrumentationLibraryInfo(getInstrumentationScopeInfo());
}
@Override
public abstract InstrumentationScopeInfo getInstrumentationScopeInfo();
/** A {@code Builder} class for {@link TestSpanData}. */
@AutoValue.Builder
public abstract static class Builder {

View File

@ -10,6 +10,7 @@ import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.internal.InstrumentationScopeUtil;
import io.opentelemetry.sdk.trace.data.SpanData;
import javax.annotation.Nullable;
@ -68,7 +69,9 @@ public interface ReadableSpan {
*
* @return an instance of {@link InstrumentationScopeInfo} describing the instrumentation scope
*/
InstrumentationScopeInfo getInstrumentationScopeInfo();
default InstrumentationScopeInfo getInstrumentationScopeInfo() {
return InstrumentationScopeUtil.toInstrumentationScopeInfo(getInstrumentationLibraryInfo());
}
/**
* Returns whether this Span has already been ended.

View File

@ -9,6 +9,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.internal.InstrumentationScopeUtil;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SpanLimits;
import java.util.List;
@ -165,7 +166,9 @@ public interface SpanData {
*
* @return an instance of {@link InstrumentationScopeInfo}
*/
InstrumentationScopeInfo getInstrumentationScopeInfo();
default InstrumentationScopeInfo getInstrumentationScopeInfo() {
return InstrumentationScopeUtil.toInstrumentationScopeInfo(getInstrumentationLibraryInfo());
}
/**
* Returns the resource of this {@code Span}.