Skip to content

Conversation

@MrKrishnabhagat
Copy link

@MrKrishnabhagat MrKrishnabhagat commented Apr 9, 2025

/claim #2456

This PR implements support for emitting OpenTelemetry-compliant events for prompt and completion logging.

✅ Adds:

  • use_legacy_attributes config (default: true)
  • emit_prompt_events and emit_completion_events (default: true)
  • record_prompt_and_completion() utility function
  • Integrated into: completion_wrappers.py, chat_wrappers.py, embeddings_wrappers.py

Fully backward compatible with legacy attributes.


Important

Add OpenTelemetry-compliant prompt and completion event logging with configurable options and backward compatibility.

  • Behavior:
    • Adds OpenTelemetry-compliant event logging for prompt and completion events via record_prompt_and_completion() in utils.py.
    • Configurable via use_legacy_attributes, emit_prompt_events, and emit_completion_events in config.py.
    • Integrated into completion_wrappers.py, chat_wrappers.py, embeddings_wrappers.py.
  • Config:
    • Adds use_legacy_attributes, emit_prompt_events, emit_completion_events to Config class in config.py.
  • Utility Function:
    • Adds record_prompt_and_completion() in utils.py to emit events or set attributes based on config.

This description was created by Ellipsis for 502f1ab. It will automatically update as commits are pushed.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 502f1ab in 1 minute and 42 seconds

More details
  • Looked at 45 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/config.py:12
  • Draft comment:
    The lambda for upload_base64_image only returns a type hint (str) instead of actual logic. Confirm if this is intended or if a proper implementation is needed.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/utils.py:117
  • Draft comment:
    Consider adding more detailed documentation on when events vs. legacy attributes are used, as the flag toggles might be unclear to users.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/config.py:5
  • Draft comment:
    New config flags (use_legacy_attributes, emit_prompt_events, emit_completion_events) have been added. Please ensure these are clearly documented so users know when and how each mode is used, and whether they might ever be used concurrently.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
4. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/config.py:12
  • Draft comment:
    The default lambda for 'upload_base64_image' returns the built-in type 'str' rather than a string instance. If this no-op stub is intentional, consider adding a clarifying comment or returning an empty string instead.
  • Reason this comment was not posted:
    Comment was on unchanged code.
5. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/utils.py:117
  • Draft comment:
    In 'record_prompt_and_completion', consider documenting that if 'use_legacy_attributes' is True, prompt/completion events are not emitted, and think about potential issues if very long strings are passed (which might affect span sizes).
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
6. packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/utils.py:152
  • Draft comment:
    Typo alert: The log message on line 152 says "OpenLLMetry failed to trace in %s, error: %s". If this is meant to refer to OpenTelemetry, please update the spelling accordingly.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_Bioy5iGopIpRLzva


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants