Skip to content

feat: add ability to configure flush behavior for AWS lambda instrumentation#4158

Open
herin049 wants to merge 2 commits intoopen-telemetry:mainfrom
herin049:feat/aws-lambda-flush-config
Open

feat: add ability to configure flush behavior for AWS lambda instrumentation#4158
herin049 wants to merge 2 commits intoopen-telemetry:mainfrom
herin049:feat/aws-lambda-flush-config

Conversation

@herin049
Copy link
Contributor

@herin049 herin049 commented Feb 1, 2026

Description

Adds ability to configure flush behavior in AWS Lambda instrumentation.

Fixes #4157

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?

tox run -e $(tox --listenvs | grep aws-lambda | tr '\n' ',')

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

@herin049 herin049 requested a review from a team as a code owner February 1, 2026 22:33
)


def _get_env_bool(env_var: str, default: bool) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised there isn't something like this already in contrib nor the SDK repo -- I couldn't find one either.

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Lgtm

By default, the instrumentation force flushes both traces and metrics after each Lambda invocation.
This behavior can be controlled with the following environment variables:

* ``OTEL_INSTRUMENTATION_AWS_LAMBDA_FORCE_FLUSH``: Enables or disables force flushing for all signal types. Defaults to ``true``.
Copy link
Contributor

@xrmx xrmx Feb 5, 2026

Choose a reason for hiding this comment

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

If these are Python specific they should be OTEL_PYTHON_ prefixed, e.g. OTEL_PYTHON_AWS_LAMBDA_FORCE_FLUSH

if value is None:
return default
value = value.strip().lower()
if value in ("y", "yes", "t", "true", "on", "1"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue I see with that is that we cannot allow explicitly setting this option to false. Should I make this a number (i.e. 0/1) instead?

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.

Provide alternate strategies for exporting metrics with AWS Lambda

3 participants