Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instrumentation-aws-sdk): make empty context when SQS message has no propagation fields #1889

Merged
merged 5 commits into from
Jan 13, 2024

Conversation

zl4bv
Copy link
Contributor

@zl4bv zl4bv commented Jan 5, 2024

Which problem is this PR solving?

Stacktrace of the type error

TypeError: Cannot convert undefined or null to object
  File "<anonymous>", in Function.keys
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/services/MessageAttributes.js", line 33, col 23, in ContextGetter.keys
    return Object.keys(carrier);
  File "/src/node_modules/@opentelemetry/propagator-aws-xray/build/src/AWSXRayPropagator.js", line 69, col 35, in AWSXRayPropagator.getSpanContextFromHeader
    const headerKeys = getter.keys(carrier);
  File "/src/node_modules/@opentelemetry/propagator-aws-xray/build/src/AWSXRayPropagator.js", line 60, col 34, in AWSXRayPropagator.extract
    const spanContext = this.getSpanContextFromHeader(carrier, getter);
  File "/src/node_modules/@opentelemetry/api/build/src/api/propagation.js", line 72, col 44, in PropagationAPI.extract
    return this._getGlobalPropagator().extract(context, carrier, getter);
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/services/sqs.js", line 67, col 66, in messageToSpanDetails
    '{snip}                           parentContext: api_1.propagation.extract(api_1.ROOT_CONTEXT, (0, MessageAttributes_1.extractPropagationContext)(me {snip}
  File "/src/node_modules/@opentelemetry/propagation-utils/build/src/pubsub-propagation.js", line 132, col 73, in <anonymous>
    const { attributes, name, parentContext: propagatedContext, } = messageToSpanDetails(message);
  File "<anonymous>", in Array.forEach
  File "/src/node_modules/@opentelemetry/propagation-utils/build/src/pubsub-propagation.js", line 131, col 14, in Object.patchMessagesArrayToStartProcessSpans
    messages.forEach(message => {
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/services/sqs.js", line 61, col 63, in SqsServiceExtension.responseHook
    propagation_utils_1.pubsubPropagation.patchMessagesArrayToStartProcessSpans({
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/services/ServicesExtensions.js", line 33, col 154, in ServicesExtensions.responseHook
    '{snip}  0 ? void 0 : serviceExtension.responseHook) === null || _a === void 0 ? void 0 : _a.call(serviceExtension, response, span, tracer, config);
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/aws-sdk.js", line 166, col 45, in <anonymous>
    this.servicesExtensions.responseHook(normalizedResponse, span, self.tracer, self._config);
  File "node:async_hooks", line 338, col 14, in AsyncLocalStorage.run
  File "/src/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js", line 33, col 40, in AsyncLocalStorageContextManager.with
    return this._asyncLocalStorage.run(context, cb, ...args);
  File "/src/node_modules/@opentelemetry/api/build/src/api/context.js", line 60, col 46, in ContextAPI.with
    return this._getContextManager().with(context, fn, thisArg, ...args);
  File "/src/node_modules/@opentelemetry/instrumentation-aws-sdk/build/src/aws-sdk.js", line 149, col 31, in Request.<anonymous>
    api_1.context.with(completedEventContext, () => {
  [REMAINDER TRUNCATED]

Short description of the changes

@zl4bv zl4bv requested a review from a team January 5, 2024 04:25
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Merging #1889 (0d58f9d) into main (c0d873c) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1889      +/-   ##
==========================================
+ Coverage   91.47%   91.50%   +0.02%     
==========================================
  Files         145      145              
  Lines        7423     7425       +2     
  Branches     1483     1484       +1     
==========================================
+ Hits         6790     6794       +4     
+ Misses        633      631       -2     
Files Coverage Δ
...entation-aws-sdk/src/services/MessageAttributes.ts 97.43% <100.00%> (+5.54%) ⬆️

@blumamir
Copy link
Member

blumamir commented Jan 7, 2024

LGTM. thank you for submitting a fix

Can you please run npm run lint:fix in the package to fix lint issues so CI is green? Thanks

@zl4bv
Copy link
Contributor Author

zl4bv commented Jan 8, 2024

@blumamir the lint issues have been addressed. Let me know if there's anything else that needs to be done.

@blumamir blumamir merged commit 577a291 into open-telemetry:main Jan 13, 2024
17 checks passed
@dyladan dyladan mentioned this pull request Jan 13, 2024
@zl4bv zl4bv deleted the fix/header-keys-undefined branch February 2, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants