Add common gen AI utils into opentelemetry-instrumentation#3188
Add common gen AI utils into opentelemetry-instrumentation#3188aabmass wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
|
Lint and tests for OpenAI are failing because we test against oldest published supported dependencies opentelemetry-python-contrib/tox.ini Lines 427 to 429 in 07c97ea To move this PR forward we either need to
|
I decided to do this, I've split the openai changes for now. I'll make a tracking bug to update the code once this PR is merged. |
4175da2 to
dcd3e4c
Compare
| def get_span_name(span_attributes: Mapping[str, AttributeValue]) -> str: | ||
| name = span_attributes.get(GenAIAttributes.GEN_AI_OPERATION_NAME, "") | ||
| model = span_attributes.get(GenAIAttributes.GEN_AI_REQUEST_MODEL, "") | ||
| return f"{name} {model}" |
There was a problem hiding this comment.
model name is not always available, we should return name in this case
| return f"{name} {model}" | ||
|
|
||
|
|
||
| def handle_span_exception(span: Span, error: Exception) -> None: |
There was a problem hiding this comment.
maybe
| def handle_span_exception(span: Span, error: Exception) -> None: | |
| def end_span_with_exception(span: Span, error: Exception) -> None: |
?
we're not handling anything, right?
BTW - there is nothing gen-ai specific here, should we move it to common instrumentation helpers?
There was a problem hiding this comment.
Tbh I'm kind of just mechanically copying from openai-v2:
Actually, the API/SDK has a mechanism here when used in start_as_current_span ctx manager. That would also call span.record_exception() which I believe add a span event with the stacktrace.
cc @lzchen @alizenhom do you know why OpenAI doesn't just use the existing mechanism?
|
Putting this back in draft for now, see the comments on linked issue #3191 (comment) |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
This PR has been closed due to inactivity. Please reopen if you would like to continue working on it. |
Description
Part of #3191
(Copied out of cohere PR #3081)
Type of change
Refactor
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.