opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

opentelemetry-instrumentation-botocore: add ability to instrument aiobotocore

Open herin049 opened this issue 1 month ago • 0 comments

What problem do you want to solve?

The current opentelemetry-instrumentation-botocore library only instruments the botocore library (which boto3 is built on top of). However, it lacks support for the async implementation aiobotocore. I see that previously there was interest in adding a dedicated opentelemetry-instrumentation-aiobotocore library (see https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1709), but was turned down to limit the scope of instrumentation libraries supported. Fortunately, the aiobotocore implementation is essentially a direct asynchronous port of botocore, so a dedicated library likely isn't needed.

Describe the solution you'd like

As mentioned above, given that aiobotocore is effectively an async port of botocore, nearly all of the existing instrumentation logic and extensions can be reused (with the exception of the Bedrock extension). The aiobotocore client extends the botocore base client and any errors are raised as botocore errors. In fact, the only changes required to add support for aiobotocore would be to patch the two equivalent async functions in aiobotocore. A reasonable approach is as follows:

  1. Add an AiobotocoreInstrumentor class in opentelemetry-instrumentation-botocore, and patch the relevant async functions, reusing the existing extension logic already implemented while externalizing some logic in BotocoreInstrumentor to allow for more code reuse.
  2. Add an aiobotocore entrypoint to the pyproject.toml for auto instrumentation.
  3. Define separate known extensions maps for botocore and aiobotocore to prevent potential errors from using extensions not compatible with aiobotocore (i.e. Bedrock). Note: we can update the bedrock extension to support aiobotocore at a later point to re-consolidate the extension maps.

If the team thinks the proposed outline is acceptable, I am more than happy to contribute these changes.

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

herin049 avatar Dec 22 '25 22:12 herin049