-
Notifications
You must be signed in to change notification settings - Fork 67
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
Rename indexer metrics related to get operations #853
Changes from 2 commits
02fb0ad
6d32e1a
da35579
b56f239
85fae6d
7d64c94
8e810cb
7d15558
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 |
---|---|---|
|
@@ -68,7 +68,7 @@ var ( | |
func init() { | ||
flag.BoolVar(&printVersionInfo, "version", false, "Print Elastic Package Registry version") | ||
flag.StringVar(&address, "address", "localhost:8080", "Address of the package-registry service.") | ||
flag.StringVar(&metricsAddress, "metrics-address", "", "Address to expose the Prometheus metrics.") | ||
flag.StringVar(&metricsAddress, "metrics-address", "", "Address to expose the Prometheus metrics (experimental). ") | ||
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. Just a minor change here to add this Prometheus metric endpoint is subject to changes. 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. Sounds good to me, we may redefine something else while we start using it. |
||
flag.StringVar(&tlsCertFile, "tls-cert", "", "Path of the TLS certificate.") | ||
flag.StringVar(&tlsKeyFile, "tls-key", "", "Path of the TLS key.") | ||
flag.StringVar(&configPath, "config", "config.yml", "Path to the configuration file.") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,32 +39,33 @@ var ( | |
prometheus.CounterOpts{ | ||
Namespace: metricsNamespace, | ||
Name: "storage_indexer_update_index_success_total", | ||
Help: "A counter for updates of the cursor.", | ||
Help: "A counter for updates of the cursor in the storage indexer.", | ||
}, | ||
) | ||
|
||
StorageIndexerUpdateIndexErrorsTotal = prometheus.NewCounter( | ||
prometheus.CounterOpts{ | ||
Namespace: metricsNamespace, | ||
Name: "storage_indexer_update_index_error_total", | ||
Help: "A counter for all the update index processes that finished with error.", | ||
Help: "A counter for all the update index processes that finished with error in the storage indexer.", | ||
}, | ||
) | ||
|
||
StorageIndexerUpdateIndexDurationSeconds = prometheus.NewHistogram( | ||
prometheus.HistogramOpts{ | ||
Namespace: metricsNamespace, | ||
Name: "storage_indexer_update_index_duration_seconds", | ||
Help: "A histogram of latencies for update index processes run by the indexer.", | ||
Help: "A histogram of latencies for update index processes run by the storage indexer.", | ||
}, | ||
) | ||
|
||
StorageIndexerGetDurationSeconds = prometheus.NewHistogram( | ||
IndexerGetDurationSeconds = prometheus.NewHistogramVec( | ||
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. Umm, I am wondering how useful is this metric. Looking at the sample metrics in the description, they seem to be all quite fast as these operations happen mostly in memory, and they end up all in the lower bucket. So I wonder if maybe we can remove this metric. Or if we leave it, lower the boundaries of each bucket so they don't end up all in the lower bucket. 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. Currently I don't have data about these get operations in the storage indexer. 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. Well, current implementations are only filtering a list in memory. But it is true that the operation in the storage indexer is in a mutex whose lock can have some wait time while the index is updated. We may revisit the bucket thresholds when we have more data. |
||
prometheus.HistogramOpts{ | ||
Namespace: metricsNamespace, | ||
Name: "storage_indexer_get_duration_seconds", | ||
Name: "indexer_get_duration_seconds", | ||
Help: "A histogram of latencies for get processes run by the indexer.", | ||
}, | ||
[]string{"indexer"}, | ||
) | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
|
||
"cloud.google.com/go/storage" | ||
"github.com/pkg/errors" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"go.uber.org/zap" | ||
|
||
"github.com/elastic/package-registry/metrics" | ||
|
@@ -31,6 +32,8 @@ type Indexer struct { | |
m sync.RWMutex | ||
|
||
resolver packages.RemoteResolver | ||
|
||
label string | ||
} | ||
|
||
type IndexerOptions struct { | ||
|
@@ -43,6 +46,7 @@ func NewIndexer(storageClient *storage.Client, options IndexerOptions) *Indexer | |
return &Indexer{ | ||
storageClient: storageClient, | ||
options: options, | ||
label: "StorageIndexer", | ||
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. Hm.. could it be a const instead of a structure field? 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. I wanted to follow the same structure that it is used for FileSystemIndexers (link) where the label is part of the struct. But it is true that for storage indexer it is not needed to add that label as a field struct. So, I'll move it to be a const. |
||
} | ||
} | ||
|
||
|
@@ -173,6 +177,9 @@ func (i *Indexer) updateIndex(ctx context.Context) error { | |
} | ||
|
||
func (i *Indexer) Get(ctx context.Context, opts *packages.GetOptions) (packages.Packages, error) { | ||
start := time.Now() | ||
defer metrics.IndexerGetDurationSeconds.With(prometheus.Labels{"indexer": i.label}).Observe(time.Since(start).Seconds()) | ||
|
||
i.m.RLock() | ||
defer i.m.RUnlock() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be moved to another section in the changelog ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can fit as a bugfix 🙂 Though it could be also seen as a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bugfix is fine :)