mirror of https://github.com/grpc/grpc-java.git
core: Make OpenCensus tags non-propagating. (#5689)
The `method` and `status` shouldn't be propagated in the first place, but in previous OpenCensus implementation all tags are propagating by default. Now with the TagMetadata it may make sense to change them to local tags. This will be a breaking change to users who depend on the behavior that these tags propagate through process boundaries.
This commit is contained in:
parent
d86d3dd363
commit
46f34a513f
|
|
@ -356,7 +356,7 @@ public final class CensusStatsModule {
|
||||||
this.parentCtx = checkNotNull(parentCtx);
|
this.parentCtx = checkNotNull(parentCtx);
|
||||||
TagValue methodTag = TagValue.create(fullMethodName);
|
TagValue methodTag = TagValue.create(fullMethodName);
|
||||||
this.startCtx = module.tagger.toBuilder(parentCtx)
|
this.startCtx = module.tagger.toBuilder(parentCtx)
|
||||||
.putPropagating(DeprecatedCensusConstants.RPC_METHOD, methodTag)
|
.putLocal(DeprecatedCensusConstants.RPC_METHOD, methodTag)
|
||||||
.build();
|
.build();
|
||||||
this.stopwatch = module.stopwatchSupplier.get().start();
|
this.stopwatch = module.stopwatchSupplier.get().start();
|
||||||
if (module.recordStartedRpcs) {
|
if (module.recordStartedRpcs) {
|
||||||
|
|
@ -442,7 +442,7 @@ public final class CensusStatsModule {
|
||||||
module
|
module
|
||||||
.tagger
|
.tagger
|
||||||
.toBuilder(startCtx)
|
.toBuilder(startCtx)
|
||||||
.putPropagating(DeprecatedCensusConstants.RPC_STATUS, statusTag)
|
.putLocal(DeprecatedCensusConstants.RPC_STATUS, statusTag)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -647,7 +647,7 @@ public final class CensusStatsModule {
|
||||||
module
|
module
|
||||||
.tagger
|
.tagger
|
||||||
.toBuilder(parentCtx)
|
.toBuilder(parentCtx)
|
||||||
.putPropagating(DeprecatedCensusConstants.RPC_STATUS, statusTag)
|
.putLocal(DeprecatedCensusConstants.RPC_STATUS, statusTag)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,7 +672,7 @@ public final class CensusStatsModule {
|
||||||
parentCtx =
|
parentCtx =
|
||||||
tagger
|
tagger
|
||||||
.toBuilder(parentCtx)
|
.toBuilder(parentCtx)
|
||||||
.putPropagating(DeprecatedCensusConstants.RPC_METHOD, methodTag)
|
.putLocal(DeprecatedCensusConstants.RPC_METHOD, methodTag)
|
||||||
.build();
|
.build();
|
||||||
return new ServerTracer(CensusStatsModule.this, parentCtx);
|
return new ServerTracer(CensusStatsModule.this, parentCtx);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ public class CensusModulesTest {
|
||||||
Context.ROOT,
|
Context.ROOT,
|
||||||
tagger
|
tagger
|
||||||
.emptyBuilder()
|
.emptyBuilder()
|
||||||
.putPropagating(StatsTestUtils.EXTRA_TAG, TagValue.create("extra value"))
|
.putLocal(StatsTestUtils.EXTRA_TAG, TagValue.create("extra value"))
|
||||||
.build());
|
.build());
|
||||||
ctx = ContextUtils.withValue(ctx, fakeClientParentSpan);
|
ctx = ContextUtils.withValue(ctx, fakeClientParentSpan);
|
||||||
Context origCtx = ctx.attach();
|
Context origCtx = ctx.attach();
|
||||||
|
|
@ -648,7 +648,7 @@ public class CensusModulesTest {
|
||||||
// EXTRA_TAG is propagated by the FakeStatsContextFactory. Note that not all tags are
|
// EXTRA_TAG is propagated by the FakeStatsContextFactory. Note that not all tags are
|
||||||
// propagated. The StatsContextFactory decides which tags are to propagated. gRPC facilitates
|
// propagated. The StatsContextFactory decides which tags are to propagated. gRPC facilitates
|
||||||
// the propagation by putting them in the headers.
|
// the propagation by putting them in the headers.
|
||||||
TagContext clientCtx = tagger.emptyBuilder().putPropagating(
|
TagContext clientCtx = tagger.emptyBuilder().putLocal(
|
||||||
StatsTestUtils.EXTRA_TAG, TagValue.create("extra-tag-value-897")).build();
|
StatsTestUtils.EXTRA_TAG, TagValue.create("extra-tag-value-897")).build();
|
||||||
CensusStatsModule census =
|
CensusStatsModule census =
|
||||||
new CensusStatsModule(
|
new CensusStatsModule(
|
||||||
|
|
@ -689,7 +689,7 @@ public class CensusModulesTest {
|
||||||
// It also put clientCtx in the Context seen by the call handler
|
// It also put clientCtx in the Context seen by the call handler
|
||||||
assertEquals(
|
assertEquals(
|
||||||
tagger.toBuilder(clientCtx)
|
tagger.toBuilder(clientCtx)
|
||||||
.putPropagating(
|
.putLocal(
|
||||||
DeprecatedCensusConstants.RPC_METHOD,
|
DeprecatedCensusConstants.RPC_METHOD,
|
||||||
TagValue.create(method.getFullMethodName()))
|
TagValue.create(method.getFullMethodName()))
|
||||||
.build(),
|
.build(),
|
||||||
|
|
@ -925,7 +925,7 @@ public class CensusModulesTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
tagger
|
tagger
|
||||||
.emptyBuilder()
|
.emptyBuilder()
|
||||||
.putPropagating(
|
.putLocal(
|
||||||
DeprecatedCensusConstants.RPC_METHOD,
|
DeprecatedCensusConstants.RPC_METHOD,
|
||||||
TagValue.create(method.getFullMethodName()))
|
TagValue.create(method.getFullMethodName()))
|
||||||
.build(),
|
.build(),
|
||||||
|
|
|
||||||
|
|
@ -1450,7 +1450,7 @@ public abstract class AbstractInteropTest {
|
||||||
Context.ROOT,
|
Context.ROOT,
|
||||||
tagger
|
tagger
|
||||||
.emptyBuilder()
|
.emptyBuilder()
|
||||||
.putPropagating(StatsTestUtils.EXTRA_TAG, TagValue.create("extra value"))
|
.putLocal(StatsTestUtils.EXTRA_TAG, TagValue.create("extra value"))
|
||||||
.build());
|
.build());
|
||||||
ctx = ContextUtils.withValue(ctx, clientParentSpan);
|
ctx = ContextUtils.withValue(ctx, clientParentSpan);
|
||||||
Context origCtx = ctx.attach();
|
Context origCtx = ctx.attach();
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ public class StatsTestUtils {
|
||||||
String serializedString = new String(bytes, UTF_8);
|
String serializedString = new String(bytes, UTF_8);
|
||||||
if (serializedString.startsWith(EXTRA_TAG_HEADER_VALUE_PREFIX)) {
|
if (serializedString.startsWith(EXTRA_TAG_HEADER_VALUE_PREFIX)) {
|
||||||
return tagger.emptyBuilder()
|
return tagger.emptyBuilder()
|
||||||
.putPropagating(EXTRA_TAG,
|
.putLocal(EXTRA_TAG,
|
||||||
TagValue.create(serializedString.substring(EXTRA_TAG_HEADER_VALUE_PREFIX.length())))
|
TagValue.create(serializedString.substring(EXTRA_TAG_HEADER_VALUE_PREFIX.length())))
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue