Skip to content

Commit f0fb4e3

Browse files
committed
port some more attributes
1 parent baa8a99 commit f0fb4e3

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

sentry_sdk/consts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,9 @@ class OP:
807807
GEN_AI_EXECUTE_TOOL = "gen_ai.execute_tool"
808808
GEN_AI_HANDOFF = "gen_ai.handoff"
809809
GEN_AI_INVOKE_AGENT = "gen_ai.invoke_agent"
810+
GEN_AI_PIPELINE = "gen_ai.pipeline"
810811
GEN_AI_RESPONSES = "gen_ai.responses"
812+
GEN_AI_RUN = "gen_ai.run"
811813
GRAPHQL_EXECUTE = "graphql.execute"
812814
GRAPHQL_MUTATION = "graphql.mutation"
813815
GRAPHQL_PARSE = "graphql.parse"
@@ -833,10 +835,6 @@ class OP:
833835
HUGGINGFACE_HUB_CHAT_COMPLETIONS_CREATE = (
834836
"ai.chat_completions.create.huggingface_hub"
835837
)
836-
LANGCHAIN_PIPELINE = "ai.pipeline.langchain"
837-
LANGCHAIN_RUN = "ai.run.langchain"
838-
LANGCHAIN_TOOL = "ai.tool.langchain"
839-
LANGCHAIN_AGENT = "ai.agent.langchain"
840838
QUEUE_PROCESS = "queue.process"
841839
QUEUE_PUBLISH = "queue.publish"
842840
QUEUE_SUBMIT_ARQ = "queue.submit.arq"

sentry_sdk/integrations/langchain.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def on_llm_start(
186186
watched_span = self._create_span(
187187
run_id,
188188
kwargs.get("parent_run_id"),
189-
op=OP.LANGCHAIN_RUN,
189+
op=OP.GEN_AI_,
190190
name=kwargs.get("name") or "Langchain LLM call",
191191
origin=LangchainIntegration.origin,
192192
)
@@ -309,9 +309,9 @@ def on_chain_start(self, serialized, inputs, *, run_id, **kwargs):
309309
run_id,
310310
kwargs.get("parent_run_id"),
311311
op=(
312-
OP.LANGCHAIN_RUN
312+
OP.GEN_AI_RUN
313313
if kwargs.get("parent_run_id") is not None
314-
else OP.LANGCHAIN_PIPELINE
314+
else OP.GEN_AI_PIPELINE
315315
),
316316
name=kwargs.get("name") or "Chain execution",
317317
origin=LangchainIntegration.origin,
@@ -347,7 +347,7 @@ def on_agent_action(self, action, *, run_id, **kwargs):
347347
watched_span = self._create_span(
348348
run_id,
349349
kwargs.get("parent_run_id"),
350-
op=OP.LANGCHAIN_AGENT,
350+
op=OP.GEN_AI_INVOKE_AGENT,
351351
name=action.tool or "AI tool usage",
352352
origin=LangchainIntegration.origin,
353353
)
@@ -384,7 +384,7 @@ def on_tool_start(self, serialized, input_str, *, run_id, **kwargs):
384384
watched_span = self._create_span(
385385
run_id,
386386
kwargs.get("parent_run_id"),
387-
op=OP.LANGCHAIN_TOOL,
387+
op=OP.GEN_AI_EXECUTE_TOOL,
388388
name=serialized.get("name") or kwargs.get("name") or "AI tool usage",
389389
origin=LangchainIntegration.origin,
390390
)

tests/integrations/langchain/test_langchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ def test_langchain_agent(
177177
tx = events[0]
178178
assert tx["type"] == "transaction"
179179
chat_spans = list(x for x in tx["spans"] if x["op"] == "gen_ai.chat")
180-
tool_exec_span = next(x for x in tx["spans"] if x["op"] == "ai.tool.langchain")
180+
tool_exec_span = next(x for x in tx["spans"] if x["op"] == "gen_ai.execute_tool")
181181

182182
assert len(chat_spans) == 2
183183

184184
# We can't guarantee anything about the "shape" of the langchain execution graph
185-
assert len(list(x for x in tx["spans"] if x["op"] == "ai.run.langchain")) > 0
185+
assert len(list(x for x in tx["spans"] if x["op"] == "gen_ai.run")) > 0
186186

187187
if use_unknown_llm_type:
188188
assert "gen_ai.usage.input_tokens" in chat_spans[0]["data"]

0 commit comments

Comments
 (0)