Add OTLP trace export and bump spannerotel to v0.2.0#67
Conversation
Introduce --experimental-trace-otlp for local OpenTelemetry collectors, set service.name via spannerotel v0.2.0, and document PROFILE plan spans. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for exporting OpenTelemetry spans via OTLP/gRPC to a local collector, introducing the --experimental-trace-otlp and --experimental-trace-otlp-endpoint CLI flags, updating the documentation, and upgrading dependencies. A critical issue was identified in trace.go where checking n != 1 for mutually exclusive flags prevents the optional case (where no tracing flags are set) from falling through to the default configuration, incorrectly triggering an error instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if n != 1 { | ||
| return tracing.Config{}, fmt.Errorf("exactly one of --experimental-trace-otlp, --experimental-trace-stdout, or --experimental-trace-project must be set") | ||
| } |
There was a problem hiding this comment.
By checking n != 1, any case where no tracing flags are set (n == 0) will trigger the error exactly one of ... must be set. This makes the default branch in the switch statement (which returns tracing is not configured) completely unreachable.
Additionally, if traceConfig is called when tracing is disabled, the error message claiming that one of the flags must be set is misleading. Changing the check to n > 1 allows the n == 0 case to correctly fall through to the default branch.
| if n != 1 { | |
| return tracing.Config{}, fmt.Errorf("exactly one of --experimental-trace-otlp, --experimental-trace-stdout, or --experimental-trace-project must be set") | |
| } | |
| if n > 1 { | |
| return tracing.Config{}, fmt.Errorf("at most one of --experimental-trace-otlp, --experimental-trace-stdout, or --experimental-trace-project can be set") | |
| } |
References
- When configuring mutually exclusive CLI flags, omit the required constraint if the flags are optional as a group, allowing the user to specify none of them.
Summary
--experimental-trace-otlpand--experimental-trace-otlp-endpointfor local OpenTelemetry collectors (xor with Cloud Trace and stderr export).spannerotelto v0.2.0 (OTLP export,service.nameresource).Test plan
go test ./...Made with Cursor