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>
marked this pull request as ready for review
ericapisani
deleted the
ep/py-2332-huggingface-span-first-7z3
branch
This was referenced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters