Skip to content

Commit 1b7e46e

Browse files
committed
Fixes
1 parent 18176cd commit 1b7e46e

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

internal/scti/handlers.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ var (
6565
knownLogs metric.Int64Gauge // origin => value (always 1.0)
6666
lastSCTIndex metric.Int64Gauge // origin => value
6767
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
7171
)
7272

7373
// setupMetrics initializes all the exported metrics.
@@ -84,16 +84,17 @@ func setupMetrics() {
8484
metric.WithDescription("Index of last SCT"),
8585
metric.WithUnit("{entry}")))
8686

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}")))
8990

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}")))
9294

93-
rspLatency = mustCreate(meter.Float64Histogram("tesseract.http_response.duration",
95+
reqDuration = mustCreate(meter.Float64Histogram("tesseract.http.request.duration",
9496
metric.WithDescription("CT HTTP response duration"),
95-
metric.WithExplicitBucketBoundaries(otel.LatencyHistogramBuckets...),
96-
metric.WithUnit("ms")))
97+
metric.WithUnit("s")))
9798
}
9899

99100
// 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) {
119120

120121
originAttr := originKey.String(a.log.origin)
121122
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))
123124
startTime := a.opts.TimeSource.Now()
124125
logCtx := a.opts.RequestLog.start(r.Context())
125126
a.opts.RequestLog.origin(logCtx, a.log.origin)
126127
defer func() {
127128
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)))
129130
}()
130131

131132
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) {
155156
statusCode, err = a.handler(ctx, a.opts, a.log, w, r)
156157
a.opts.RequestLog.status(ctx, statusCode)
157158
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)))
159160
if err != nil {
160161
klog.Warningf("%s: %s handler error: %v", a.log.origin, a.name, err)
161162
a.opts.sendHTTPError(w, statusCode, err)

internal/scti/otel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var (
2828
)
2929

3030
var (
31-
codeKey = attribute.Key("tesseract.code")
31+
codeKey = attribute.Key("http.response.status_code")
3232
operationKey = attribute.Key("tesseract.operation")
3333
originKey = attribute.Key("tesseract.origin")
3434
)

0 commit comments

Comments
 (0)