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

Metrics: Add MetricBuilder to standardize metrics #3743

Conversation

rna-afk
Copy link
Contributor

@rna-afk rna-afk commented Jun 11, 2020

In order to make all the metrics uniform, the MetricBuilder
struct type is created with the option for storage, value setting,
and a type field. A build function is added which will create the
respective Prometheus Collector object based on the type of the
MetricBuilder and will automatically set the values and labels to
the collector object which can be used for pushing.

It also has a field for the description and the full name of the
metric for providing information about the metric generated. The field
bucket is used only for histogram.

@rna-afk rna-afk changed the title Metrics: Add MetricBuilder to standardize metrics [WIP] Metrics: Add MetricBuilder to standardize metrics Jun 11, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 11, 2020
Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

you need to vendor in prometheus. try to add that in a separate commit.

pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder_test.go Outdated Show resolved Hide resolved
@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch from 15d1fac to 1ac4cbc Compare June 11, 2020 14:51
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
pkg/metrics/metricbuilder/metricbuilder.go Outdated Show resolved Hide resolved
@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch 2 times, most recently from 7ea4e15 to 8e36a95 Compare June 15, 2020 15:52
Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

Regarding the initializer, perhaps we should consider something similar to this pattern: https://play.golang.org/p/VGl9olSFnNm

This would require setters for label key values and value. Curious if @abhinavdahiya has thoughts.

I think the semantics of this pattern has some nice benefits.

go.mod Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
@rna-afk
Copy link
Contributor Author

rna-afk commented Jun 23, 2020

Did see it thanks. Every time I try to solve it, it causes more problems. I will manually fix the entries now.

@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch 5 times, most recently from 210452b to 0bb52ad Compare June 25, 2020 16:56
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 25, 2020
@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch from 3353975 to 2aa53f6 Compare June 30, 2020 14:42
@rna-afk
Copy link
Contributor Author

rna-afk commented Jun 30, 2020

/retest

1 similar comment
@rna-afk
Copy link
Contributor Author

rna-afk commented Jun 30, 2020

/retest

@rna-afk rna-afk changed the title [WIP] Metrics: Add MetricBuilder to standardize metrics Metrics: Add MetricBuilder to standardize metrics Jun 30, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2020
Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

I think this is in really good shape.

pkg/metrics/builder/builder.go Outdated Show resolved Hide resolved
pkg/metrics/builder/builder_test.go Show resolved Hide resolved
pkg/metrics/builder/builder.go Show resolved Hide resolved
pkg/metrics/builder/builder_test.go Show resolved Hide resolved
})
}
}
func TestNewMetricBuilder(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment:

TestNewMetricBuilder tests the Metric Builder initializer.

Although I see now that this tests more than the iniitializer. I'm not sure if these are the most useful test cases. They are fine, but they don't test realistic errors/failure modes so I'm not sure if these add much value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.. do you have any kind of tests in mind? I thought that since this is just a struct with the metric type, there can only be some kind of validation tests and the significant tests can be done only when the API system is in place.

@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch from 2aa53f6 to 033e2f1 Compare July 2, 2020 15:50
@rna-afk
Copy link
Contributor Author

rna-afk commented Jul 6, 2020

/test e2e-aws-upgrade

2 similar comments
@rna-afk
Copy link
Contributor Author

rna-afk commented Jul 6, 2020

/test e2e-aws-upgrade

@rna-afk
Copy link
Contributor Author

rna-afk commented Jul 6, 2020

/test e2e-aws-upgrade

In order to make all the metrics uniform, the MetricBuilder
struct type is created with the option for storage, value setting,
and a type field. A build function is added which will create the
respective Prometheus Collector object based on the type of the
MetricBuilder and will automatically set the values and labels to
the collector object which can be used for pushing.

It also has a field for the description and the full name of the
metric for providing information about the metric generated. The field
bucket is used only for histogram.
Added the dependencies for prometheus in the vendor folder along
with some indirect dependencies.
@rna-afk rna-afk force-pushed the installer_telemetry_metric_builder branch from c2fc9c5 to 7ccc7cb Compare July 13, 2020 18:49
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jul 13, 2020

@rna-afk: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-ovirt 7ccc7cb link /test e2e-ovirt
ci/prow/e2e-libvirt 7ccc7cb link /test e2e-libvirt

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@abhinavdahiya
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 21, 2020
@patrickdillon
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 815f624 into openshift:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants