Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions router/pkg/metric/otlp_metric_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ func (h *OtlpMetricStore) MeasureRequestError(ctx context.Context, opts ...otelm
}

func (h *OtlpMetricStore) MeasureOperationPlanningTime(ctx context.Context, planningTime float64, opts ...otelmetric.RecordOption) {
if planningTime >= upperTimeLimit {
h.logger.Info("otlp: the operation planning time upper limit", zap.Float64("planningTime", planningTime))
} else if planningTime >= timeLimit {
h.logger.Info("otlp: the operation planning time high", zap.Float64("planningTime", planningTime))
}

if c, ok := h.measurements.histograms[OperationPlanningTime]; ok {
c.Record(ctx, planningTime, opts...)
}
Expand Down
12 changes: 12 additions & 0 deletions router/pkg/metric/prom_metric_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ import (
otelmetric "go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/sdk/metric"
"go.uber.org/zap"
"time"
)

const (
cosmoRouterPrometheusMeterName = "cosmo.router.prometheus"
cosmoRouterPrometheusMeterVersion = "0.0.1"
)

const (
timeLimit = float64(5*time.Second) / float64(time.Millisecond)
upperTimeLimit = float64(10*time.Second) / float64(time.Millisecond)
)

type PromMetricStore struct {
meter otelmetric.Meter
meterProvider *metric.MeterProvider
Expand Down Expand Up @@ -139,6 +145,12 @@ func (h *PromMetricStore) MeasureRequestError(ctx context.Context, opts ...otelm
}

func (h *PromMetricStore) MeasureOperationPlanningTime(ctx context.Context, planningTime float64, opts ...otelmetric.RecordOption) {
if planningTime >= upperTimeLimit {
h.logger.Info("prometheus: the operation planning time upper limit", zap.Float64("planningTime", planningTime))
} else if planningTime >= timeLimit {
h.logger.Info("prometheus: the operation planning time high", zap.Float64("planningTime", planningTime))
}

if c, ok := h.measurements.histograms[OperationPlanningTime]; ok {
c.Record(ctx, planningTime, opts...)
}
Expand Down
Loading