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

meshapi: follow best practice for metric names #722

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coordinator/meshapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newMeshAPIServer(meshAuth *authority.Authority, bundleGetter certBundleGett

attestationFailuresCounter := promauto.With(reg).NewCounter(prometheus.CounterOpts{
Subsystem: "contrast_meshapi",
Name: "attestation_failures",
Name: "attestation_failures_total",
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered creating a constant containing this value? We could reuse the constant in the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Might be a good idea if we want to use this in more places in the future, or must reference more label names elsewhere. But I think in general building up tests on metrics as insight isn't that good of a design.

Help: "Number of attestation failures from workloads to the Coordinator.",
})

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/architecture/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Coordinator](../deployment#verify-the-coordinator) respectively.
The `meshapi.MeshAPI` service records metrics for the method `NewMeshCert`, which
gets called by the [Initializer](../components#the-initializer) when starting a
new workload. Attestation failures from workloads to the Coordinator can be
tracked with the counter `contrast_meshapi_attestation_failures`.
tracked with the counter `contrast_meshapi_attestation_failures_total`.

The current manifest generation is exposed as a
[gauge](https://prometheus.io/docs/concepts/metric_types/#gauge) with the metric
Expand Down
4 changes: 2 additions & 2 deletions e2e/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ func getFailures(ctx context.Context, t *testing.T, ct *contrasttest.ContrastTes
require.NoError(err)
failures := -1
for k, v := range metrics {
if k == "contrast_meshapi_attestation_failures" {
if k == "contrast_meshapi_attestation_failures_total" {
failures = int(v.GetMetric()[0].GetCounter().GetValue())
}
}
if failures == -1 {
// metric not found
t.Error("metric \"contrast_meshapi_attestation_failures\" not found")
t.Error("metric \"contrast_meshapi_attestation_failures_total\" not found")
}
return failures
}