* feat(spot): first version to test http endpoints * fix(helm): changed nginx path prefix * fix(spots): added missing BUCKET_NAME env var * fix(spots): added services init check * feat(spots): removed geo module * feat(spots): removed uaparser * feat(spots): added more detailed authorization error log * feat(spots): changed the authorization middleware * feat(spots): extended http body size limit to 128kb * feat(spots): added s3 error log * feat(spots): added new handler for uploaded event * feat(backend): small api changes in spot service * feat(backend): rewrote request parameters grabber for getSpot handler * feat(backend): added tenantID to auth struct * feat(backend): added pre-signed download urls for preview, mob et video files * feat(backend): added user's email to spots table, and getSpot responses * feat(backend): returning spotID as a string * feat(spot): added transcoder pipeline * fix(spot): return spotID as a string * feat(spot): added volume mount to spot service * feat(spot): fixed volume mounting * feat(spot): helm fix * feat(spot): helm another fix * fix(spot): correct video.webm path * fix(spot): correct pre-signed url for download original video * feat(spot): added PATCH and DELETE methods to CORS * feat(spot): use string format for spotIDs in delete method * feat(spot): added public key implemented * fix(spot): correct public-key parser * fix(spot): fixed query params issue + user's tenantID * fix(spot): use 1 as a default tenant * feat(spot): added correct total spots calculation * fix(spot): fixed offset calculation * feat(spot): added extra check in auth method * fix(spot): removed / from video file name * fix(spot): devided codec flag into 2 parts * feat(spot): use fixed tenantID = 1 for oss users * feat(spot): return 404 for public key not found issue * feat(spots): added spots folder to minio path rule * feat(spot): added spot video streaming support * fix(spot): fixed an sql request for spot streams * feat(spot): return playlist file in getSpot responce * feat(spot): try to use aac audio codec * feat(spot): added permissions support (oss/ee) * feat(spot): added authorizer method * feat(spot): added license check * feat(spot): added spot preview for get response * fix(spot): fixed a problem with permissions * feat(spot): added crop feature * feat(spot): upload cropped video back to s3 * feat(spot): manage expired modified playlist file * feat(backend): hack with video formats * feat(backend): removed space * feat(spot): req tracing * feat(spot): manual method's name mapping * feat(spot): added a second method to public key auth support * feat(spot): metrics * feat(spot): added rate limiter per user * feat(spot): added ping endpoint for spot jwt token check * feat(spot): getStatus endpoint * feat(spot): added missing import * feat(spot): transcoding issue fix * feat(spot): temp remove tasks * feat(spot): better error log message * feat(spot): set default jwt_secret value * feat(spot): debug auth * feat(spot): 2 diff jwt tokens support * feat(spot): pg tasks with process status * feat(spot): more logs * feat(spot): improved defer for GetTask method * feat(spot): keep only failed tasks * feat(spot): removing temp dir with spot files * feat(spot): added several workers for transcoding module * feat(spot): fixed spot path for temp video files * feat(spot): use custom statusWriter to track response code in middleware * feat(spot): added body and parameter parser for auditrail feature * feat(spot): fixed IsAuth method signature * feat(spot): fixed ee service builder * feat(spot): added import * feat(spot): fix data type for payload and parameters jsonb fields * feat(spot): typo fix * feat(spot): moved out consts * feat(spot): new table's name * feat(spot): added missing imports in go.mod * feat(spot): added a check for the number of comments (20 by default)
194 lines
5.2 KiB
Go
194 lines
5.2 KiB
Go
package spot
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"openreplay/backend/pkg/metrics/common"
|
|
)
|
|
|
|
var spotRequestSize = prometheus.NewHistogramVec(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "request_size_bytes",
|
|
Help: "A histogram displaying the size of each HTTP request in bytes.",
|
|
Buckets: common.DefaultSizeBuckets,
|
|
},
|
|
[]string{"url", "response_code"},
|
|
)
|
|
|
|
func RecordRequestSize(size float64, url string, code int) {
|
|
spotRequestSize.WithLabelValues(url, strconv.Itoa(code)).Observe(size)
|
|
}
|
|
|
|
var spotRequestDuration = prometheus.NewHistogramVec(
|
|
prometheus.HistogramOpts{
|
|
Namespace: "spot",
|
|
Name: "request_duration_seconds",
|
|
Help: "A histogram displaying the duration of each HTTP request in seconds.",
|
|
Buckets: common.DefaultDurationBuckets,
|
|
},
|
|
[]string{"url", "response_code"},
|
|
)
|
|
|
|
func RecordRequestDuration(durMillis float64, url string, code int) {
|
|
spotRequestDuration.WithLabelValues(url, strconv.Itoa(code)).Observe(durMillis / 1000.0)
|
|
}
|
|
|
|
var spotTotalRequests = prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Namespace: "spot",
|
|
Name: "requests_total",
|
|
Help: "A counter displaying the number all HTTP requests.",
|
|
},
|
|
)
|
|
|
|
func IncreaseTotalRequests() {
|
|
spotTotalRequests.Inc()
|
|
}
|
|
|
|
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{
|
|
spotRequestSize,
|
|
spotRequestDuration,
|
|
spotTotalRequests,
|
|
spotOriginalVideoSize,
|
|
spotCroppedVideoSize,
|
|
spotVideosTotal,
|
|
spotVideosCropped,
|
|
spotVideosTranscoded,
|
|
spotOriginalVideoDownloadDuration,
|
|
spotCroppingDuration,
|
|
spotCroppedVideoUploadDuration,
|
|
spotTranscodingDuration,
|
|
spotTranscodedVideoUploadDuration,
|
|
}
|
|
}
|