Documentation
¶
Overview ¶
Package telemetry provides OpenTelemetry metric helpers for the Apito engine. Open-core stays Prometheus-client-free; register a MeterProvider at process startup to export metrics (exporter choice is deployment-specific).
Index ¶
- Constants
- func EchoMiddleware(cfg *models.Config) echo.MiddlewareFunc
- func EchoRoutePattern(c interface{ ... }) string
- func HTTPInFlightDelta(ctx context.Context, cfg *models.Config, endpoint string, delta int64)
- func LatencyBuckets() []float64
- func MetricsEnabled(cfg *models.Config) bool
- func RecordCacheRequest(ctx context.Context, cfg *models.Config, layer, result string)
- func RecordDBOperation(ctx context.Context, cfg *models.Config, engine, op string, err error, ...)
- func RecordDDLApply(ctx context.Context, cfg *models.Config, engine, kind string, err error, ...)
- func RecordFunctionExecute(ctx context.Context, cfg *models.Config, plugin string, err error, ...)
- func RecordGraphQLOperation(ctx context.Context, cfg *models.Config, surface, operation, opName string, ...)
- func RecordHTTPRequest(ctx context.Context, cfg *models.Config, endpoint, method string, status int, ...)
- func RecordKVRequest(ctx context.Context, cfg *models.Config, op string, err error, d time.Duration)
- func RecordPoolAcquire(ctx context.Context, cfg *models.Config, projectID, engine string, err error, ...)
- func RecordQueueConsume(ctx context.Context, cfg *models.Config, queue string, err error, ...)
- func RecordQueueEnqueue(ctx context.Context, cfg *models.Config, queue string, err error)
- func RecordRESTToGraphQL(ctx context.Context, cfg *models.Config, model, method string, status int, ...)
- func RecordSessionValidate(ctx context.Context, cfg *models.Config, result string, d time.Duration)
- func RegisterConnectionManagerObservers(cfg *models.Config, cm ConnectionPoolStats)
- func StatusString(code int) string
- func WrapProjectDBWithMetrics(cfg *models.Config, engine string, inner interfaces.ProjectDBInterface) interfaces.ProjectDBInterface
- type ConnectionPoolStats
Constants ¶
const ObservePoolCallbackInterval = 10 * time.Second
ObservePoolCallbackInterval documents expected callback frequency from the metric reader.
Variables ¶
This section is empty.
Functions ¶
func EchoMiddleware ¶
func EchoMiddleware(cfg *models.Config) echo.MiddlewareFunc
EchoMiddleware returns Echo middleware that records apito_http_* metrics. Labels use Echo's route Path() to keep cardinality bounded.
func EchoRoutePattern ¶
EchoRoutePattern returns a bounded route label for metrics (Echo route path or fallback).
func HTTPInFlightDelta ¶
HTTPInFlightDelta adjusts the in-flight gauge (typically +1 before next, -1 in defer).
func LatencyBuckets ¶
func LatencyBuckets() []float64
LatencyBuckets returns standard histogram boundaries for request/operation latency (seconds).
func MetricsEnabled ¶
MetricsEnabled reports whether apito_* instruments should record (nil-safe).
func RecordCacheRequest ¶
RecordCacheRequest records cache hit/miss/err.
func RecordDBOperation ¶
func RecordDBOperation(ctx context.Context, cfg *models.Config, engine, op string, err error, d time.Duration)
RecordDBOperation records a non-DDL project DB call.
func RecordDDLApply ¶
func RecordDDLApply(ctx context.Context, cfg *models.Config, engine, kind string, err error, d time.Duration)
RecordDDLApply records DDL-style operations (schema/collection lifecycle).
func RecordFunctionExecute ¶
func RecordFunctionExecute(ctx context.Context, cfg *models.Config, plugin string, err error, d time.Duration)
RecordFunctionExecute records /function execution metrics.
func RecordGraphQLOperation ¶
func RecordGraphQLOperation(ctx context.Context, cfg *models.Config, surface, operation, opName string, err error, d time.Duration)
RecordGraphQLOperation records GraphQL execution metrics.
func RecordHTTPRequest ¶
func RecordHTTPRequest(ctx context.Context, cfg *models.Config, endpoint, method string, status int, d time.Duration)
RecordHTTPRequest records HTTP metrics after a request completes.
func RecordKVRequest ¶
func RecordKVRequest(ctx context.Context, cfg *models.Config, op string, err error, d time.Duration)
RecordKVRequest records a KV operation.
func RecordPoolAcquire ¶
func RecordPoolAcquire(ctx context.Context, cfg *models.Config, projectID, engine string, err error, d time.Duration)
RecordPoolAcquire records connection pool acquire latency.
func RecordQueueConsume ¶
func RecordQueueConsume(ctx context.Context, cfg *models.Config, queue string, err error, d time.Duration)
RecordQueueConsume records a consume/handling step.
func RecordQueueEnqueue ¶
RecordQueueEnqueue records a publish to the queue abstraction.
func RecordRESTToGraphQL ¶
func RecordRESTToGraphQL(ctx context.Context, cfg *models.Config, model, method string, status int, d time.Duration)
RecordRESTToGraphQL records REST bridge metrics.
func RecordSessionValidate ¶
RecordSessionValidate records token validation in middleware.
func RegisterConnectionManagerObservers ¶
func RegisterConnectionManagerObservers(cfg *models.Config, cm ConnectionPoolStats)
RegisterConnectionManagerObservers wires pool stats to OTel observable instruments (no import of database package).
func StatusString ¶
StatusString returns a three-digit status string for REST metrics.
func WrapProjectDBWithMetrics ¶
func WrapProjectDBWithMetrics(cfg *models.Config, engine string, inner interfaces.ProjectDBInterface) interfaces.ProjectDBInterface
WrapProjectDBWithMetrics returns inner wrapped with apito_db_* OTel recording when enabled.
Types ¶
type ConnectionPoolStats ¶
type ConnectionPoolStats interface {
GetDetailedStats() map[string]interface{}
}
ConnectionPoolStats is implemented by *database.ConnectionManager for observable pool metrics.