Skip to content

Commit 16d5f44

Browse files
NPelletblumamirdyladan
authored andcommitted
feat(propagator/aws-xray): Extract X-Ray header in a case-insensitive fashion (#1328)
* Extract X-Ray header in a case-insensitive fashion * Back to apostrophes * Switch to 1 tab = 2 spaces * Add semis * Apply prettier to tests as well * chore: fix lint --------- Co-authored-by: Amir Blum <[email protected]> Co-authored-by: Daniel Dyla <[email protected]>
1 parent cc67637 commit 16d5f44

File tree

5 files changed

+68
-15
lines changed

5 files changed

+68
-15
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## [1.3.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.3.0...propagator-aws-xray-v1.3.1) (2023-08-14)
4+
5+
6+
### Bug Fixes
7+
8+
* Revert "feat(minification): Add importHelpers and tslib as a dependency ([#1545](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1545))" ([#1611](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1611)) ([e5bca5f](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/e5bca5fe5b27adc59c8de8fe4087d38b69d93bd4))
9+
10+
## [1.3.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.2.1...propagator-aws-xray-v1.3.0) (2023-07-12)
11+
12+
13+
### Features
14+
15+
* **minification:** Add importHelpers and tslib as a dependency ([#1545](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1545)) ([65f612e](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/65f612e35c4d67b9935dc3a9155588b35d915482))
16+
17+
## [1.2.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.2.0...propagator-aws-xray-v1.2.1) (2023-05-16)
18+
19+
20+
### Bug Fixes
21+
22+
* **eslint-config:** replace gts with prettier and eslint ([#1439](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1439)) ([2571c37](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/2571c371be1b5738442200cab2415b6a04c32aab))
23+
24+
## [1.2.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.1.1...propagator-aws-xray-v1.2.0) (2023-02-07)
25+
26+
27+
### Features
28+
29+
* **propagator/aws-xray:** Extract X-Ray header in a case-insensitive fashion ([#1328](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1328)) ([4227d8a](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/4227d8a3df7b0782d76844e89d452e0432a704f4))
30+
331
## [1.1.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/propagator-aws-xray-v1.1.0...propagator-aws-xray-v1.1.1) (2022-11-02)
432

533

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
[![NPM Published Version][npm-img]][npm-url]
44
[![Apache License][license-image]][license-image]
55

6-
[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @willarmiros
7-
86
The OpenTelemetry Propagator for AWS X-Ray provides HTTP header propagation for systems that are using AWS `X-Amzn-Trace-Id` format.
97
This propagator translates the OpenTelemetry SpanContext into the equivalent AWS header format, for use with the OpenTelemetry JS SDK.
108
`TraceState` is currently not propagated.
119

12-
Compatible with OpenTelemetry JS API and SDK `1.0+`.
10+
## Status
11+
12+
| Maturity | [Component Owner](../../.github/component_owners.yml) | Compatibility |
13+
| ----------------------------------------- | ----------------------------------------------------- | --------------------- |
14+
| [Stable](../../../CONTRIBUTING.md#stable) | @carolabadeer | API 1.0+<br/>SDK 1.0+ |
1315

1416
## Installation
1517

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentelemetry/propagator-aws-xray",
3-
"version": "1.1.1",
3+
"version": "1.3.1",
44
"description": "OpenTelemetry AWS Xray propagator provides context propagation for systems that are using AWS X-Ray format.",
55
"main": "build/src/index.js",
66
"module": "build/esm/index.js",
@@ -16,7 +16,7 @@
1616
"lint": "eslint . --ext .ts",
1717
"lint:fix": "eslint . --ext .ts --fix",
1818
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json",
19-
"prepare": "npm run compile"
19+
"prepublishOnly": "npm run compile"
2020
},
2121
"keywords": [
2222
"opentelemetry",
@@ -36,10 +36,7 @@
3636
"build/esm/**/*.d.ts",
3737
"build/src/**/*.js",
3838
"build/src/**/*.js.map",
39-
"build/src/**/*.d.ts",
40-
"doc",
41-
"LICENSE",
42-
"README.md"
39+
"build/src/**/*.d.ts"
4340
],
4441
"publishConfig": {
4542
"access": "public"
@@ -50,19 +47,18 @@
5047
"devDependencies": {
5148
"@opentelemetry/api": "^1.0.0",
5249
"@types/mocha": "8.2.3",
53-
"@types/node": "18.11.7",
50+
"@types/node": "18.6.5",
5451
"@types/webpack-env": "1.16.2",
55-
"gts": "3.1.0",
5652
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
5753
"karma": "6.3.16",
5854
"karma-chrome-launcher": "^3.1.1",
5955
"karma-coverage-istanbul-reporter": "3.0.3",
6056
"karma-mocha": "2.0.1",
61-
"karma-spec-reporter": "0.0.32",
57+
"karma-spec-reporter": "0.0.36",
6258
"karma-webpack": "4.0.2",
6359
"mocha": "7.2.0",
6460
"nyc": "15.1.0",
65-
"rimraf": "3.0.2",
61+
"rimraf": "5.0.5",
6662
"ts-loader": "8.3.0",
6763
"ts-mocha": "10.0.0",
6864
"typescript": "4.4.4",

src/AWSXRayPropagator.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,18 @@ export class AWSXRayPropagator implements TextMapPropagator {
9292
carrier: unknown,
9393
getter: TextMapGetter
9494
): SpanContext {
95-
const traceHeader = getter.get(carrier, AWSXRAY_TRACE_ID_HEADER);
96-
if (!traceHeader || typeof traceHeader !== 'string')
95+
const headerKeys = getter.keys(carrier);
96+
const relevantHeaderKey = headerKeys.find(e => {
97+
return e.toLowerCase() === AWSXRAY_TRACE_ID_HEADER;
98+
});
99+
if (!relevantHeaderKey) {
97100
return INVALID_SPAN_CONTEXT;
101+
}
102+
const traceHeader = getter.get(carrier, relevantHeaderKey);
103+
104+
if (!traceHeader || typeof traceHeader !== 'string') {
105+
return INVALID_SPAN_CONTEXT;
106+
}
98107

99108
let pos = 0;
100109
let trimmedPart: string;

test/AWSXRayPropagator.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ describe('AWSXRayPropagator', () => {
299299

300300
assert.deepStrictEqual(extractedSpanContext, undefined);
301301
});
302+
303+
it('extracts context in a case-insensitive fashion', () => {
304+
carrier[AWSXRAY_TRACE_ID_HEADER.toUpperCase()] =
305+
'Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar';
306+
const extractedSpanContext = trace
307+
.getSpan(
308+
xrayPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
309+
)
310+
?.spanContext();
311+
312+
assert.deepStrictEqual(extractedSpanContext, {
313+
traceId: TRACE_ID,
314+
spanId: SPAN_ID,
315+
isRemote: true,
316+
traceFlags: TraceFlags.SAMPLED,
317+
});
318+
});
319+
302320
describe('.fields()', () => {
303321
it('should return a field with AWS X-Ray Trace ID header', () => {
304322
const expectedField = xrayPropagator.fields();

0 commit comments

Comments
 (0)