◐ Shell
clean mode source ↗

feat(huggingface_hub): Migrate to span first by ericapisani · Pull Request #6124 · getsentry/sentry-python

Migrates the huggingface_hub integration to the span-first (streaming
span) architecture.

When `_experiments={"trace_lifecycle": "stream"}` is enabled, the
integration now uses `StreamedSpan` via `sentry_sdk.traces.start_span`
instead of the legacy `Span`-based (transactions) path. The legacy path
remains unchanged for backwards compatibility.

To support both span types from shared AI monitoring utilities,
`record_token_usage` and `set_data_normalized` now accept
`Union[Span, StreamedSpan]` and route attribute writes through a new
private `_set_span_data_attribute` helper in `sentry_sdk.ai.utils`
(calling `set_attribute` on `StreamedSpan` and `set_data` on `Span`).

Part of the broader span-first integration migration.

Fixes PY-2332

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@ericapisani marked this pull request as ready for review

April 21, 2026 18:09

alexander-alderman-webb

sentrivana

@ericapisani ericapisani deleted the ep/py-2332-huggingface-span-first-7z3 branch

April 23, 2026 11:46

This was referenced

May 4, 2026