-
Notifications
You must be signed in to change notification settings - Fork 208
Introducing cachemetrics package #2156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
|
||
| go_library( | ||
| name = "go_default_library", | ||
| srcs = ["metrics.go"], | ||
| importpath = "github.com/pipe-cd/pipe/pkg/cache/cachemetrics", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@com_github_prometheus_client_golang//prometheus:go_default_library"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright 2021 The PipeCD Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package cachemetrics | ||
|
|
||
| import ( | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| ) | ||
|
|
||
| const ( | ||
| statusKey = "status" | ||
| sourceKey = "source" | ||
| ) | ||
|
|
||
| type StatusLabel string | ||
|
|
||
| const ( | ||
| LabelStatusHit StatusLabel = "hit" | ||
khanhtc1202 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| LabelStatusMiss StatusLabel = "miss" | ||
| ) | ||
|
|
||
| type SourceLabel string | ||
|
|
||
| const ( | ||
| LabelSourceRedis SourceLabel = "redis" | ||
khanhtc1202 marked this conversation as resolved.
Show resolved
Hide resolved
khanhtc1202 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| LabelSourceInmemory SourceLabel = "inmemory" | ||
| ) | ||
|
|
||
| var ( | ||
| getCounter = prometheus.NewCounterVec( | ||
| prometheus.CounterOpts{ | ||
| Name: "controlplane_cache_get_operation_total", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is prefix But it's okay to determine later.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ops, should be as your suggestion 🙏 lets me address it in this PR 🙏
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, already merged lol
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nakabonne plz #2157 🙏
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha! |
||
| Help: "Number of cache get operation while processing", | ||
| }, | ||
| []string{ | ||
| statusKey, | ||
| sourceKey, | ||
| }, | ||
| ) | ||
| ) | ||
|
|
||
| func Register(r prometheus.Registerer) { | ||
| r.MustRegister(getCounter) | ||
| } | ||
|
|
||
| func IncGetOperationCounter(status StatusLabel, source SourceLabel) { | ||
| getCounter.With(prometheus.Labels{ | ||
| statusKey: string(status), | ||
| sourceKey: string(source), | ||
| }).Inc() | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.