Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fixes #721

This PR ensures that kwargs passed to agentops.init() are correctly passed downstream to Session and its components, including support for custom exporters and exporter endpoints.

Key changes:

  • Add support for custom exporters via agentops.init(exporter=...)
  • Add support for custom exporter endpoints via agentops.init(exporter_endpoint=...)
  • Ensure all kwargs are correctly passed through the initialization chain
  • Add comprehensive tests for the new functionality

Link to Devin run: https://app.devin.ai/sessions/1e7a27e69cfd4308a9c6a9f67602651e

Requested by: Constantin-Doru

- Add support for custom exporters via agentops.init(exporter=...)
- Add support for custom exporter endpoints via agentops.init(exporter_endpoint=...)
- Ensure kwargs are correctly passed downstream to Session and its components
- Add tests for custom exporter configuration

Co-Authored-By: Constantin-Doru Teodorescu <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Comment on lines +20 to +21
self.exporter: Optional[Any] = None
self.exporter_endpoint: Optional[str] = None

Choose a reason for hiding this comment

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

The exporter parameter accepts Any type without validation, which could lead to runtime errors. Should validate the exporter has required methods/interface.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
self.exporter: Optional[Any] = None
self.exporter_endpoint: Optional[str] = None
self.exporter: Optional[MetricsExporter] = None
self.exporter_endpoint: Optional[str] = None

Comment on lines +87 to +88
elif os.environ.get("AGENTOPS_EXPORTER_ENDPOINT") is not None:
self.exporter_endpoint = os.environ.get("AGENTOPS_EXPORTER_ENDPOINT")

Choose a reason for hiding this comment

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

Environment variable access is not type-safe - os.environ.get() should specify a default value to ensure consistent type handling.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
elif os.environ.get("AGENTOPS_EXPORTER_ENDPOINT") is not None:
self.exporter_endpoint = os.environ.get("AGENTOPS_EXPORTER_ENDPOINT")
elif (exporter_endpoint := os.environ.get("AGENTOPS_EXPORTER_ENDPOINT", None)) is not None:
self.exporter_endpoint = exporter_endpoint

@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Co-Authored-By: Constantin-Doru Teodorescu <[email protected]>
@teocns teocns closed this Mar 4, 2025
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.

Consolidate initialization and kwargs passing to AgentOps client

2 participants