Skip to content

Conversation

jakubno
Copy link
Member

@jakubno jakubno commented Aug 5, 2025

Description

This pull request introduces support for setting sandbox metadata via a new PUT endpoint in the API. These changes allow clients to set the metadata of a running sandbox.

@jakubno jakubno self-assigned this Aug 5, 2025
@jakubno jakubno added the feature New feature label Aug 5, 2025
Copy link

linear bot commented Aug 5, 2025

@jakubno jakubno force-pushed the allow-metadata-to-be-updated-e2b-2792 branch 7 times, most recently from e88ce2b to 506a4bf Compare August 5, 2025 14:56
@jakubno jakubno marked this pull request as ready for review August 5, 2025 15:15
@jakubno jakubno force-pushed the allow-metadata-to-be-updated-e2b-2792 branch from 506a4bf to 7d3b28a Compare August 6, 2025 15:24
@dobrac
Copy link
Contributor

dobrac commented Aug 6, 2025

Description

This PR introduces a comprehensive team metrics system for tracking sandbox usage, including:

  • New API endpoint /teams/metrics for retrieving team-level metrics
  • Team metrics collection using OpenTelemetry for real-time concurrent sandbox tracking
  • ClickHouse integration for historical team metrics storage
  • Integration tests for the new functionality

the description looks to be incorrect

@ValentaTomas
Copy link
Member

My main question is about the API—which of the following do we want:

  • PATCH /sandboxes/{sandboxID}
  • PATCH/PUT? /sandboxes/{sandboxID}/metadata

Also if users wants to merge/only add metadata that should be somehow possible.

@jakubno jakubno marked this pull request as draft August 6, 2025 17:44
@jakubno jakubno force-pushed the allow-metadata-to-be-updated-e2b-2792 branch 9 times, most recently from 5df89a9 to bdb97cd Compare August 21, 2025 14:42
@jakubno jakubno force-pushed the allow-metadata-to-be-updated-e2b-2792 branch from bdb97cd to c651166 Compare August 21, 2025 14:47
@jakubno jakubno requested a review from dobrac August 23, 2025 19:47
@jakubno jakubno marked this pull request as draft August 24, 2025 19:17
@jakubno jakubno marked this pull request as ready for review August 25, 2025 08:17
@jakubno
Copy link
Member Author

jakubno commented Aug 25, 2025

@cursoragent review

This comment was marked as resolved.

Comment on lines +14 to +18
func (o *Orchestrator) UpdateSandboxMetadata(
ctx context.Context,
sbx *instance.InstanceInfo,
metadata map[string]string,
) *api.APIError {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a missing lock for concurrent metadata updates? e.g. first request succeeds second on the orchestrator, but second request sets the metadata on the API -> inconsistency

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactor how we lock, now if there's some handler or background process working with sandbox it should always acquire lock

assert.Equal(t, count, successCount, "All concurrent updates should succeed")

// Verify final state - should be from one of the updates
getSandboxResponse, err := c.GetSandboxesSandboxIDWithResponse(t.Context(), sandbox.SandboxID, setup.WithAPIKey())
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't check that the metadata reported by the API is the same as the one reported by the orchestrator

@jakubno jakubno marked this pull request as draft August 26, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants