memory-bank/components/ide-metrics.md
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:
The IDE Metrics component is built as a Go service with several key components:
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 configurationThe 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:
The IDE Metrics component implements several security measures:
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 endpointcomponents/common-go: Common Go utilitiescomponents/ide-metrics-api: API definitionsThe IDE Metrics component integrates with:
The IDE Metrics component is typically used to: