This repository has been archived by the owner on Feb 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
metrics.go
80 lines (71 loc) · 2.85 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2019 eBay Inc.
// Primary authors: Simon Fell, Diego Ongaro,
// Raymond Kroeker, and Sathish Kandasamy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package query
import (
metricsutil "github.com/ebay/akutan/util/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type queryMetrics struct {
parseQueryDurationSeconds prometheus.Summary
rewriteQueryDurationSeconds prometheus.Summary
planQueryDurationSeconds prometheus.Summary
executeQueryDurationSeconds prometheus.Summary
}
var metrics queryMetrics
func init() {
mr := metricsutil.Registry{R: prometheus.DefaultRegisterer}
metrics = queryMetrics{
parseQueryDurationSeconds: mr.NewSummary(prometheus.SummaryOpts{
Namespace: "akutan",
Subsystem: "query",
Name: "parse_duration_seconds",
Help: `The time it takes to parse a query.`,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}),
rewriteQueryDurationSeconds: mr.NewSummary(prometheus.SummaryOpts{
Namespace: "akutan",
Subsystem: "query",
Name: "rewrite_duration_seconds",
Help: `The time it takes to rewrite a query.
This step happens after parsing and before planning, and it includes fetching
numeric IDs for any external IDs used in the query.
`,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}),
planQueryDurationSeconds: mr.NewSummary(prometheus.SummaryOpts{
Namespace: "akutan",
Subsystem: "query",
Name: "planning_duration_seconds",
Help: `The time it takes to come up with a query plan.
Query planning is a CPU-intensive process that considers many possible execution plans and picks
the one with the lowest estimated cost.
These observations are expected to vary significantly from one query to the
next, but a major shift in the overall distributions would indicate a change in
usage or a change in the code.
`,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}),
executeQueryDurationSeconds: mr.NewSummary(prometheus.SummaryOpts{
Namespace: "akutan",
Subsystem: "query",
Name: "execute_duration_seconds",
Help: `The time it takes to execute a query.
This happens after query planning, and it involves fetching the data from the
views.
`,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
}),
}
}