Skip to content

feat(integrations): aws boto3 sdk#521

Closed
Mahhheshh (Mahhheshh) wants to merge 1 commit into
braintrustdata:mainfrom
Mahhheshh:boto3-sdk
Closed

feat(integrations): aws boto3 sdk#521
Mahhheshh (Mahhheshh) wants to merge 1 commit into
braintrustdata:mainfrom
Mahhheshh:boto3-sdk

Conversation

@Mahhheshh

@Mahhheshh Mahhheshh (Mahhheshh) commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

An attempt to enable tracing for aws boto3 sdk. #279

This PR Adds:

  • Braintrust tracing support for Converse API
  • vcr backed tests for the Converse
  • auto instrument test

AI closure: (parts written by AI, I gave up)
Source Code

  • _MIME_TYPES
  • _normalize_converse_message_content
  • _normalize_converse_message_content

Tests

  • test_normalize_converse_message_content_converts_inline_media_bytes
  • test_normalize_converse_message_content_preserves_non_binary_sources_and_errors

Example Trace (as basic as it could get only text baby)

{
  "id": "4863118b-12f0-49c6-8eb3-e3503ee44f78",
  "metrics": {
    "start": 1781631248.7061074,
    "end": 1781631248.710462,
    "duration": 0.004354715347290039,
    "prompt_tokens": 18.0,
    "completion_tokens": 5.0,
    "tokens": 23.0
  },
  "span_attributes": {
    "type": "SpanTypeAttribute.LLM",
    "name": "bedrock_runtime.converse",
    "exec_counter": 1
  },
  "context": {
    "caller_functionname": "pytest_pyfunc_call",
    "caller_filename": "/home/mahi/OpenSource/braintrust-sdk-python/py/.nox/test_boto3-latest/lib/python3.14/site-packages/_pytest/python.py",
    "caller_lineno": 167
  },
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "what's 2+2"
          }
        ]
      }
    ]
  },
  "metadata": {
    "runtime_provider": "aws_bedrock_runtime",
    "model": "claude-3-haiku-20240307-v1",
    "model_provider": "anthropic",
    "instructions": "answer only in single integer"
  },
  "project_id": "test-boto3",
  "log_id": "g",
  "output": {
    "message": {
      "role": "assistant",
      "content": [
        {
          "text": "4"
        }
      ]
    }
  },
  "created": "2026-06-16T17:34:08.705904+00:00",
  "span_id": "48080a1c-7d82-42a5-b122-850565b8e97b",
  "root_span_id": "48080a1c-7d82-42a5-b122-850565b8e97b",
  "span_parents": null
}

Future;
...

Meme to make day better
image

return cls.wrapper(wrapped, instance, args, kwargs)


class NestedFunctionWrapperPatcher(FunctionWrapperPatcher):

@Mahhheshh Mahhheshh (Mahhheshh) Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

could have followed the similar approach to Anthropics patching, I found this simple, convenient, it's ugly but this works.

@Mahhheshh

Copy link
Copy Markdown
Contributor Author

closing in favor of 519

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.

1 participant