From a8f5a44e5cae265e215996fa3e86f6ca26c32a2e Mon Sep 17 00:00:00 2001 From: Won Jun Jang Date: Mon, 21 Aug 2017 12:04:00 -0400 Subject: [PATCH] code review --- src/_flow/baggage_restriction_manager.js | 2 +- src/baggage/baggage_setter.js | 2 +- src/baggage/default_baggage_restriction_manager.js | 2 +- src/span.js | 4 ++++ src/tracer.js | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/_flow/baggage_restriction_manager.js b/src/_flow/baggage_restriction_manager.js index 42196cb30..016a55c2c 100644 --- a/src/_flow/baggage_restriction_manager.js +++ b/src/_flow/baggage_restriction_manager.js @@ -28,5 +28,5 @@ import Restriction from '../baggage/restriction.js' * allowed and any other applicable restrictions on the baggage value. */ declare interface BaggageRestrictionManager { - getRestriction(key: string): Restriction; + getRestriction(service: string, key: string): Restriction; } diff --git a/src/baggage/baggage_setter.js b/src/baggage/baggage_setter.js index b74e8db64..dc45a87aa 100644 --- a/src/baggage/baggage_setter.js +++ b/src/baggage/baggage_setter.js @@ -49,7 +49,7 @@ export default class BaggageSetter { let value = baggageValue; let truncated = false; let prevItem = ''; - let restriction = this._restrictionManager.getRestriction(key); + let restriction = this._restrictionManager.getRestriction(span.serviceName, key); if (!restriction.keyAllowed) { this._logFields(span, key, value, prevItem, truncated, restriction.keyAllowed); this._metrics.baggageUpdateFailure.increment(1); diff --git a/src/baggage/default_baggage_restriction_manager.js b/src/baggage/default_baggage_restriction_manager.js index 58667b14f..9100a1652 100644 --- a/src/baggage/default_baggage_restriction_manager.js +++ b/src/baggage/default_baggage_restriction_manager.js @@ -34,7 +34,7 @@ export default class DefaultBaggageRestrictionManager { this._restriction = new Restriction(true, length); } - getRestriction(key: string): Restriction { + getRestriction(service: string, key: string): Restriction { return this._restriction; } } diff --git a/src/span.js b/src/span.js index 211959f23..f9546d10f 100644 --- a/src/span.js +++ b/src/span.js @@ -59,6 +59,10 @@ export default class Span { return this._operationName; } + get serviceName(): string { + return this._tracer._serviceName; + } + static _getBaggageHeaderCache() { if (!Span._baggageHeaderCache) { Span._baggageHeaderCache = {}; diff --git a/src/tracer.js b/src/tracer.js index 46cee4e40..ba5c8fcd3 100644 --- a/src/tracer.js +++ b/src/tracer.js @@ -75,7 +75,8 @@ export default class Tracer { this._reporter = reporter; this._sampler = sampler; this._logger = options.logger || new NullLogger(); - this._baggageSetter = new BaggageSetter(options.baggageRestrictionManager || new DefaultBaggageRestrictionManager(), + this._baggageSetter = new BaggageSetter( + options.baggageRestrictionManager || new DefaultBaggageRestrictionManager(), this._metrics); this._injectors = {}; this._extractors = {};