Skip to content

graph OTel traces with non-informative names #3173

@SawickiBartosz

Description

@SawickiBartosz

Initial Checks

Description

Hi!

When using the OTel instrumentation for graphs, the operation names contain the generic node_id and graph.name. I believe it'd be more readable to show the actual graph name and node id.

I use jaeger for tracing, below is the tracing in the jaeger UI.

Image

Here are the traces extracted from jaeger.
traces-1760525065706.json

I'm open to contribute here.

Example Code

import os
import logfire

from dataclasses import dataclass
from pydantic_graph import Graph, GraphRunContext, BaseNode, End
from typing import Optional


@dataclass
class MyState:
    input_number: int
    doubled_input: Optional[int] = None
    final_result: Optional[int] = None

@dataclass
class DoublingNode(BaseNode[MyState]):  

    async def run(
        self,
        ctx: GraphRunContext[MyState],  
    ) -> 'AddingNode':  
        # Double the input number and store in doubled_input
        ctx.state.doubled_input = ctx.state.input_number * 2
        return AddingNode()

@dataclass
class AddingNode(BaseNode[MyState]):  

    async def run(
        self,
        ctx: GraphRunContext[MyState],  
    ) -> End:  
        # Add 10 to the doubled input and store in final_result
        ctx.state.final_result = ctx.state.doubled_input + 10
        return End(ctx.state)

graph = Graph(name="pydantic_ai_graph",
              state_type=MyState,
              nodes=[DoublingNode, AddingNode])

os.environ['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'http://localhost:4318/v1/traces' 
logfire.configure(send_to_logfire=False, service_name="ArithmeticAgent")  

result = await graph.run(DoublingNode(),
                         state=MyState(input_number=3))

Python, Pydantic AI & LLM client version

Python 3.11.11

pydantic-ai==1.0.18
pydantic-ai-slim==1.0.18
pydantic-evals==1.0.18
pydantic-graph==1.0.18

.\jaeger.exe --version
application version: git-commit=a204929483c734da6c54eaa75f3f7c322b3e886b, git-version=v2.11.0, build-date=2025-10-03T02:41:46Z
jaeger version v2.11.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions