Skip to content

Conversation

@herin049
Copy link
Contributor

Description

Adds support for aiobotocore instrumentation, following the implementation approach outlined in issue #4048.

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?

Unit tests have been added.

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 changed the title feat: add support for aiobotocore instrumentation (WIP) feat: add support for aiobotocore instrumentation Dec 25, 2025
@herin049 herin049 requested a review from a team as a code owner December 25, 2025 06:48
@xrmx
Copy link
Contributor

xrmx commented Dec 31, 2025

@lukeina2z @yiyuan-he wdyt?



_instruments = ("botocore ~= 1.0",)
_aiobotocore_instruments = ("aiobotocore ~= 2.0",)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should looks something like the following so that opentelemetry-bootstrap will work with that.

_instruments_botocore = "botocore ~= 1.0"
_instruments_aiobotocore = "aiobotocore ~= 2.0"

_instruments = ()
_instruments_any = (_instruments_botocore, _instruments_aiobotocore)


[project.entry-points.opentelemetry_instrumentor]
botocore = "opentelemetry.instrumentation.botocore:BotocoreInstrumentor"
aiobotocore = "opentelemetry.instrumentation.botocore:AiobotocoreInstrumentor"
Copy link
Contributor

Choose a reason for hiding this comment

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

Code above should be updated to something like the following:

[project.optional-dependencies]
instruments = []
instruments-any = [
  "botocore ~= 1.0",
  "aiobotoore ~= 2.0"
]

Copy link
Contributor Author

@herin049 herin049 Jan 1, 2026

Choose a reason for hiding this comment

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

Just want to make sure I'm understanding what you're saying here. Are you suggesting we just have a single opentelemetry_instrumentor entrypoint pointing to the BotocoreInstrumentor class, and only apply the aiobotocore patches if it is installed? I did initially consider this, but I did also want to potentially give users the ability to selectively instrument only aiobotocore or botocore. But in practice, I don't see a reason why you would ever want to do this. WDYT?

except Exception as ex: # pylint: disable=broad-except
_logger.error("Error when loading extension: %s", ex)
return _AwsSdkExtension(call_context)
_AIOBOTOCORE_EXTENSIONS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason why bedrock is not there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you look in the bedrock extension, it does a direct isinstance check for botocore.EventStream. However, aiobotocore actually defines aiobotocore.AioEventStream. I'm sure the differences are trivial, I just wanted to limit the scope of this PR.

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants