memory-bank/components/ide-metrics-api.md
The IDE Metrics API defines the gRPC interfaces for collecting metrics and error reports from IDE components within the Gitpod platform. It provides a standardized way for IDE instances to report performance data and errors to a central metrics service.
This API enables:
The IDE Metrics API is implemented as a gRPC service defined in Protocol Buffer files. These definitions are used to generate client and server code in various languages (Go, TypeScript, Java) for use by IDE components and the metrics collection service.
Provides methods for reporting metrics and errors:
AddCounter: Increments a counter metric with specified labelsObserveHistogram: Records an observation in a histogram metricAddHistogram: Adds pre-aggregated histogram datareportError: Reports an error with detailed context informationThe API supports two primary metric types:
Error reports include:
The API uses Protocol Buffers version 3 (proto3) syntax, which provides forward and backward compatibility features. The service is designed to allow for the addition of new metric types and error reporting fields without breaking existing clients.
The IDE Metrics API uses Protocol Buffers and gRPC for defining interfaces. When changes are made to the .proto files, the corresponding code in various languages needs to be regenerated.
To regenerate the code:
Navigate to the ide-metrics-api directory:
cd components/ide-metrics-api
Run the generate script:
./generate.sh
This script performs the following actions:
protoc-gen-go and protoc-gen-go-grpcThe IDE Metrics API is unique in that it generates both gRPC and REST API endpoints using the gRPC Gateway, and it also generates Java code for use in JetBrains IDE plugins.
After regenerating the code, you may need to rebuild components that depend on the IDE Metrics API. This typically involves:
For Go components:
cd <component-directory>
go build ./...
For TypeScript components:
cd <component-directory>
yarn install
yarn build
For Java components:
cd <component-directory>/java
./gradlew build
Using Leeway (for CI/CD):
leeway build -D components/<component-name>:app