[skip-tag:sdk] feat(sdk): additive OTel instrumentation (1/4)#74
Merged
Conversation
- sdk/telemetry: OTLPConfig + WithOTLP{Trace,Meter,Log} option helpers
with optErr propagation through Init{Tracer,Meter,Log}.
- sdk/event: Envelope.SpanContext / WithRemoteContext for cross-process
OTel trace correlation via existing TraceID/SpanID fields.
- sdk/engine: TracingMiddleware HostMiddleware that wraps Publish, AskUser,
Checkpoint, ReportUsage in spans; Interrupts is intentionally not traced.
All changes are additive; no public API removed.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Part 1 of 4 in the v0.2.x additive SDK batch. Tagging is suppressed on
this PR via
[skip-tag:sdk]; a singlesdk/v0.2.9tag will be cut afterPR 4/4 merges.
This PR introduces additive OpenTelemetry instrumentation across
sdk/telemetry,sdk/event, andsdk/engine. No public API is removed or altered.sdk/telemetry — OTLP exporter helpers
OTLPConfig(endpoint, headers, insecure, timeout, compression).WithOTLPTraceExporter/WithOTLPMeterExporter/WithOTLPLogProcessoroptions that build OTLP/HTTP exporters.
Init{Tracer,Meter,Log}now surface option-time configuration errors via anew internal
optErrfield — option functions can't return errors directly,so this lets exporter construction failures bubble up through
Init*insteadof panicking later.
sdk/event — OTel span context on envelopes
Envelope.SpanContext()reconstructs an OTeltrace.SpanContext(markedRemote: true) from the existingTraceID/SpanIDfields.Envelope.WithRemoteContext(ctx)injects that span context into a childcontext so downstream consumers can start linked spans across process
boundaries (events bus → worker → tracer).
sdk/engine — Tracing host middleware
TracingMiddleware()is aHostMiddlewarethat decoratesHost.Publish,AskUser,Checkpoint,ReportUsagewith OTel spans.Interrupts()is intentionally not traced — it is a hot, non-blockingchannel accessor and tracing it would dominate spans.
flowcraft.run.id,flowcraft.event.subject,flowcraft.checkpoint.exec_id, etc.) and errorsare recorded via
span.RecordError+codes.Error.Test plan
go vet ./telemetry/... ./event/... ./engine/...go test ./telemetry/... ./event/... ./engine/... -count=1sdk/telemetry/otlp_test.go— mock OTLP/HTTP collector verifies tracedelivery.
sdk/event/trace_test.go— round-trips trace/span ID throughEnvelopeand confirms child-span linkage.
sdk/engine/middleware_otel_test.go— span creation, attribute population,error recording for each wrapped Host method.
Release notes
This PR is additive only; tagging is intentionally skipped. The cumulative
sdk/v0.2.9tag will be created on the final PR (4/4) of this batch.Made with Cursor