cloud tracing support #63
Merged
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.
CloudTraceSink Implementation Summary
Overview
Implemented enterprise cloud tracing with "Local Write, Batch Upload" pattern for the Sentience Python SDK.
Files Created
1.
sentience/cloud_tracing.pyClass:
CloudTraceSink(TraceSink)Enterprise cloud sink that:
close()via pre-signed URLKey Features:
2.
sentience/tracer_factory.pyFunction:
create_tracer(api_key, run_id, api_url)Factory function with automatic tier detection:
TracerwithCloudTraceSinkTracerwithJsonlTraceSink(local-only)Tier Detection Flow:
api_keyprovided → Request pre-signed URL from/v1/traces/init3.
tests/test_cloud_tracing.pyComprehensive test suite with 20+ tests:
CloudTraceSink Tests:
Factory Tests:
Regression Tests:
Files Modified
sentience/__init__.pyAdded exports:
Usage Examples
Pro Tier (Cloud Upload)
Free Tier (Local Only)
Direct CloudTraceSink Usage
Architecture Benefits
Performance
Security
Reliability
Testing
Run the test suite:
API Requirements
The backend API must implement:
POST
/v1/traces/initRequest:
{ "run_id": "550e8400-e29b-41d4-a716-446655440000" }Headers:
Response (200 - Pro Tier):
{ "upload_url": "https://sentience.nyc3.digitaloceanspaces.com/user123/550e8400.../trace.jsonl.gz?X-Amz-Signature=..." }Response (403 - Free Tier):
{ "error": "Cloud tracing requires Pro tier" }Backward Compatibility
✅ 100% Backward Compatible
JsonlTraceSinkworks unchangedTracerworks unchangedcreate_tracer()is optional convenience functionCloudTraceSinkis optional - not required for basic usageNext Steps
Test the implementation:
Verify no regressions:
Update version number in
__init__.pyif neededUpdate CHANGELOG.md with new features
Backend team: Implement
/v1/traces/initendpointPrinciples Followed
Per
studio/CLAUDE.md:CloudTraceSink,Tracer,TraceEventdataclasses