Skip to content

Commit

Permalink
Merge pull request #280 from cdnjs/sven/r2-metrics-file-ext
Browse files Browse the repository at this point in the history
split R2 pump metrics by file extension
  • Loading branch information
xtuc authored Feb 6, 2024
2 parents ce7815a + 84e3ed8 commit a7f4f32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion functions/r2-pump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func Invoke(ctx context.Context, e gcp.GCSEvent) error {
if err := audit.WroteR2(ctx, pkgName, version, keys, FILE_EXTENSION); err != nil {
log.Printf("failed to audit: %s\n", err)
}
if err := metrics.NewUpdatePublishedR2(); err != nil {
if err := metrics.NewUpdatePublishedR2(FILE_EXTENSION); err != nil {
return errors.Wrap(err, "could not report metrics")
}

Expand Down
20 changes: 13 additions & 7 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,42 @@ var (
)

type IncMetricPayload struct {
Name string `json:"name"`
Name string `json:"name"`
Labels []string `json:"labels"`
}

func NewUpdateDetected() error {
return sendMetrics(&IncMetricPayload{
Name: "new_update_detected",
Name: "new_update_detected",
Labels: make([]string, 0),
})
}

func NewUpdateProccessed() error {
return sendMetrics(&IncMetricPayload{
Name: "new_update_processed",
Name: "new_update_processed",
Labels: make([]string, 0),
})
}

func NewUpdatePublishedKV() error {
return sendMetrics(&IncMetricPayload{
Name: "new_update_published_kv",
Name: "new_update_published_kv",
Labels: make([]string, 0),
})
}

func NewUpdatePublishedR2() error {
func NewUpdatePublishedR2(ext string) error {
return sendMetrics(&IncMetricPayload{
Name: "new_update_published_r2",
Name: "new_update_published_r2",
Labels: []string{ext},
})
}

func NewUpdatePublishedAlgolia() error {
return sendMetrics(&IncMetricPayload{
Name: "new_update_published_algolia",
Name: "new_update_published_algolia",
Labels: make([]string, 0),
})
}

Expand Down

0 comments on commit a7f4f32

Please sign in to comment.