@aws/otel-aws-xray-propagator
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -1,2 +0,2 @@ | ||
import { Context, HttpTextPropagator, SetterFunction, GetterFunction } from '@opentelemetry/api'; | ||
import { Context, TextMapPropagator, TextMapSetter, TextMapGetter } from '@opentelemetry/api'; | ||
export declare const AWSXRAY_TRACE_ID_HEADER = "X-Amzn-Trace-Id"; | ||
@@ -11,5 +11,6 @@ /** | ||
*/ | ||
export declare class AWSXRayPropagator implements HttpTextPropagator { | ||
inject(context: Context, carrier: unknown, setter: SetterFunction): void; | ||
extract(context: Context, carrier: unknown, getter: GetterFunction): Context; | ||
export declare class AWSXRayPropagator implements TextMapPropagator { | ||
inject(context: Context, carrier: unknown, setter: TextMapSetter): void; | ||
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context; | ||
fields(): string[]; | ||
private getSpanContextFromHeader; | ||
@@ -16,0 +17,0 @@ private _parseTraceId; |
@@ -20,3 +20,2 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const core_1 = require("@opentelemetry/core"); | ||
exports.AWSXRAY_TRACE_ID_HEADER = 'X-Amzn-Trace-Id'; | ||
@@ -37,4 +36,2 @@ const TRACE_HEADER_DELIMITER = ';'; | ||
const NOT_SAMPLED = '0'; | ||
const VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i; | ||
const VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i; | ||
/** | ||
@@ -50,4 +47,4 @@ * Implementation of the AWS X-Ray Trace Header propagation protocol. See <a href= | ||
inject(context, carrier, setter) { | ||
const spanContext = core_1.getParentSpanContext(context); | ||
if (!spanContext || !core_1.isValid(spanContext)) | ||
const spanContext = api_1.getParentSpanContext(context); | ||
if (!spanContext || !api_1.isSpanContextValid(spanContext)) | ||
return; | ||
@@ -74,21 +71,24 @@ const otTraceId = spanContext.traceId; | ||
samplingFlag; | ||
setter(carrier, exports.AWSXRAY_TRACE_ID_HEADER, traceHeader); | ||
setter.set(carrier, exports.AWSXRAY_TRACE_ID_HEADER, traceHeader); | ||
} | ||
extract(context, carrier, getter) { | ||
const spanContext = this.getSpanContextFromHeader(carrier, getter); | ||
if (!core_1.isValid(spanContext)) | ||
if (!api_1.isSpanContextValid(spanContext)) | ||
return context; | ||
return core_1.setExtractedSpanContext(context, spanContext); | ||
return api_1.setExtractedSpanContext(context, spanContext); | ||
} | ||
fields() { | ||
return [exports.AWSXRAY_TRACE_ID_HEADER]; | ||
} | ||
getSpanContextFromHeader(carrier, getter) { | ||
const traceHeader = getter(carrier, exports.AWSXRAY_TRACE_ID_HEADER) | ||
? getter(carrier, exports.AWSXRAY_TRACE_ID_HEADER) | ||
: getter(carrier, exports.AWSXRAY_TRACE_ID_HEADER.toLowerCase()); | ||
const traceHeader = getter.get(carrier, exports.AWSXRAY_TRACE_ID_HEADER) | ||
? getter.get(carrier, exports.AWSXRAY_TRACE_ID_HEADER) | ||
: getter.get(carrier, exports.AWSXRAY_TRACE_ID_HEADER.toLowerCase()); | ||
// Only if the returned traceHeader is no empty string can be extracted | ||
if (!traceHeader || typeof traceHeader !== 'string') | ||
return core_1.INVALID_SPAN_CONTEXT; | ||
return api_1.INVALID_SPAN_CONTEXT; | ||
let pos = 0; | ||
let trimmedPart; | ||
let parsedTraceId = api_1.INVALID_TRACE_ID; | ||
let parsedSpanId = api_1.INVALID_SPAN_ID; | ||
let parsedTraceId = api_1.INVALID_TRACEID; | ||
let parsedSpanId = api_1.INVALID_SPANID; | ||
let parsedTraceFlags = null; | ||
@@ -119,3 +119,3 @@ while (pos < traceHeader.length) { | ||
if (parsedTraceFlags === null) { | ||
return core_1.INVALID_SPAN_CONTEXT; | ||
return api_1.INVALID_SPAN_CONTEXT; | ||
} | ||
@@ -128,4 +128,4 @@ const resultSpanContext = { | ||
}; | ||
if (!core_1.isValid(resultSpanContext)) { | ||
return core_1.INVALID_SPAN_CONTEXT; | ||
if (!api_1.isSpanContextValid(resultSpanContext)) { | ||
return api_1.INVALID_SPAN_CONTEXT; | ||
} | ||
@@ -137,7 +137,7 @@ return resultSpanContext; | ||
if (xrayTraceId.length !== TRACE_ID_LENGTH) { | ||
return api_1.INVALID_TRACE_ID; | ||
return api_1.INVALID_TRACEID; | ||
} | ||
// Check version trace id version | ||
if (!xrayTraceId.startsWith(TRACE_ID_VERSION)) { | ||
return api_1.INVALID_TRACE_ID; | ||
return api_1.INVALID_TRACEID; | ||
} | ||
@@ -147,3 +147,3 @@ // Check delimiters | ||
xrayTraceId.charAt(TRACE_ID_DELIMITER_INDEX_2) !== TRACE_ID_DELIMITER) { | ||
return api_1.INVALID_TRACE_ID; | ||
return api_1.INVALID_TRACEID; | ||
} | ||
@@ -154,4 +154,4 @@ const epochPart = xrayTraceId.substring(TRACE_ID_DELIMITER_INDEX_1 + 1, TRACE_ID_DELIMITER_INDEX_2); | ||
// Check the content of trace id | ||
if (!VALID_TRACEID_REGEX.test(resTraceId)) { | ||
return api_1.INVALID_TRACE_ID; | ||
if (!api_1.isValidTraceId(resTraceId)) { | ||
return api_1.INVALID_TRACEID; | ||
} | ||
@@ -161,5 +161,3 @@ return resTraceId; | ||
_parseSpanId(xrayParentId) { | ||
return VALID_SPANID_REGEX.test(xrayParentId) | ||
? xrayParentId | ||
: api_1.INVALID_SPAN_ID; | ||
return api_1.isValidSpanId(xrayParentId) ? xrayParentId : api_1.INVALID_SPANID; | ||
} | ||
@@ -166,0 +164,0 @@ _parseTraceFlag(xraySampledFlag) { |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.12.1"; | ||
export declare const VERSION = "0.12.2"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.12.1'; | ||
exports.VERSION = '0.12.2'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@aws/otel-aws-xray-propagator", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "OpenTelemetry AWS Xray propagator provides HTTP header propagation for systems that are using AWS Xray HTTP header format.", | ||
@@ -74,5 +74,6 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.10.2", | ||
"@opentelemetry/core": "^0.10.2" | ||
"@opentelemetry/context-base": "^0.13.0", | ||
"@opentelemetry/core": "^0.13.0", | ||
"@opentelemetry/api": "^0.13.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31806
3
233
+ Added@opentelemetry/api@0.13.0(transitive)
+ Added@opentelemetry/context-base@0.13.0(transitive)
+ Added@opentelemetry/core@0.13.0(transitive)
- Removed@opentelemetry/api@0.10.2(transitive)
- Removed@opentelemetry/context-base@0.10.2(transitive)
- Removed@opentelemetry/core@0.10.2(transitive)
Updated@opentelemetry/api@^0.13.0
Updated@opentelemetry/core@^0.13.0