* feat(server): moved an http server object into a pkg subdir to be reusable for http, spots, and integrations * feat(web): isolated web module (server, router, middleware, utils) used in spots and new integrations * feat(web): removed possible panic * feat(web): split all handlers from http service into different packages for better management. * feat(web): changed router's method signature * feat(web): added missing handlers interface * feat(web): added health middleware to remove unnecessary checks * feat(web): customizable middleware set for web servers * feat(web): simplified the handler's structure * feat(web): created an unified server.Run method for all web services (http, spot, integrations) * feat(web): fixed a json size limit issue * feat(web): removed Keys and PG connection from router * feat(web): simplified integration's main file * feat(web): simplified spot's main file * feat(web): simplified http's main file (builder) * feat(web): refactored audit trail functionality * feat(web): added ee version of audit trail * feat(web): added ee version of conditions module * feat(web): moved ee version of some web session structs * feat(web): new format of web metrics * feat(web): added new web metrics to all handlers * feat(web): added justExpired feature to web ingest handler * feat(web): added small integrations improvements
149 lines
4 KiB
Go
149 lines
4 KiB
Go
package spot
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"openreplay/backend/pkg/metrics/common"
|
|
)
|
|
|
|
var spotOriginalVideoSize = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "original_video_size_bytes",
|
|
Help: "A histogram displaying the size of each original video in bytes.",
|
|
Buckets: common.VideoSizeBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordOriginalVideoSize(size float64) {
|
|
spotOriginalVideoSize.Observe(size)
|
|
}
|
|
|
|
var spotCroppedVideoSize = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "cropped_video_size_bytes",
|
|
Help: "A histogram displaying the size of each cropped video in bytes.",
|
|
Buckets: common.VideoSizeBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordCroppedVideoSize(size float64) {
|
|
spotCroppedVideoSize.Observe(size)
|
|
}
|
|
|
|
var spotVideosTotal = prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Namespace: "spot",
|
|
Name: "videos_total",
|
|
Help: "A counter displaying the total number of all processed videos.",
|
|
},
|
|
)
|
|
|
|
func IncreaseVideosTotal() {
|
|
spotVideosTotal.Inc()
|
|
}
|
|
|
|
var spotVideosCropped = prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Namespace: "spot",
|
|
Name: "videos_cropped_total",
|
|
Help: "A counter displaying the total number of all cropped videos.",
|
|
},
|
|
)
|
|
|
|
func IncreaseVideosCropped() {
|
|
spotVideosCropped.Inc()
|
|
}
|
|
|
|
var spotVideosTranscoded = prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Namespace: "spot",
|
|
Name: "videos_transcoded_total",
|
|
Help: "A counter displaying the total number of all transcoded videos.",
|
|
},
|
|
)
|
|
|
|
func IncreaseVideosTranscoded() {
|
|
spotVideosTranscoded.Inc()
|
|
}
|
|
|
|
var spotOriginalVideoDownloadDuration = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "original_video_download_duration_seconds",
|
|
Help: "A histogram displaying the duration of downloading each original video in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordOriginalVideoDownloadDuration(durMillis float64) {
|
|
spotOriginalVideoDownloadDuration.Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
var spotCroppingDuration = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "cropping_duration_seconds",
|
|
Help: "A histogram displaying the duration of cropping each video in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordCroppingDuration(durMillis float64) {
|
|
spotCroppingDuration.Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
var spotCroppedVideoUploadDuration = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "cropped_video_upload_duration_seconds",
|
|
Help: "A histogram displaying the duration of uploading each cropped video in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordCroppedVideoUploadDuration(durMillis float64) {
|
|
spotCroppedVideoUploadDuration.Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
var spotTranscodingDuration = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "transcoding_duration_seconds",
|
|
Help: "A histogram displaying the duration of transcoding each video in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordTranscodingDuration(durMillis float64) {
|
|
spotTranscodingDuration.Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
var spotTranscodedVideoUploadDuration = prometheus.NewHistogram(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "transcoded_video_upload_duration_seconds",
|
|
Help: "A histogram displaying the duration of uploading each transcoded video in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
)
|
|
|
|
func RecordTranscodedVideoUploadDuration(durMillis float64) {
|
|
spotTranscodedVideoUploadDuration.Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
func List() []prometheus.Collector {
|
|
return []prometheus.Collector{
|
|
spotOriginalVideoSize,
|
|
spotCroppedVideoSize,
|
|
spotVideosTotal,
|
|
spotVideosCropped,
|
|
spotVideosTranscoded,
|
|
spotOriginalVideoDownloadDuration,
|
|
spotCroppingDuration,
|
|
spotCroppedVideoUploadDuration,
|
|
spotTranscodingDuration,
|
|
spotTranscodedVideoUploadDuration,
|
|
}
|
|
}
|