Repository navigation
fix(protocol): make telemetry export opt-in - #2738
Closed
abhinavkr26104 wants to merge 3 commits into
Closed
abhinavkr26104 wants to merge 3 commits into
abhinavkr26104 wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: e77c269 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 20 files
Architecture diagram
sequenceDiagram
participant Client as SDK Client (TS/Go/Python)
participant Init as stagehand.init
participant Schema as Protocol Schema (Zod/JSON)
participant Ext as Extension (tracing.ts)
participant OTLP as OTLP Collector
Note over Client,OTLP: Telemetry Opt-In Flow
Client->>Init: Call init with clientInfo
alt Telemetry omitted (default)
Init->>Schema: Validate init params
Schema-->>Init: Optional telemetry field absent
Init->>Ext: configure(undefined, clientInfo)
Ext->>Ext: Skip runtime creation
Note over Ext: Tracing inert, no exporters
Init-->>Client: Init success
Ext->>OTLP: No export attempts
else Explicit telemetry configured
Client->>Init: Set telemetry.traces.endpoint
Init->>Schema: Validate with explicit endpoint
Schema-->>Init: Telemetry config present
Init->>Ext: configure(telemetry, clientInfo)
Ext->>Ext: Create tracing runtime
Ext->>OTLP: Start span export
OTLP-->>Ext: Accept spans
Init-->>Client: Init success with telemetry
end
Note over Client,Ext: Go SDK Special Handling
Client->>Init: Pass TelemetryConfig (value type)
Init->>Init: Check endpoint non-empty
alt Endpoint empty (zero value)
Init->>Init: Convert to nil pointer
Init->>Ext: Omit from wire
else Endpoint non-empty
Init->>Init: Keep pointer reference
Init->>Ext: Include on wire
end
opt Shutdown with telemetry
Client->>Ext: forceFlush()
Ext->>OTLP: Flush pending spans
Client->>Ext: shutdown()
Ext->>OTLP: Close exporters
end
opt Shutdown without telemetry
Client->>Ext: forceFlush()
Ext->>Ext: No-op (no runtime)
Client->>Ext: shutdown()
Ext->>Ext: No-op (no runtime)
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
# Conflicts: # packages/extension/tracing.ts # packages/sdk-go/internal/extensionassets/stagehand-extension.zip # packages/sdk-python/src/stagehand/_generated/models.py
miguelg719
approved these changes
Sep 25, 2026
Contributor
|
This PR was approved by @miguelg719 and mirrored to #3045. All further discussion should happen on that PR. |
miguelg719
added a commit
that referenced
this pull request
Sep 26, 2026
Mirrored from external contributor PR #2738 after approval by @miguelg719. Original author: @abhinavkr26104 Original PR: #2738 Approved source head SHA: `e77c269fcc7ab33d2b76f213f26da62b77b1e826` @abhinavkr26104, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here. ## Original description # why The v4 init schema supplied `https://example.com/v1/traces` whenever callers omitted telemetry. The extension treated that placeholder as an intentional OTLP destination, creating guaranteed-failing background exports and possible shutdown delays for otherwise default Stagehand instances. Fixes #2732 # what changed - Make `stagehand.init` telemetry optional instead of injecting a placeholder endpoint. - Leave extension tracing inert when no telemetry configuration is supplied while preserving explicit OTLP export behavior. - Regenerate Python and Go protocol models and the embedded Go extension bundle. - Keep Go's existing value-style public telemetry option while omitting its zero value from the wire. - Document that telemetry export is disabled by default and add protocol/runtime/SDK regression coverage. - Add patch Changesets for the extension and SDKs. # test plan - Protocol unit suite: 26 files passed, 359 tests passed. - Extension unit suite: 45 files passed, 334 tests passed, 10 existing TODOs. - Focused TypeScript SDK create tests passed, including omitted and explicit telemetry. - Python focused tests: 200 passed, 1 skipped; generated-model freshness, Ruff format, and Ruff lint checks passed. - Full Python suite attempted: 455 passed, 2 skipped; only the two pre-existing Windows path assertions tracked by #2733 failed. - Go SDK suite excluding the intentionally separate examples package passed. - Protocol type-check and extension production build passed. - Targeted Oxfmt, Oxlint, Changesets validation, and `git diff --check` passed. - The full JavaScript unit run was attempted; unrelated Windows/environment failures remain in SDK path assertions, package-manager spawning, and file metadata handling. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Makes telemetry export opt-in so omitted telemetry no longer injects a placeholder endpoint that caused guaranteed-failing exports and shutdown delays. `stagehand.init` no longer defaults to `https://example.com/v1/traces`; omitting telemetry leaves tracing inert, while explicit telemetry keeps OTLP export. - Protocol: `stagehand.init.telemetry` is now optional with no default; schema, integrity, and wire-casing tests updated. - Extension: `createStagehandTracing.configure` accepts `undefined` and skips runtime creation; flush/shutdown become no-ops when telemetry is absent. - SDKs: TypeScript omits `telemetry` from the wire when unset; Go's `StagehandInitParams.Telemetry` is now `*TelemetryConfig` and omits the zero value via `optionalTelemetry`, while `CreateOptions.Telemetry` stays value-style; Python marks `telemetry` as `Optional` with the placeholder default removed. - Release: Patch changesets added for the five affected packages. **Migration** - No action needed; placeholder export errors and shutdown delays disappear. - Set `telemetry.traces.endpoint` to an OTLP collector (ending in `/v1/traces`) with required headers to enable export. - Go: pass `nil` to omit telemetry or set a non-empty endpoint/headers to enable; direct `StagehandInitParams` construction now requires `*TelemetryConfig`. <sup>Written for commit fecc5a6. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3045?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> <!-- external-contributor-pr:owned source-pr=2738 source-sha=e77c269fcc7ab33d2b76f213f26da62b77b1e826 claimer=miguelg719 --> --------- Co-authored-by: Abhinav Kumar Singh <[email protected]> Co-authored-by: miguel <[email protected]> Co-authored-by: Miguel <[email protected]>
Contributor
|
The mirrored PR #3045 has been merged into |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
why
The v4 init schema supplied
https://example.com/v1/traceswhenever callers omitted telemetry. The extension treated that placeholder as an intentional OTLP destination, creating guaranteed-failing background exports and possible shutdown delays for otherwise default Stagehand instances.Fixes #2732
what changed
stagehand.inittelemetry optional instead of injecting a placeholder endpoint.test plan
git diff --checkpassed.Summary by cubic
Makes telemetry export opt-in so omitted telemetry no longer injects a placeholder endpoint that caused guaranteed-failing exports and shutdown delays. Previously,
stagehand.initdefaulted tohttps://example.com/v1/traces; now, omitting telemetry leaves tracing inert and explicit telemetry keeps OTLP export.stagehand.init.telemetryis optional; defaults removed; schema and integrity/wire-casing tests updated.createStagehandTracing.configureacceptsundefinedand skips runtime; flush/shutdown are no-ops when telemetry is absent; tests cover this.telemetryfrom the wire when unset; Go generates*TelemetryConfigand sends partial configs (e.g., headers-only) while omitting the zero value; Python'stelemetryis optional with the default removed.@browserbasehq/stagehand,@browserbasehq/stagehand-go,@browserbasehq/stagehand-python, and@browserbasehq/stagehand-extension.Migration
telemetry.traces.endpointto your OTLP collector (must end with/v1/traces) and include required headers.nilto omit telemetry or set a non-emptyTelemetry.Traces.Endpoint(or headers) to enable export; value-style options are unchanged.Written for commit e77c269. Summary will update on new commits.