Skip to content
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

Support Block Adapter metrics with adapter_stats_id #8680

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

itaigilo
Copy link
Contributor

@itaigilo itaigilo commented Feb 17, 2025

Closes #8672.

Change Description

Currently, the Block Adapters that use reportMetrics only report with operation and isErrStr labels -
Adding another adapter_stats_id label to it, to allow better tracing.

@itaigilo itaigilo added exclude-changelog PR description should not be included in next release changelog msb labels Feb 17, 2025
Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

14 passed

Copy link

E2E Test Results - Quickstart

11 passed

@itaigilo itaigilo marked this pull request as ready for review February 17, 2025 20:27
@itaigilo itaigilo changed the title Support Block Adapter stats tag Support Block Adapter stats blockstoreTag Feb 18, 2025
@itaigilo itaigilo requested review from arielshaqed and a team February 20, 2025 10:49
@itaigilo itaigilo requested review from N-o-Z, nadavsteindler and guy-har and removed request for a team February 21, 2025 19:51
@arielshaqed
Copy link
Contributor

Not sure what I'm meant to review here: PR says "stats", code says "metrics". I think we need only to rename the PR - if it's about stats then we might need to do rather different things.

@itaigilo
Copy link
Contributor Author

Not sure what I'm meant to review here: PR says "stats", code says "metrics". I think we need only to rename the PR - if it's about stats then we might need to do rather different things.

Well, let's have it written:
When you write stats, you mean the pkg/stats package?
And when you write metrics, you mean everything that's grafana/prometheus related?

If so, not the mix, since the stats.go files are handling prometheus stuff...

Having said that, I don't mind renaming this PR 😄

@itaigilo itaigilo changed the title Support Block Adapter stats blockstoreTag Support Block Adapter metrics with adapter_stats_id Feb 24, 2025
Copy link
Contributor

@guy-har guy-har left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, requesting changes mostly because of the label name, that I'm not sure what it means

adapterStatsID *string
}

func BuildHistogramsInstance(name string, adapterStatsID *string) Histograms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is adapterStatsID? not sure what this means, please change name or document

func BuildHistogramsInstance(name string, adapterStatsID *string) Histograms {
labelNames := []string{"operation", "error"}
if adapterStatsID != nil {
labelNames = append(labelNames, "adapter_stats_id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the label, I have no idea what this represents

Comment on lines +178 to +180
if s.adapterStatsID != nil {
labels = append(labels, *s.adapterStatsID)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker (thinking out load), but this one disturbs me a bit, why do we need to check every report? It's a bit weird that we have a label that is added only in some cases.
Maybe having two instead of making it generic, or providing getDurationHistogramWithLables. Also maybe moving the optional to the beginning will be safer because we tend to add labels to the end.
IMO just add the label, for everyone, it shouldn't affect too much if it has only one value

durationHistograms.WithLabelValues(operation, isErrStr).Observe(time.Since(start).Seconds())
if sizeBytes != nil {
requestSizeHistograms.WithLabelValues(operation, isErrStr).Observe(float64(*sizeBytes))
func NewS3Stats(adapterStatsID *string) block.Histograms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func NewS3Stats(adapterStatsID *string) block.Histograms {
func NewStats(adapterStatsID *string) block.Histograms {

durationHistograms.WithLabelValues(operation, isErrStr).Observe(time.Since(start).Seconds())
if sizeBytes != nil {
requestSizeHistograms.WithLabelValues(operation, isErrStr).Observe(float64(*sizeBytes))
func NewAzureStats(adapterStatsID *string) block.Histograms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func NewAzureStats(adapterStatsID *string) block.Histograms {
func NewStats(adapterStatsID *string) block.Histograms {

Copy link
Contributor

@guy-har guy-har left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes again but this one is critical.
We can't initiate the same adapter twice, which raises the question, how was this tested? Did we try this out for two Adapters with same name and different AdapterStatID?

Comment on lines +152 to +158
var durationHistograms = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: name + "_operation_duration_seconds",
Help: "durations of outgoing " + name + " operations",
},
labelNames,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is an issue here, each histogram can be initiated one time per name, otherwise it will panic. This means that:

  1. We can't initiate a block adapter twice!
  2. Don't think this can be used for 2 different adapterStatesIDs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude-changelog PR description should not be included in next release changelog msb
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow label in Metrics Adapter
3 participants