Skip to main content

Why Filter Spans

When using third-party frameworks that emit their own OpenTelemetry spans (e.g., Google A2A, PydanticAI internals, LangChain sub-components), those spans can clutter your traces with low-level transport or framework details that aren’t useful for debugging your application. The span_name_filters parameter on HoneyHiveTracer.init() lets you control which spans are sent to HoneyHive. Filtered spans are dropped before any enrichment or export, so they have zero overhead.
For full parameter details, see the span_name_filters parameter in the SDK reference.

Exclude Filter

Drop spans whose name starts with a given prefix. All other spans are kept.
from honeyhive import HoneyHiveTracer
import os

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
    span_name_filters={
        "exclude": [
            {"type": "prefix", "value": "a2a.client.transports"},
        ],
    },
)
This drops all spans with names starting with a2a.client.transports (e.g., a2a.client.transports.jsonrpc.JsonRpcTransport.send_message) while keeping useful spans like agent run, chat gpt-4o-mini, etc.

Include Filter

Only keep spans whose name starts with one of the given prefixes. All other spans are dropped.
from honeyhive import HoneyHiveTracer
import os

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
    span_name_filters={
        "include": [
            {"type": "prefix", "value": "pydantic-ai"},
            {"type": "prefix", "value": "chat"},
        ],
    },
)
This keeps only spans whose names start with pydantic-ai or chat, dropping everything else.

Combining Include and Exclude

When both include and exclude are specified, a span must match at least one include prefix and not match any exclude prefix.
from honeyhive import HoneyHiveTracer
import os

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
    span_name_filters={
        "include": [
            {"type": "prefix", "value": "a2a"},
        ],
        "exclude": [
            {"type": "prefix", "value": "a2a.client.transports"},
        ],
    },
)
This keeps all a2a.* spans except the noisy transport internals.

Filter Entry Format

Each filter entry is a dictionary with two keys:
KeyTypeDescription
typeLiteral["prefix"]The matching strategy. Must be "prefix".
valuestrThe string to match against the beginning of the span name.

Common Filters

FrameworkNoisy span prefixDescription
Google A2Aa2a.client.transportsJSON-RPC transport internals

Debugging

When verbose=True is set on HoneyHiveTracer.init(), filtered spans are logged at debug level so you can verify your filters are working as expected.
from honeyhive import HoneyHiveTracer
import os

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
    verbose=True,
    span_name_filters={
        "exclude": [
            {"type": "prefix", "value": "a2a.client.transports"},
        ],
    },
)