-
Notifications
You must be signed in to change notification settings - Fork 827
📝 Add docstrings to fix/cache-token-attributes
#3443
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
base: main
Are you sure you want to change the base?
Conversation
Docstrings generation was requested by @hayke102. * #3442 (comment) The following files were modified: * `packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.py` * `packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/span_utils.py`
|
Important Review skippedCodeRabbit bot authored PR detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
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.
Important
Looks good to me! 👍
Reviewed everything up to 8ef912a in 2 minutes and 31 seconds. Click for details.
- Reviewed
120lines of code in2files - Skipped
0files when reviewing. - Skipped posting
6draft 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-anthropic/opentelemetry/instrumentation/anthropic/__init__.py:185
- Draft comment:
Comprehensive docstring added for _aset_token_usage. Consider including explicit type hints in the docstring (e.g. parameter types) for additional clarity. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
2. packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.py:293
- Draft comment:
Replacing GenAIAttributes with SpanAttributes for cache token metrics improves consistency. Verify that mixing GenAIAttributes (for input/output tokens) with SpanAttributes (for cache tokens) is intentional per your semantic conventions. - 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.
3. packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.py:302
- Draft comment:
The docstring for _set_token_usage is well-written. For enhanced clarity, consider explicitly documenting the expected types for parameters and any return values. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
4. packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.py:902
- Draft comment:
Ensure the file ends with a newline to conform with standard file formatting practices. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This comment is about a missing newline at the end of the file. While it's true that many style guides recommend files end with a newline, this is typically caught by linters, formatters, or pre-commit hooks. The rules state "Do NOT comment on anything that would be obviously caught by the build" and to only keep comments with "STRONG EVIDENCE" that they are correct. A missing newline is a very minor formatting issue that would typically be caught by automated tools. The comment also uses the phrase "Ensure the file ends with a newline" which sounds like asking the author to verify/check something, which the rules say to avoid. This is not a logic issue or a code quality refactor - it's a trivial formatting concern. However, the diff does show that a newline was removed (the backslash notation), so the comment is technically correct about the file not ending with a newline. This could be considered a legitimate style issue that the author may have accidentally introduced. While the comment is technically correct, it falls into the category of trivial formatting issues that should be caught by automated tools like linters or formatters. The rules explicitly state not to comment on things that would be "obviously caught by the build" and to assume comments are incorrect unless there's strong evidence. A missing newline is exactly the type of thing that automated tools handle, and it's not a substantive code issue. This comment should be deleted. It's about a trivial formatting issue (missing newline at end of file) that would typically be caught by linters or formatters, and it doesn't represent a substantive code quality or logic issue.
5. packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/span_utils.py:284
- Draft comment:
The newly added docstring for set_chat_response_usage is detailed and clear. Nice job documenting the aggregation and recording of token usage! - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
6. packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/span_utils.py:346
- Draft comment:
Updating the attribute key to use SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS improves consistency. Confirm that this change aligns with the overall semantic conventions used across the project. - 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_uQdGJHasMXjAatix
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Docstrings generation was requested by @hayke102.
The following files were modified:
packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/__init__.pypackages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/span_utils.pyℹ️ Note
Important
Add docstrings to functions in
__init__.pyandspan_utils.py, and rename attributes for consistency._aset_token_usage()and_set_token_usage()in__init__.pyto describe parameters and functionality.set_chat_response_usage()inspan_utils.pyto explain token usage aggregation and recording.GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENStoSpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENSin__init__.py.GenAIAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENStoSpanAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENSin__init__.py.GenAIAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENStoSpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENSinspan_utils.py.This description was created by
for 8ef912a. You can customize this summary. It will automatically update as commits are pushed.