-
Notifications
You must be signed in to change notification settings - Fork 509
feat: Context management for using with that manages trace(s) automatically
#1019
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
06eca59
add context management to use `with` with `start_trace`
dot-agi 513e7d3
set to `Success` when no error encountered
dot-agi 4f71026
add examples
dot-agi c7055df
add tests for context management
dot-agi c57001a
add docs
dot-agi 5c8b995
add `TraceState` for handling status codes and handle thread manageme…
dot-agi 1bf7033
modify to use updated status codes
dot-agi 84670a8
heckin' ruff
dot-agi 426b8b4
gh copilot said do it so i did
dot-agi 0ab4632
Merge branch 'main' into feat/trace-context-manager
dot-agi 5a29002
Merge branch 'main' into feat/trace-context-manager
dot-agi a314e6a
Merge branch 'main' into feat/trace-context-manager
dot-agi d9a348e
Merge branch 'main' into feat/trace-context-manager
dot-agi 41826a1
Merge branch 'main' into feat/trace-context-manager
dot-agi de0e410
global tracer everywher
dot-agi 605f52f
Merge branch 'main' into feat/trace-context-manager
dot-agi da8fac0
should fix linting
dot-agi 01d6bf2
Convert end_state to string using helper function
dot-agi c045f76
Revert "Convert end_state to string using helper function"
dot-agi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """ | ||
dot-agi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| AgentOps enums for user-friendly API. | ||
| This module provides simple enums that users can import from agentops | ||
| without needing to know about OpenTelemetry internals. | ||
| """ | ||
|
|
||
| from enum import Enum | ||
| from opentelemetry.trace.status import StatusCode | ||
|
|
||
|
|
||
| class TraceState(Enum): | ||
| """ | ||
| Enum for trace end states. | ||
| This provides a user-friendly interface that maps to OpenTelemetry StatusCode internally. | ||
| Users can simply use agentops.TraceState.SUCCESS instead of importing OpenTelemetry. | ||
| """ | ||
|
|
||
| SUCCESS = StatusCode.OK | ||
| ERROR = StatusCode.ERROR | ||
| UNSET = StatusCode.UNSET | ||
|
|
||
| def __str__(self) -> str: | ||
| """Return the name for string representation.""" | ||
| return self.name | ||
|
|
||
| def to_status_code(self) -> StatusCode: | ||
| """Convert to OpenTelemetry StatusCode.""" | ||
| return self.value | ||
|
|
||
|
|
||
| # For backward compatibility, also provide these as module-level constants | ||
| SUCCESS = TraceState.SUCCESS | ||
| ERROR = TraceState.ERROR | ||
| UNSET = TraceState.UNSET | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.