65
65
knownLogs metric.Int64Gauge // origin => value (always 1.0)
66
66
lastSCTIndex metric.Int64Gauge // origin => value
67
67
lastSCTTimestamp metric.Int64Gauge // origin => value
68
- reqsCounter metric.Int64Counter // origin, op => value
69
- rspsCounter metric.Int64Counter // origin, op, code => value
70
- rspLatency metric.Float64Histogram // origin, op, code => value
68
+ reqCounter metric.Int64Counter // origin, op => value
69
+ rspCounter metric.Int64Counter // origin, op, code => value
70
+ reqDuration metric.Float64Histogram // origin, op, code => value
71
71
)
72
72
73
73
// setupMetrics initializes all the exported metrics.
@@ -84,16 +84,17 @@ func setupMetrics() {
84
84
metric .WithDescription ("Index of last SCT" ),
85
85
metric .WithUnit ("{entry}" )))
86
86
87
- reqsCounter = mustCreate (meter .Int64Counter ("tesseract.http_request.count" ,
88
- metric .WithDescription ("CT HTTP requests" )))
87
+ reqCounter = mustCreate (meter .Int64Counter ("tesseract.http.request.count" ,
88
+ metric .WithDescription ("CT HTTP requests" ),
89
+ metric .WithUnit ("{request}" )))
89
90
90
- rspsCounter = mustCreate (meter .Int64Counter ("tesseract.http_response.count" ,
91
- metric .WithDescription ("CT HTTP responses" )))
91
+ rspCounter = mustCreate (meter .Int64Counter ("tesseract.http.response.count" ,
92
+ metric .WithDescription ("CT HTTP responses" ),
93
+ metric .WithUnit ("{response}" )))
92
94
93
- rspLatency = mustCreate (meter .Float64Histogram ("tesseract.http_response .duration" ,
95
+ reqDuration = mustCreate (meter .Float64Histogram ("tesseract.http.request .duration" ,
94
96
metric .WithDescription ("CT HTTP response duration" ),
95
- metric .WithExplicitBucketBoundaries (otel .LatencyHistogramBuckets ... ),
96
- metric .WithUnit ("ms" )))
97
+ metric .WithUnit ("s" )))
97
98
}
98
99
99
100
// entrypoints is a list of entrypoint names as exposed in statistics/logging.
@@ -119,13 +120,13 @@ func (a appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
119
120
120
121
originAttr := originKey .String (a .log .origin )
121
122
operationAttr := operationKey .String (a .name )
122
- reqsCounter .Add (r .Context (), 1 , metric .WithAttributes (originAttr , operationAttr ))
123
+ reqCounter .Add (r .Context (), 1 , metric .WithAttributes (originAttr , operationAttr ))
123
124
startTime := a .opts .TimeSource .Now ()
124
125
logCtx := a .opts .RequestLog .start (r .Context ())
125
126
a .opts .RequestLog .origin (logCtx , a .log .origin )
126
127
defer func () {
127
128
latency := a .opts .TimeSource .Now ().Sub (startTime ).Seconds ()
128
- rspLatency .Record (r .Context (), latency , metric .WithAttributes (originAttr , operationAttr , codeKey .Int (statusCode )))
129
+ reqDuration .Record (r .Context (), latency , metric .WithAttributes (originAttr , operationAttr , codeKey .Int (statusCode )))
129
130
}()
130
131
131
132
klog .V (2 ).Infof ("%s: request %v %q => %s" , a .log .origin , r .Method , r .URL , a .name )
@@ -155,7 +156,7 @@ func (a appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
155
156
statusCode , err = a .handler (ctx , a .opts , a .log , w , r )
156
157
a .opts .RequestLog .status (ctx , statusCode )
157
158
klog .V (2 ).Infof ("%s: %s <= st=%d" , a .log .origin , a .name , statusCode )
158
- rspsCounter .Add (r .Context (), 1 , metric .WithAttributes (originAttr , operationAttr , codeKey .Int (statusCode )))
159
+ rspCounter .Add (r .Context (), 1 , metric .WithAttributes (originAttr , operationAttr , codeKey .Int (statusCode )))
159
160
if err != nil {
160
161
klog .Warningf ("%s: %s handler error: %v" , a .log .origin , a .name , err )
161
162
a .opts .sendHTTPError (w , statusCode , err )
0 commit comments