Skip to content

CCM-33842: Normalize OpenAI and Anthropic GenAI usage attrs#7

Open
shreyas70 wants to merge 1 commit into
harness:mainfrom
shreyas70:CCM-33842-openai-anthropic-semconv
Open

CCM-33842: Normalize OpenAI and Anthropic GenAI usage attrs#7
shreyas70 wants to merge 1 commit into
harness:mainfrom
shreyas70:CCM-33842-openai-anthropic-semconv

Conversation

@shreyas70

Copy link
Copy Markdown
Contributor

Summary

  • Normalize OpenAI and Anthropic client spans to assert/use gen_ai.provider.name instead of the older gen_ai.system attribute.
  • Populate dotted cache token attributes when provider usage details are available:
    • gen_ai.usage.cache_read.input_tokens
    • gen_ai.usage.cache_creation.input_tokens
  • Populate gen_ai.usage.reasoning.output_tokens when reasoning token details are available.
  • Add test assertions for OpenAI and Anthropic semantic-convention fields.

Test plan

  • .venv/bin/python -m pytest test/instrumentation/openai/openai_instrumentation_test.py -> 19 passed
  • .venv/bin/python -m py_compile src/harness_sdk/instrumentation/anthropic/__init__.py src/harness_sdk/instrumentation/openai/__init__.py

Notes

  • Anthropic focused tests could not be run in this local venv because the PyPI opentelemetry-instrumentation-anthropic package installed here does not include opentelemetry.instrumentation.anthropic.messages_extractors, which this repo's existing Anthropic wrapper imports.
  • Streaming cache/reasoning accumulation is not changed in this PR.

Made with Cursor

Add canonical provider assertions and populate dotted cache and reasoning token attributes for OpenAI and Anthropic client spans.

Co-authored-by: Cursor <cursoragent@cursor.com>
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