feat: Track LS startup with OpenTelemetry
Description
Adds OpenTelemetry (OTel) tracing and metrics to the Language Server startup monitor, following the suggestion in #2284 (closed) to use OTel instead of Snowplow for engineering insights.
I've tested different startup times on prod and we have some data coming to GitLab observability dashboard https://gitlab.com/groups/gitlab-org/-/observability/services. Select gitlab-vscode-extension in the list. The charts are default but I'll see how to configure them better for our purporses.
OTel resource attributes (set once for all spans/metrics)
ide_name, ide_vendor, ide_version, extension_name, extension_version, os, remote_name
ls.startup span attributes (per startup event)
Mirrors the existing Snowplow payload exactly: status, failed_phase, spawn_duration_ms, handshake_duration_ms, total_duration_ms, restart_attempts
ls.startup.duration histogram (per startup event)
Records total startup duration in ms with attributes: status, failed_phase, remote_name
Configuration
OTel is enabled when vscode.env.isTelemetryEnabled is true, same as Snowplow. The OTLP endpoint defaults to a hardcoded base URL and can be overridden via VS Code setting gitlab.telemetry.otlpEndpointUrl for local testing.
How to test locally
Traces only - Jaeger
Jaeger is an open-source distributed tracing UI that accepts OTLP data and lets you visualise spans in a browser.
- Start Jaeger locally (exposes OTLP HTTP on port
4318and the UI on port16686):docker run -p 16686:16686 -p 4318:4318 jaegertracing/all-in-one - Override the OTLP base URL in your VS Code
settings.json:"gitlab.telemetry.otlpEndpointUrl": "http://localhost:4318" - Launch the extension (F5) and let the Language Server start up.
- Open the Jaeger UI at http://localhost:16686, select the
gitlab-vscode-extensionservice, and click Find Traces to see thels.startupspan with all attributes.
Traces and metrics - Grafana LGTM
Grafana LGTM is an all-in-one Docker image that accepts OTLP for both traces and metrics, and provides a Grafana UI to visualise them.
- Start the Grafana LGTM container (exposes OTLP HTTP on port
4318and the Grafana UI on port3000):docker run -d --name grafana-lgtm -p 3000:3000 -p 4318:4318 grafana/otel-lgtm - Override the OTLP base URL in your VS Code
settings.json:"gitlab.telemetry.otlpEndpointUrl": "http://localhost:4318" - Launch the extension (F5) and let the Language Server start up.
- Open Grafana at http://localhost:3000 (admin/admin).
- Traces: Explore → Tempo → select
gitlab-vscode-extensionservice → find thels.startupspan with all attributes. - Metrics: Explore → Prometheus → query
ls_startup_durationto see the histogram.
- Traces: Explore → Tempo → select
Related Issues
References #2284 (closed)
What CHANGELOG entry will this MR create?
-
fix:Bug fix fixes - a user-facing issue in production - included in changelog -
feature:New feature - a user-facing change which adds functionality - included in changelog -
BREAKING CHANGE:(fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog - None - other non-user-facing changes
