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

botocore: add basic handling for bedrock invoke.model #3200

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

xrmx
Copy link
Contributor

@xrmx xrmx commented Jan 22, 2025

Description

Handle the invokeModel operation in the bedrock extension of the botocore instrumentation for a bunch of models from Amazon and Anthropic. The API changes between models and so we need custom code for each model 😭 . We are tracing a bunch of request and response params that are available in all models. Next batch of changes will add tracing for the streaming versions of the Converse and InvokeModel.

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

  • tox -e py310-test-instrumentation-botocore

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

@xrmx xrmx changed the title Add basic handling for invoke.model botocore: add basic handling for invoke.model Jan 22, 2025
@xrmx xrmx requested a review from a team as a code owner January 22, 2025 16:09
@xrmx xrmx changed the title botocore: add basic handling for invoke.model botocore: add basic handling for bedrock invoke.model Jan 22, 2025
@karthikscale3
Copy link
Contributor

Looks good to me, thanks

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

thanks and appreciate you taking the time to hit the branching based on models. While IIUC, the converse API doesn't have this issue, langchain etc want invoke_model. So, it is a good idea to have this here and doing the non-streaming variants first makes it a lot easier to review.

@xrmx xrmx enabled auto-merge (squash) January 23, 2025 16:14
@xrmx xrmx merged commit 2756c1e into open-telemetry:main Jan 23, 2025
687 checks passed
xrmx added a commit to xrmx/opentelemetry-python-contrib that referenced this pull request Jan 24, 2025
…#3200)

* Add basic handling for invoke.model

* Add changelog a please pylint

* Record converse cassettes against us-east-1

* Avoid double copy of streaming body

---------

Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
aryabharat pushed a commit to aryabharat/opentelemetry-python-contrib that referenced this pull request Feb 2, 2025
…#3200)

* Add basic handling for invoke.model

* Add changelog a please pylint

* Record converse cassettes against us-east-1

* Avoid double copy of streaming body

---------

Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com>
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.

4 participants