Skip to content

feat: add error and log span kinds#1283

Open
Br1an67 wants to merge 1 commit intoAgentOps-AI:mainfrom
Br1an67:feat/error-log-span-kinds
Open

feat: add error and log span kinds#1283
Br1an67 wants to merge 1 commit intoAgentOps-AI:mainfrom
Br1an67:feat/error-log-span-kinds

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

📥 Pull Request

📘 Description

Add ERROR and LOG span kinds to the SDK, addressing both #1025 and #1024.

Each span kind is available in two forms:

Decorators — wrap functions to trace them as error/log spans:

from agentops.sdk.decorators import error, log

@error
def handle_failure():
    ...

@log(name="custom_log")
def log_event():
    ...

Standalone functions — create one-shot event spans:

import agentops

agentops.error(name="validation_failed", message="Invalid input format")
agentops.log(name="checkpoint", message="Processing complete", level="INFO")

Changes:

  • agentops/semconv/span_kinds.py: Add ERROR and LOG to AgentOpsSpanKindValues enum and SpanKind class
  • agentops/sdk/decorators/__init__.py: Create error/log decorators via create_entity_decorator factory
  • agentops/__init__.py: Add standalone error() and log() functions using _create_as_current_span, update exports

🧪 Testing

Added 14 unit tests in tests/unit/sdk/test_error_log_spans.py covering:

  • Error decorator: basic span creation, custom name, async support
  • Log decorator: basic span creation, custom name
  • Standalone error(): span creation, error status code, extra attributes, default name
  • Standalone log(): span creation, log level, default INFO level, extra attributes, default name

All 164 tests pass (including existing tests). Ruff lint clean.

…ctions

Add ERROR and LOG span kinds to the SDK, each available as:
- Decorators: @error / @log for wrapping functions
- Standalone functions: agentops.error() / agentops.log() for one-shot events

Changes:
- Add ERROR and LOG to AgentOpsSpanKindValues enum and SpanKind class
- Create error/log decorators via create_entity_decorator factory
- Add agentops.error(name, message) standalone function (sets error status)
- Add agentops.log(name, message, level) standalone function
- Add 14 unit tests covering decorators, standalone functions, and attributes

Closes AgentOps-AI#1025, closes AgentOps-AI#1024
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.

1 participant