Skip to content

feat(langchain): implement emitting events in addition to current behavior#2889

Merged
nirga merged 14 commits intotraceloop:mainfrom
LuizDMM:implement-events-langchain
Jul 11, 2025
Merged

feat(langchain): implement emitting events in addition to current behavior#2889
nirga merged 14 commits intotraceloop:mainfrom
LuizDMM:implement-events-langchain

Conversation

@LuizDMM
Copy link
Copy Markdown
Contributor

@LuizDMM LuizDMM commented May 5, 2025

✅ PR Requirements

  • I have added tests that cover my changes.
  • If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation):
  • (If applicable) I have updated the documentation accordingly.

📌 Issue Requirements

  • Make sure to keep the current way of emitting events and the new (event-based) way with the official semantic
  • Add a config to each instrumentation called use_legacy_attributes which defaults to true, and if set to false emit events instead of the prompt / completion attributes.
  • Propagate a new initialization parameter of the SDK called use_legacy_attributes that sets this config in all instrumentations.

LuizDMM added 3 commits May 3, 2025 08:04
… to current behavior

* Add "use_legacy_attributes" to Config and the Instrumentor constructor, defaulting to True;
* emit events for user prompts and AI responses, following [OpenTelemetry semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/\\\);
* introduce a privacy safeguard by checking the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable to enable or disable content capture in events;
* implement comprehensive tests to verify the new functionality and ensure that, when use_legacy_attributes == True, the existing behavior remains unchanged;
- Introduce TypedDicts and dataclasses to standardize inputs for event handling;
- Add `emit_event` method to encapsulate all event emission logic via `Event` instances;
- Refactor instrumentation to use `emit_event`, improving clarity and maintainability.
@ellipsis-dev
Copy link
Copy Markdown
Contributor

ellipsis-dev Bot commented May 5, 2025

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at help@ellipsis.dev


Generated with ❤️ by ellipsis.dev

@LuizDMM LuizDMM changed the title feat(langchain): implement emitting events in addition to current behaviour feat(langchain): implement emitting events in addition to current behavior May 5, 2025
@cursor
Copy link
Copy Markdown

cursor Bot commented Jul 5, 2025

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_43b90518-6947-4e9b-bab1-c59574709513).

Copy link
Copy Markdown
Member

@nirga nirga left a comment

Choose a reason for hiding this comment

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

I think you're reverting several changes we've incorporated in callback_handler, can you take a look?

@cursor
Copy link
Copy Markdown

cursor Bot commented Jul 11, 2025

🚨 BugBot couldn't run

Something went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_93ce9dcb-576e-49c5-bb5d-654aa14c71db).

@nirga nirga merged commit b58201f into traceloop:main Jul 11, 2025
9 checks passed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Noticed this file is empty. Is it intentional, or should it be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @ronensc, I'm taking a look in my branch here, if any code was lost in the merges, I'll remove it if it isn't necessary anymore, thank you for point out.

@LuizDMM
Copy link
Copy Markdown
Contributor Author

LuizDMM commented Jul 14, 2025

I think you're reverting several changes we've incorporated in callback_handler, can you take a look?

Hey @nirga, I'll take a look here in the merges I did and fix if that's the case, sorry for the delay, I hadn't seen your comment.

amitalokbera pushed a commit to amitalokbera/openllmetry that referenced this pull request Jul 15, 2025
…avior (traceloop#2889)

Co-authored-by: Nir Gazit <nirga@users.noreply.github.com>
else:
set_llm_request(span, serialized, prompts, kwargs, self.spans[run_id])

@dont_throw
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@LuizDMM Could you please clarify the reason for removing @dont_throw from on_llm_end()?

nina-kollman pushed a commit that referenced this pull request Aug 11, 2025
…avior (#2889)

Co-authored-by: Nir Gazit <nirga@users.noreply.github.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.

3 participants