-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
docs: Add docstrings to telemetry class #2377
Conversation
Disclaimer: This review was made by a crew of AI Agents. Code Review CommentOverviewThe recent pull request aims to enhance the documentation within the Telemetry class, focusing on consistent and informative docstrings for methods that aid in understanding how telemetry data is collected and used effectively. Positive Aspects
Suggested Improvements1. Return Type DocumentationTo improve clarity and usability, all methods should include return type annotations. For example: def task_ended(self, span: Span, task: Task, crew: Crew) -> None:
"""Records the completion of a task execution in a crew.
Args:
span (Span): The OpenTelemetry span tracking the task execution
task (Task): The task that was completed
crew (Crew): The crew context in which the task was executed
Returns:
None
Note:
If share_crew is enabled, this will also record the task output
""" 2. Exception DocumentationEach method should specify possible exceptions that might arise during execution. For instance: def tool_usage(self, llm: Any, tool_name: str, attempts: int) -> None:
"""Records the usage of a tool by an agent.
Args:
llm (Any): The language model being used
tool_name (str): Name of the tool being used
attempts (int): Number of attempts made with this tool
Returns:
None
Raises:
TelemetryError: If telemetry operation fails
""" 3. Type Hints ImprovementUtilizing more specific type hints instead of def tool_usage_error(self, llm: BaseLanguageModel) -> None:
"""Records when a tool usage results in an error.
Args:
llm (BaseLanguageModel): The language model being used when the error occurred
Returns:
None
""" 4. Method ExamplesFor complex methods, adding usage examples in their docstrings could significantly enhance developer understanding. Consider: def test_execution_span(self, crew: Crew, iterations: int, inputs: dict[str, Any] | None, model_name: str) -> None:
"""Records the execution of a test suite for a crew.
Args:
crew (Crew): The crew being tested
iterations (int): Number of test iterations
inputs (dict[str, Any] | None): Input parameters for the test
model_name (str): Name of the model used in testing
Returns:
None
Example:
>>> telemetry = Telemetry()
>>> telemetry.test_execution_span(
... crew=my_crew,
... iterations=5,
... inputs={"test_data": "sample"},
... model_name="gpt-4"
... )
""" 5. Validation InformationDocumenting input validation requirements can help prevent misuse of methods: def flow_plotting_span(self, flow_name: str, node_names: list[str]) -> None:
"""Records flow visualization/plotting activity.
Args:
flow_name (str): Name of the flow being plotted
node_names (list[str]): List of node names in the flow
Returns:
None
Note:
- flow_name must be non-empty
- node_names must contain at least one node name
""" General Recommendations
ConclusionOverall, this pull request significantly enhances the documentation quality of the Telemetry class, fostering better maintainability and developer engagement. Implementing the suggested improvements will further enhance the code quality and ease of understanding for current and future contributors. Thank you for your hard work on this! |
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.
Thank you!!
Description
This PR adds detailed documentation for all methods in the Telemetry class, improving code understanding and facilitating future contributions.
Changes
Why is this change necessary?
Checklist
Additional Notes
This contribution focuses exclusively on documentation, with no functional code changes. All docstrings were written based on the current method implementations.