The IDE Metrics component is a service in Gitpod that collects, processes, and exposes metrics and error reports from various IDE components. It provides a centralized way to gather performance data, usage statistics, and error information from IDE-related components such as the supervisor, VS Code extensions, and web workbenches.
The primary purposes of the IDE Metrics component are:
- Collect metrics from IDE components
- Process and validate metric data
- Expose metrics in Prometheus format
- Handle error reporting from IDE components
- Provide a gRPC and REST API for metrics submission
- Support aggregated histogram metrics for efficient data collection
- Implement security measures through label allowlists
- Enable monitoring of IDE performance and usage
The IDE Metrics component is built as a Go service with several key components:
- Metrics Server: Core server that handles gRPC and HTTP requests
- Metrics Registry: Manages Prometheus metrics
- Error Reporter: Processes and forwards error reports
- Label Validator: Validates metric labels against allowlists
- Aggregated Histograms: Efficiently handles histogram data
The component exposes both gRPC and HTTP endpoints for metrics submission and provides a Prometheus-compatible endpoint for metrics scraping.
main.go
: Entry point for the applicationcmd/root.go
: Command-line interface setupcmd/run.go
: Main server run commandpkg/server/server.go
: Core server implementationpkg/metrics/
: Metrics handling utilitiespkg/errorreporter/
: Error reporting functionalityconfig-example.json
: Example configuration
The IDE Metrics component supports several types of metrics:
Simple counters that can be incremented or added to, used for tracking occurrences of events.
Record observations in buckets, used for measuring durations or sizes.
Efficiently handle pre-aggregated histogram data, reducing the number of individual metric submissions.
The component includes an error reporting system that:
- Validates error reports against an allowlist of components
- Structures error data with contextual information
- Forwards errors to an error reporting service
- Includes workspace and user context with errors
The IDE Metrics component implements several security measures:
- Validates metric labels against configured allowlists
- Replaces invalid labels with default or "unknown" values
- Logs unexpected label names or values
- Prevents metric explosion from arbitrary labels
- Validates error reporting components against an allowlist
- Prevents unauthorized components from submitting errors
- Logs attempts from unexpected components
The IDE Metrics component is configured through a JSON configuration file:
{
"server": {
"port": 9500,
"counterMetrics": [
{
"name": "example_counter",
"help": "Example counter metric",
"labels": [
{
"name": "label1",
"allowValues": ["value1", "value2"],
"defaultValue": "unknown"
}
]
}
],
"histogramMetrics": [...],
"aggregatedHistogramMetrics": [...],
"errorReporting": {
"allowComponents": ["supervisor", "vscode-web"]
}
},
"prometheus": {
"addr": "localhost:9500"
}
}
The IDE Metrics component exposes several API endpoints:
/metrics-api/
: Base path for all API requests/metrics
: Prometheus metrics endpoint
components/common-go
: Common Go utilitiescomponents/ide-metrics-api
: API definitions
- Prometheus client for metrics
- gRPC for API communication
- gRPC-web for browser compatibility
- cmux for multiplexing connections
The IDE Metrics component integrates with:
- Supervisor: Submits metrics and error reports
- VS Code Extensions: Submit metrics and error reports
- Web Workbench: Submits metrics and error reports
- Prometheus: Scrapes exposed metrics
- Error Reporting Service: Receives error reports
The IDE Metrics component is typically used to:
- Track IDE performance metrics
- Monitor feature usage
- Collect error reports from IDE components
- Generate dashboards for IDE health and usage
- Identify performance bottlenecks
- IDE Service: Configures and manages IDEs
- IDE Proxy: Proxies requests to IDE Metrics
- Supervisor: Submits metrics and error reports
- Dashboard: May display metrics data