Skip to content

ai_track uses multiple values for keyword argument 'op' #4596

@mshavliuk

Description

@mshavliuk

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.33.0

Steps to Reproduce

import os

import sentry_sdk
from langchain_aws import ChatBedrockConverse
from sentry_sdk.ai.monitoring import ai_track
from sentry_sdk.integrations.langchain import LangchainIntegration

sentry_sdk.init(
    dsn=os.environ["SENTRY_DSN"],
    environment="localhost",
    traces_sample_rate=1.0,
    integrations=[LangchainIntegration()],
)

@ai_track("Bug demo", op="ai.run")
def run_llm():
    llm = ChatBedrockConverse(
        region_name="eu-west-1",
        aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
        aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
        model="eu.amazon.nova-lite-v1:0",
        max_tokens=1,
    )
    llm.invoke('hello')


if __name__ == "__main__":
    run_llm()

Expected Result

The llm call is traced with "ai.run" operation name

Actual Result

Traceback (most recent call last):
  File ".../sentry_bug.py", line 29, in <module>
    run_llm()
  File ".../.venv/lib/python3.12/site-packages/sentry_sdk/ai/monitoring.py", line 37, in sync_wrapped
    with start_span(name=description, op=op, **span_kwargs) as span:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sentry_sdk.api.start_span() got multiple values for keyword argument 'op'

The issue is caused in the following code:

op = span_kwargs.get("op", "ai.run" if curr_pipeline else "ai.pipeline")
with start_span(name=description, op=op, **span_kwargs) as span:

Metadata

Metadata

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy