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

refactor: avoid exception when lambda_handler envs not present in aws-lambda instrumentation #2750

Conversation

Ronald-TR
Copy link
Contributor

@Ronald-TR Ronald-TR commented Jul 29, 2024

Description

This small refactor explains what happens when the aws-lambda instrumentation fails during _instrument() method, the exception occurs when the environment variables ORIG_HANDLER and _HANDLER doesn't exists, probably because the instrumentation is running outside an aws lambda.

Otherwise, this doesn't fix the original issue: opentelemetry-instrumentation-aws-lambda is installed by default during opentelemetry-bootstrap -a install, that is the reason why the original issue happens.

The PR just brings more clarity for this error.

Fixes #2744

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Jul 29, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Ronald-TR Ronald-TR force-pushed the refactor/missing_lambda_handler_in_aws_lambda_raises_exception branch from aac8922 to 7a8b084 Compare July 29, 2024 15:16
@emdneto emdneto requested a review from a team July 29, 2024 15:21
@emdneto
Copy link
Member

emdneto commented Jul 29, 2024

Quick example:

import requests

requests.get("https://httpbin.org/robots.txt")

Installs:

pip install --upgrade pip
pip install opentelemetry-distro
pip install requests
opentelemetry-bootstrap -a install

Run

opentelemetry-instrument --traces_exporter console --metrics_exporter console --service_name test python example.py

@Ronald-TR Ronald-TR changed the title refactor: raise exception when lambda_handler envs not present in aws-lambda instrumentation refactor: avoid exception when lambda_handler envs not present in aws-lambda instrumentation Jul 29, 2024
…ception' of github.com:Ronald-TR/opentelemetry-python-contrib into refactor/missing_lambda_handler_in_aws_lambda_raises_exception
CHANGELOG.md Show resolved Hide resolved
Co-authored-by: Emídio Neto <[email protected]>
Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

LGTM with the text updated to give an hint on how to fix things

@lzchen lzchen merged commit d563f8d into open-telemetry:main Jul 30, 2024
389 checks passed
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.

opentelemetry-instrumentation-aws-lambda: code does not handle lack of expected environment variables
6 participants