forked from mtusi2026/mtusi2026lab5
fix: expose pipeline health metrics
This commit is contained in:
@@ -11,6 +11,11 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
var (
|
||||
requestDurationBuckets = []float64{0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 20, 30}
|
||||
uploadDurationBuckets = []float64{0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 20, 30, 60}
|
||||
)
|
||||
|
||||
type metrics struct {
|
||||
requests *prometheus.CounterVec
|
||||
duration *prometheus.HistogramVec
|
||||
@@ -36,7 +41,7 @@ func newMetrics() *metrics {
|
||||
Subsystem: "http",
|
||||
Name: "request_duration_seconds",
|
||||
Help: "HTTP request duration in seconds.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
Buckets: requestDurationBuckets,
|
||||
}, []string{"method", "route"}),
|
||||
inFlight: prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "messenger",
|
||||
@@ -59,7 +64,7 @@ func newMetrics() *metrics {
|
||||
Namespace: "messenger",
|
||||
Name: "attachment_upload_duration_seconds",
|
||||
Help: "Attachment upload duration in seconds.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
Buckets: uploadDurationBuckets,
|
||||
}),
|
||||
attachmentBytes: prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: "messenger",
|
||||
|
||||
@@ -90,8 +90,8 @@ func (s attachmentServiceStub) Metadata(context.Context, string, string) (model.
|
||||
func (s attachmentServiceStub) Content(context.Context, string, string, string) (attachment.Content, error) {
|
||||
return attachment.Content{
|
||||
Attachment: s.uploaded,
|
||||
Variant: model.Variant{ContentType: s.uploaded.ContentType, SizeBytes: s.uploaded.SizeBytes},
|
||||
Body: io.NopCloser(strings.NewReader("content")),
|
||||
Variant: model.Variant{ContentType: s.uploaded.ContentType, SizeBytes: s.uploaded.SizeBytes},
|
||||
Body: io.NopCloser(strings.NewReader("content")),
|
||||
}, s.err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user