-
Notifications
You must be signed in to change notification settings - Fork 726
feat(groq): implement emitting events in addition to current behavior #2888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LuizDMM
wants to merge
3
commits into
traceloop:main
Choose a base branch
from
LuizDMM:implement-events-groq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…urrent 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; - Move `event_logger` to Config to centralize configuration and reduce complexity; - Add `emit_event` method to encapsulate all event emission logic via `Event` instances; - Refactor instrumentation to use `emit_event`, improving clarity and maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Changes requested ❌
Reviewed everything up to c6805b2 in 3 minutes and 20 seconds. Click for details.
- Reviewed
3988
lines of code in15
files - Skipped
0
files when reviewing. - Skipped posting
11
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:12
- Draft comment:
The legacy test asserts that no logs are emitted when use_legacy_attributes is true. Ensure that the instrumentation configuration reliably sets this behavior and consider adding comments explaining why log emission is disabled in this mode. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
2. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:79
- Draft comment:
The 'assert_message_in_logs' helper is used with expected content for events. Verify that the asserted content matches the semantic conventions, especially for empty message bodies in no-content mode. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
3. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:412
- Draft comment:
In the async tests, ensure that the hard-coded response id ('chatcmpl-ec0a74e9-df7f-4e91-aa09-e9618451f5c9') is stable and correct for the mock response, or consider parameterizing this if the responses may change. - Reason this comment was not posted:
Comment looked like it was already resolved.
4. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:421
- Draft comment:
The assert_message_in_logs helper is defined at the bottom. Consider documenting its purpose inline to improve clarity for future maintainers. - Reason this comment was not posted:
Confidence changes required:20%
<= threshold50%
None
5. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:34
- Draft comment:
Consider parameterizing the hard-coded response ID (e.g. 'chatcmpl-645691ff-34af-4d0f-a1c1-fe888f8685cc') to improve test stability. Ideally, derive it dynamically or via a fixture. - 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.
6. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:421
- Draft comment:
Enhance the error messages in 'assert_message_in_logs' to provide more context when the assertion fails, aiding debugging. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%
<= threshold50%
This comment is purely informative and does not provide a specific suggestion or request for change. It does not align with the rules for good comments as it does not ask for a specific action or provide a specific suggestion.
7. packages/opentelemetry-instrumentation-groq/tests/traces/test_chat_tracing.py:129
- Draft comment:
When asserting events with no content, it may be beneficial to add a comment clarifying that an empty body is the expected behavior. This improves code clarity for future maintainers. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The test name test_chat_with_events_with_no_content clearly indicates this is testing the no-content case. The empty dict {} is passed intentionally. The assert_message_in_logs function handles empty content explicitly. Adding a comment would be redundant given the clear test name and structure. The comment could help someone quickly scanning the code without reading the full context. Empty dicts can sometimes indicate errors or incomplete implementations. While true, test names should be descriptive enough to explain the test's purpose, which this one is. Adding redundant comments can actually reduce clarity by creating noise. The comment should be deleted as it suggests adding unnecessary redundancy to already clear test code.
8. packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/event_handler.py:97
- Draft comment:
Typographical issue: the comment text 'so remove the role from the body if it is the same as the in the event name' contains a redundant word. Consider revising it to 'so remove the role from the body if it is the same as in the event name'. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While the comment is technically correct about the typo, it's an extremely minor issue in a code comment that doesn't affect functionality or code clarity. The meaning is still clear despite the small grammatical error. According to the rules, we should not make purely informative comments or comments about unimportant issues. The typo could be seen as reducing code quality and professionalism. Clear documentation is important. While clear documentation is important, this is such a minor grammatical issue that fixing it provides negligible value and creates unnecessary review noise. Delete this comment as it addresses an extremely minor documentation issue that doesn't meaningfully impact code quality or understanding.
9. packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/utils.py:47
- Draft comment:
Typo detected in log message: 'OpenLLMetry failed to trace in %s, error: %s'. Consider changing it to 'OpenTelemetry failed to trace in %s, error: %s' for clarity and consistency. - 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.
10. packages/opentelemetry-instrumentation-groq/tests/traces/cassettes/test_chat_tracing/test_chat_streaming_legacy.yaml:234
- Draft comment:
There appears to be a typographical error in the reassembled punchline. The segments of the word intended to form "challenged" are split as "-ch" + "alleng" + "ed" which, when combined, results in "challanged" missing an extra 'e'. Please correct the misspelling to "challenged" to ensure consistency in the joke. - 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.
11. packages/opentelemetry-instrumentation-groq/tests/traces/cassettes/test_chat_tracing/test_chat_streaming_with_events_with_content.yaml:231
- Draft comment:
It appears that the word intended to be 'challenged' is split incorrectly as 'alleng' (followed by 'ed'). Please correct this typographical error so that it reads 'challenged'. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% This is a test fixture file that records actual API responses. The "typo" is part of the streaming response data from the API and is intentionally recorded exactly as received. Modifying it would make the test fixture inaccurate. The apparent typo is just how the API chunks the response data and is not actually a problem that needs fixing. Could the typo cause issues for developers trying to understand the test? Could it be confusing to leave it as is? No - this is a test fixture that needs to accurately record the API's behavior, including how it chunks the response. Changing it would make the test less accurate. Delete the comment. The apparent typo is just how the API streams its response in chunks and should be preserved exactly as received in this test fixture.
Workflow ID: wflow_UX6CW31qCAsjEypJ
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
packages/opentelemetry-instrumentation-groq/tests/traces/conftest.py
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ PR Requirements
📌 Issue Requirements
Important
This PR implements event-based telemetry for Groq instrumentation, allowing toggling between legacy and new systems, and adds tests for both modes.
__init__.py
with_emit_message_events()
and_emit_choice_events()
._emit_streaming_response_events()
for streaming responses.use_legacy_attributes
inconfig.py
to toggle between legacy and event-based telemetry.emit_event()
inevent_handler.py
to emitMessageEvent
andChoiceEvent
.is_content_enabled()
andshould_emit_events()
inutils.py
to control event emission.test_chat_tracing.py
for both legacy and event-based telemetry.conftest.py
to configure test environments for different telemetry modes.This description was created by
for c6805b2. You can customize this summary. It will automatically update as commits are pushed.