Skip to content

feat(server): add operation telemetry for session create/add_message/…#1943

Merged
zhoujh01 merged 2 commits intovolcengine:mainfrom
MDNDDD:feat/session-api-telemetry
May 9, 2026
Merged

feat(server): add operation telemetry for session create/add_message/…#1943
zhoujh01 merged 2 commits intovolcengine:mainfrom
MDNDDD:feat/session-api-telemetry

Conversation

@MDNDDD
Copy link
Copy Markdown
Contributor

@MDNDDD MDNDDD commented May 9, 2026

…commit APIs

Wrap session.create, session.add_message and session.commit HTTP handlers with run_operation so callers can opt in via TelemetryRequest and receive a telemetry summary in the response. Propagate the telemetry parameter through the async/sync HTTP clients, the local client and the public SDK so all client modes expose a consistent surface.

Description

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

…commit APIs

Wrap session.create, session.add_message and session.commit HTTP handlers with
run_operation so callers can opt in via TelemetryRequest and receive a
telemetry summary in the response. Propagate the telemetry parameter through
the async/sync HTTP clients, the local client and the public SDK so all
client modes expose a consistent surface.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 85
🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Type Safety: Invalid default for telemetry field

The telemetry field in request models (AddMessageRequest, CreateSessionRequest, CommitRequest) is annotated as TelemetryRequest with default False. If TelemetryRequest is a Pydantic model, this will cause validation errors when using default values.

    telemetry: TelemetryRequest = False

    @model_validator(mode="after")
    def validate_content_or_parts(self) -> "AddMessageRequest":
        if self.content is None and self.parts is None:
            raise ValueError("Either 'content' or 'parts' must be provided")
        return self


class UsedRequest(BaseModel):
    """Request model for recording usage."""

    contexts: Optional[List[str]] = None
    skill: Optional[Dict[str, Any]] = None


class CreateSessionRequest(BaseModel):
    """Request model for creating a session."""

    session_id: Optional[str] = None
    telemetry: TelemetryRequest = False
Type Safety: Telemetry parameter default mismatch

The telemetry parameter is annotated as TelemetryRequest but defaults to False, which is a type mismatch unless TelemetryRequest explicitly includes bool.

self, session_id: Optional[str] = None, telemetry: TelemetryRequest = False
Async Function Handling

The fn passed to run_with_telemetry is a lambda returning an async coroutine. Ensure run_with_telemetry properly handles async functions by awaiting them.

execution = await run_with_telemetry(
    operation="session.create",
    telemetry=telemetry,
    fn=lambda: self._create_session_impl(session_id),
)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@zhoujh01 zhoujh01 merged commit 0158571 into volcengine:main May 9, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants