Skip to content

fix(AwsSdk): handle missing x-amz-request-id in metadata#524

Merged
bobstrecansky merged 2 commits into
open-telemetry:mainfrom
adiafora:fix/monolog-handler-null-attributes
Mar 31, 2026
Merged

fix(AwsSdk): handle missing x-amz-request-id in metadata#524
bobstrecansky merged 2 commits into
open-telemetry:mainfrom
adiafora:fix/monolog-handler-null-attributes

Conversation

@adiafora

Copy link
Copy Markdown
Contributor

@adiafora
adiafora requested a review from a team as a code owner March 17, 2026 12:31
@welcome

welcome Bot commented Mar 17, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

$span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $result['@metadata']['statusCode']); // @phan-suppress-current-line PhanTypeMismatchDimFetch
$span->setAttribute(TraceAttributes::AWS_REQUEST_ID, $result['@metadata']['headers']['x-amz-request-id']); // @phan-suppress-current-line PhanTypeMismatchDimFetch

$awsRequestId = $result['@metadata']['headers']['x-amz-request-id'] ?? null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix the bug. Should we address the other options later? I was not 100% sure but based on the AWS docs this information can have several headers

https://opentelemetry.io/docs/specs/semconv/cloud-providers/aws-sdk/

@adiafora adiafora Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scprek I think we should fix the bug in this PR. The use of other headers should be added in another PR, I think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional header checks are fairly trivial, so no objections to adding them in this PR from me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course. I added it))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks for your efforts!

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.15%. Comparing base (2b6a02f) to head (19cb273).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...strumentation/AwsSdk/src/AwsSdkInstrumentation.php 85.71% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #524   +/-   ##
=========================================
  Coverage     82.15%   82.15%           
- Complexity     2297     2298    +1     
=========================================
  Files           156      156           
  Lines          8547     8553    +6     
=========================================
+ Hits           7022     7027    +5     
- Misses         1525     1526    +1     
Flag Coverage Δ
Aws 93.37% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.14% <85.71%> (+0.14%) ⬆️
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/Guzzle 76.25% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig 28.76% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 71.51% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/MySqli 93.39% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PDO 85.67% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr3 67.70% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.58% <ø> (ø)
Symfony 88.14% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...strumentation/AwsSdk/src/AwsSdkInstrumentation.php 82.14% <85.71%> (+0.14%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b6a02f...19cb273. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

Thanks @adiafora - please can you address the failing build pipelines for the changed instrumentation?

@adiafora

Copy link
Copy Markdown
Contributor Author

@ChrisLightfootWild CI is failing on vendor/bin/phan stage due to the recent upstream deprecation of InstrumentationInterface and InstrumentationTrait in the open-telemetry/api package. Since this is unrelated to my changes, should I ignore it, suppress the Phan warnings, or will there be a separate maintenance PR to address this?

@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

@ChrisLightfootWild CI is failing on vendor/bin/phan stage due to the recent upstream deprecation of InstrumentationInterface and InstrumentationTrait in the open-telemetry/api package. Since this is unrelated to my changes, should I ignore it, suppress the Phan warnings, or will there be a separate maintenance PR to address this?

Leaving that to be fixed separately is good for that one. 👍

@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

@bobstrecansky can you merge this one if you are happy please?

@bobstrecansky
bobstrecansky merged commit 9c73e84 into open-telemetry:main Mar 31, 2026
156 of 175 checks passed
@ChrisLightfootWild

Copy link
Copy Markdown
Contributor

Available in https://github.com/opentelemetry-php/contrib-auto-aws-sdk/releases/tag/0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS Auto OTEL Logs Undefined Array Warnings when Header Missing

4 participants