Skip to content

fix(bedrock): refectored using _attributes functions #1566

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

Closed

Conversation

satya-turing
Copy link
Collaborator

@satya-turing satya-turing commented Apr 28, 2025

This MR Updates the AWS Bedrock Agent Instrumentation for Multi agent collaboration.

The OpenInference instrumentation for AWS Bedrock implements a sophisticated trace ID-based system to track and correlate events across the lifecycle of agent interactions. This implementation enables detailed observability into the execution flow of Bedrock agents, including model invocations, tool calls, knowledge base lookups, and agent collaborations.

1. SpanManager

The SpanManager class serves as the central component for managing OpenTelemetry spans in the Bedrock instrumentation:

  • Hierarchical Span Structure: Maintains a multi-level hierarchy of spans:

    • Chain Spans: Parent spans representing major trace events (e.g., preprocessing, orchestration, postprocessing)
    • Child Spans: Representing specific operations like LLM invocations, tool calls, agent_collaborator etc.
  • Trace ID Generation and Management:

    • Extracts trace IDs for each event
    • Uses the format {trace_event}-{trace_id} to ensure uniqueness
    • Maintains mappings between trace IDs and their corresponding spans
  • Parent-Child Relationship:

    • Tracks parent-child relationships between spans using the trace ID
    • Allows for proper nesting and context propagation

2. ResponseAccumulator

The _ResponseAccumulator class processes responses from the Bedrock service:

  • Event Stream Processing: Handles the event stream from Bedrock's response
  • Trace Event Routing: Routes different trace events to appropriate handlers based on event type
  • Span Creation and Attribute Setting: Creates spans and sets attributes based on the trace data

3. AttributeExtractor

The AttributeExtractor class extracts and processes attributes from various types of trace data:

  • Specialized Extractors: Contains methods for extracting attributes from different event types:

    • Model invocation input/output
    • Tool invocations (action groups, code interpreter, etc.)
    • Knowledge base lookups
    • Agent collaborator interactions
  • Standardized Attribute Format: Converts Bedrock-specific data into OpenTelemetry-compatible attributes(we have used methods for creating span attribues using attributes.py)

Multi agent collaborator hierarchy example

image

cloases #1530

@satya-turing satya-turing requested a review from a team as a code owner April 28, 2025 18:19
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 28, 2025
@satya-turing satya-turing requested a review from axiomofjoy April 28, 2025 18:27
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Apr 30, 2025
@caroger caroger moved this to In Review in Instrumentation May 8, 2025
@satya-turing
Copy link
Collaborator Author

Changes availbale in #1656,

Closing This MR

@github-project-automation github-project-automation bot moved this from In Review to Done in Instrumentation May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant