Skip to content

Commit

Permalink
Remove non-specific webhook request metrics (open-policy-agent#1428)
Browse files Browse the repository at this point in the history
As g8r once had only a validation webhook, certain metrics
(request_count, request_count_duration_seconds) were implemented without
qualifiers.  i.e., the fact that they applied to the validation webhook
was _assumed_.

As g8r now has both validation and mutation webhooks, separate metrics
for both are required.  These metrics have already been implemented, and
have been released since v3.4.0.  The original metrics were deprecated
(but retained) at the time of that release.

As we are approaching v3.6, it is finally time to remove these metrics.
This PR removes the code and updates the metrics README.

Fixes open-policy-agent#1010

Signed-off-by: juliankatz <juliankatz@google.com>
  • Loading branch information
julianKatz committed Jul 27, 2021
1 parent 4800f9a commit a0e7c16
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
25 changes: 0 additions & 25 deletions pkg/webhook/stats_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import (
)

const (
requestCountMetricName = "request_count"
requestDurationMetricName = "request_duration_seconds"

validationRequestCountMetricName = "validation_request_count"
validationRequestDurationMetricName = "validation_request_duration_seconds"

Expand All @@ -22,11 +19,6 @@ const (
)

var (
responseTimeInSecM = stats.Float64(
requestDurationMetricName,
"The response time in seconds",
stats.UnitSeconds)

validationResponseTimeInSecM = stats.Float64(
validationRequestDurationMetricName,
"The response time in seconds",
Expand Down Expand Up @@ -71,9 +63,6 @@ func newStatsReporter() (StatsReporter, error) {
}

func (r *reporter) ReportValidationRequest(response requestResponse, d time.Duration) error {
if err := r.reportRequest(response, admissionStatusKey, responseTimeInSecM.M(d.Seconds())); err != nil {
return err
}
return r.reportRequest(response, admissionStatusKey, validationResponseTimeInSecM.M(d.Seconds()))
}

Expand All @@ -100,20 +89,6 @@ func (r *reporter) report(ctx context.Context, m stats.Measurement) error {

func register() error {
views := []*view.View{
{
Name: requestCountMetricName,
Description: "The number of requests that are routed to validation webhook",
Measure: responseTimeInSecM,
Aggregation: view.Count(),
TagKeys: []tag.Key{admissionStatusKey},
},
{
Name: requestDurationMetricName,
Description: responseTimeInSecM.Description(),
Measure: responseTimeInSecM,
Aggregation: view.Distribution(0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.02, 0.03, 0.04, 0.05),
TagKeys: []tag.Key{admissionStatusKey},
},
{
Name: validationRequestCountMetricName,
Description: "The number of requests that are routed to validation webhook",
Expand Down
1 change: 0 additions & 1 deletion pkg/webhook/stats_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestValidationReportRequest(t *testing.T) {
if err != nil {
t.Errorf("ReportRequest error %v", err)
}
check(t, expectedTags, requestCountMetricName, requestDurationMetricName)
check(t, expectedTags, validationRequestCountMetricName, validationRequestDurationMetricName)
}

Expand Down
28 changes: 24 additions & 4 deletions website/docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,39 @@ Below are the list of metrics provided by Gatekeeper:

## Webhook

- Name: `request_count`
- Name: `validation_request_count`

Description: `The number of requests that are routed to webhook`
Description: `The number of requests that are routed to validation webhook`

Tags:

- `admission_status`: [`allow`, `deny`]

Aggregation: `Count`

- Name: `request_duration_seconds`
- Name: `validation_request_duration_seconds`

Description: `The response time in seconds`
Description: `The validation webhook response time in seconds`

Tags:

- `admission_status`: [`allow`, `deny`]

Aggregation: `Distribution`

- Name: `mutation_request_count`

Description: `The number of requests that are routed to mutation webhook`

Tags:

- `admission_status`: [`allow`, `deny`]

Aggregation: `Count`

- Name: `mutation_request_duration_seconds`

Description: `The mutation webhook response time in seconds`

Tags:

Expand Down

0 comments on commit a0e7c16

Please sign in to comment.