summaryrefslogtreecommitdiff
path: root/vendor/go.opencensus.io/stats/record.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.opencensus.io/stats/record.go')
-rw-r--r--vendor/go.opencensus.io/stats/record.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/vendor/go.opencensus.io/stats/record.go b/vendor/go.opencensus.io/stats/record.go
index 2b9728346..8b5b99803 100644
--- a/vendor/go.opencensus.io/stats/record.go
+++ b/vendor/go.opencensus.io/stats/record.go
@@ -86,10 +86,29 @@ func createRecordOption(ros ...Options) *recordOptions {
return o
}
+type measurementRecorder = func(tags *tag.Map, measurement []Measurement, attachments map[string]interface{})
+
// Record records one or multiple measurements with the same context at once.
// If there are any tags in the context, measurements will be tagged with them.
func Record(ctx context.Context, ms ...Measurement) {
- RecordWithOptions(ctx, WithMeasurements(ms...))
+ // Record behaves the same as RecordWithOptions, but because we do not have to handle generic functionality
+ // (RecordOptions) we can reduce some allocations to speed up this hot path
+ if len(ms) == 0 {
+ return
+ }
+ recorder := internal.MeasurementRecorder.(measurementRecorder)
+ record := false
+ for _, m := range ms {
+ if m.desc.subscribed() {
+ record = true
+ break
+ }
+ }
+ if !record {
+ return
+ }
+ recorder(tag.FromContext(ctx), ms, nil)
+ return
}
// RecordWithTags records one or multiple measurements at once.