Skip to content

Commit

Permalink
metric/coordinator: add clip metric to track vod clip jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
emranemran committed Oct 12, 2023
1 parent 33d192e commit c5cd1c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type CatalystAPIMetrics struct {
VODPipelineMetrics VODPipelineMetrics
}

var vodLabels = []string{"source_codec_video", "source_codec_audio", "pipeline", "catalyst_region", "num_profiles", "stage", "version", "is_fallback_mode", "is_livepeer_supported"}
var vodLabels = []string{"source_codec_video", "source_codec_audio", "pipeline", "catalyst_region", "num_profiles", "stage", "version", "is_fallback_mode", "is_livepeer_supported", "is_clip"}

func NewMetrics() *CatalystAPIMetrics {
m := &CatalystAPIMetrics{
Expand Down
7 changes: 5 additions & 2 deletions pipeline/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ func (c *Coordinator) finishJob(job *JobInfo, out *HandlerOutput, err error) {
config.Version,
strconv.FormatBool(job.inFallbackMode),
strconv.FormatBool(job.LivepeerSupported),
strconv.FormatBool(job.ClipStrategy.Enabled),
}

metrics.Metrics.VODPipelineMetrics.Count.
Expand Down Expand Up @@ -641,8 +642,9 @@ func (c *Coordinator) sendDBMetrics(job *JobInfo, out *HandlerOutput) {
"source_playback_at",
"download_done_at",
"segmenting_done_at",
"transcoding_done_at"
) values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22)`
"transcoding_done_at",
"is_clip"
) values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23)`
_, err := c.MetricsDB.Exec(
insertDynStmt,
time.Now().Unix(),
Expand All @@ -667,6 +669,7 @@ func (c *Coordinator) sendDBMetrics(job *JobInfo, out *HandlerOutput) {
job.DownloadDone.Unix(),
job.SegmentingDone.Unix(),
job.TranscodingDone.Unix(),
job.ClipStrategy.Enabled,
)
if err != nil {
log.LogError(job.RequestID, "error writing postgres metrics", err)
Expand Down
2 changes: 1 addition & 1 deletion pipeline/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func TestPipelineCollectedMetrics(t *testing.T) {

dbMock.
ExpectExec("insert into \"vod_completed\".*").
WithArgs(sqlmock.AnyArg(), 0, "123", sqlmock.AnyArg(), "vid codec", "audio codec", "stub", "test region", "completed", 1, sqlmock.AnyArg(), 2, 3, 4, 5, sourceFile, "s3+https://user:[email protected]/bucket/key", false, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()).
WithArgs(sqlmock.AnyArg(), 0, "123", sqlmock.AnyArg(), "vid codec", "audio codec", "stub", "test region", "completed", 1, sqlmock.AnyArg(), 2, 3, 4, 5, sourceFile, "s3+https://user:[email protected]/bucket/key", false, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), false).
WillReturnResult(sqlmock.NewResult(1, 1))

coord.StartUploadJob(job)
Expand Down

0 comments on commit c5cd1c2

Please sign in to comment.