1
0
mirror of https://github.com/golang/go synced 2024-11-06 01:46:12 -07:00
go/internal/telemetry/event/metric.go

30 lines
1003 B
Go
Raw Normal View History

// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
)
internal/telemetry: add fast non variadic event functions This adds variants of the main event functions that take specific numbers of tags, rather than a tag slice. This reduces the allocation cost when using those functions with no exporter to zero. name old time/op new time/op delta /Baseline-8 158ns ± 7% 154ns ± 1% ~ /StdLog-8 6.90µs ± 1% 6.83µs ± 1% ~ /LogNoExporter-8 1.78µs ± 5% 1.20µs ± 3% -32.37% /TraceNoExporter-8 3.11µs ± 3% 2.48µs ± 2% -20.39% /StatsNoExporter-8 3.18µs ± 5% 1.87µs ± 3% -41.16% /Log-8 46.8µs ± 2% 44.8µs ± 1% -4.33% /Trace-8 55.1µs ± 5% 54.3µs ± 3% ~ /Stats-8 15.8µs ± 3% 13.4µs ± 1% -15.00% name old alloc/op new alloc/op delta /Baseline-8 0.00B 0.00B ~ /StdLog-8 552B ± 0% 552B ± 0% ~ /LogNoExporter-8 1.02kB ± 0% 0.00kB -100.00% /TraceNoExporter-8 1.54kB ± 0% 0.51kB ± 0% -66.67% /StatsNoExporter-8 2.05kB ± 0% 0.00kB -100.00% /Log-8 26.0kB ± 0% 24.0kB ± 0% -7.87% /Trace-8 28.7kB ± 0% 27.1kB ± 0% ~ /Stats-8 13.3kB ± 0% 10.2kB ± 0% -23.08% name old allocs/op new allocs/op delta /Baseline-8 0.00 0.00 ~ /StdLog-8 30.0 ± 0% 30.0 ± 0% ~ /LogNoExporter-8 16.0 ± 0% 0.0 -100.00% /TraceNoExporter-8 32.0 ± 0% 16.0 ± 0% -50.00% /StatsNoExporter-8 32.0 ± 0% 0.0 -100.00% /Log-8 430 ± 0% 382 ± 0% -11.16% /Trace-8 496 ± 0% 464 ± 0% -6.45% /Stats-8 192 ± 0% 128 ± 0% -33.33% Change-Id: I629c0d506ab07de6f12b0acbecfc7407f59a4285 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225580 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-25 20:50:00 -06:00
// Record sends a label event to the exporter with the supplied tags.
func Record(ctx context.Context, tags ...Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{}, tags))
}
// Record1 sends a label event to the exporter with the supplied tags.
func Record1(ctx context.Context, t1 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1}, nil))
}
// Record2 sends a label event to the exporter with the supplied tags.
func Record2(ctx context.Context, t1, t2 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2}, nil))
}
// Record3 sends a label event to the exporter with the supplied tags.
func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2, t3}, nil))
}