Skip to content

Conversation

@keith-decker
Copy link
Contributor

Description

Add missing SemConv attributes to spans for LLMInvocation calls, clean up some repeated code in the unit tests for genai utils.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Updated unit tests to check for additional attributes

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

@zhirafovod zhirafovod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 NIT comments, but looks good otherwise

_maybe_set_span_messages(
span, invocation.input_messages, invocation.output_messages
)
_apply_request_attributes(span, invocation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not blocking for this PR, but we should eventually allow to set attributes at start time. I noticed we don't properly mark which attributes should be provided at the start time, fixing it in the open-telemetry/semantic-conventions#2994

else:
finish_reasons = None

if finish_reasons:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe if finish_reasons is not available, we should set error - open-telemetry/semantic-conventions#2919 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm what would you set error to in that case ? I feel like instrumentations should set error explicitly (or call into a util that sets it explicitly) rather than try to infer it like that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Liudmila means literally setting the reason to error finish_reason = FinishReasons.ERROR. Not talking about the error attribute itself

if invocation.finish_reasons is not None:
finish_reasons = invocation.finish_reasons
elif invocation.output_messages:
finish_reasons = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonder if this should be a sorted set instead of a list ? or at least converted to a set and then converted back to a sorted list to get rid of duplicates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finish reasons are sorted and unique now. some unit tests for this added as well.

def _new_str_any_dict() -> dict[str, Any]:
return {}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my reading of https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/ is that "recommended" attributes SHOULD be included by default.. So for the attributes that correspond to these fields that are "recommended" I think we should be defaulting these to empty strings and 0 values instead of None (which means they will not be added).. Thoughts @aabmass @lmolkova ?

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.

5 participants