Skip to content

feat(anthropic): emit streaming latency span attrs - #35

Merged
sayonfortify merged 1 commit into
fr-v0.52.6.xfrom
feat/anthropic-streaming-latency-span-attrs
Jun 18, 2026
Merged

feat(anthropic): emit streaming latency span attrs#35
sayonfortify merged 1 commit into
fr-v0.52.6.xfrom
feat/anthropic-streaming-latency-span-attrs

Conversation

@sayonfortify

Copy link
Copy Markdown

Adds FortifyRoot TTFT/STTG span attributes to Anthropic streaming spans, matching the RDS-derived streaming latency contract already used by OpenAI.

What changed:

  • Sync and async Anthropic stream wrappers now set:
    • fortifyroot.llm.streaming.time_to_first_token_ms
    • fortifyroot.llm.streaming.time_to_generate_ms
  • TTFT is measured when the first content delta is received from the upstream stream, before FortifyRoot's one-item safety buffer can add yield-time delay.
  • STTG is measured from first token to stream completion.
  • Empty/no-token streams omit both attrs, preserving nullable backend semantics instead of emitting fake zeroes.

Tests:

  • PYTHONPATH=packages/opentelemetry-instrumentation-anthropic:packages/opentelemetry-instrumentation-fortifyroot conda run -n py3.12 python -m pytest packages/opentelemetry-instrumentation-anthropic/tests/test_safety_unit.py -q → 19 passed
  • python3 -m py_compile streaming.py test_safety_unit.py
  • conda py3.12 py_compile same files
  • git diff --check clean

No vendored ocelle-py changes in this PR. After merge, cut the next fr-v0.52.6.N tag and vendor via ocelle-py/scripts/vendor.sh per internal SOP.

@sayonfortify
sayonfortify force-pushed the feat/anthropic-streaming-latency-span-attrs branch from 9ecee26 to a9355fe Compare June 18, 2026 22:24
@sayonfortify
sayonfortify merged commit 2f71307 into fr-v0.52.6.x Jun 18, 2026
10 checks passed
@sayonfortify
sayonfortify deleted the feat/anthropic-streaming-latency-span-attrs branch June 18, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant