-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: do not add W3C TraceContext headers to Amazon Sigv4 outgoing HT…
…TP requests (#161)
- Loading branch information
Michele Mancioppi
authored
Mar 1, 2023
1 parent
36c7483
commit 4475cc4
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { diag, Context, TextMapSetter } from '@opentelemetry/api'; | ||
import { W3CTraceContextPropagator } from '@opentelemetry/core'; | ||
|
||
/* | ||
* List of keys in the carrier that signal the need not to inject | ||
* traceparent/tracestate headers, e.g., when the outgoing request | ||
* is signed with a digest, abnd us adding HTTP headers would | ||
* invalidate the signature. | ||
*/ | ||
const contextKeysSkipInject = [ | ||
'x-amz-content-sha256', // Amazon Sigv4, see https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html | ||
]; | ||
|
||
export class LumigoW3CTraceContextPropagator extends W3CTraceContextPropagator { | ||
override inject(context: Context, carrier: unknown, setter: TextMapSetter): void { | ||
if (typeof carrier === 'object') { | ||
for (const key of contextKeysSkipInject) { | ||
if (key in carrier) { | ||
diag.debug(`Skipping injection of trace context due to key '${key}' in carrier`); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
super.inject(context, carrier, setter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters