mirror of
https://github.com/golang/go
synced 2024-11-06 13:36:12 -07:00
65e3620a7a
Change-Id: I5de33edc352a5202fdf9e38538a224dd6adafedb Reviewed-on: https://go-review.googlesource.com/c/tools/+/190799 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
// 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 export
|
|
|
|
import (
|
|
"context"
|
|
|
|
"golang.org/x/tools/internal/telemetry"
|
|
)
|
|
|
|
// Multi returns an exporter that invokes all the exporters given to it in order.
|
|
func Multi(e ...Exporter) Exporter {
|
|
a := make(multi, 0, len(e))
|
|
for _, i := range e {
|
|
if i == nil {
|
|
continue
|
|
}
|
|
if i, ok := i.(multi); ok {
|
|
a = append(a, i...)
|
|
continue
|
|
}
|
|
a = append(a, i)
|
|
}
|
|
return a
|
|
}
|
|
|
|
type multi []Exporter
|
|
|
|
func (m multi) StartSpan(ctx context.Context, span *telemetry.Span) {
|
|
for _, o := range m {
|
|
o.StartSpan(ctx, span)
|
|
}
|
|
}
|
|
func (m multi) FinishSpan(ctx context.Context, span *telemetry.Span) {
|
|
for _, o := range m {
|
|
o.FinishSpan(ctx, span)
|
|
}
|
|
}
|
|
func (m multi) Log(ctx context.Context, event telemetry.Event) {
|
|
for _, o := range m {
|
|
o.Log(ctx, event)
|
|
}
|
|
}
|
|
func (m multi) Metric(ctx context.Context, data telemetry.MetricData) {
|
|
for _, o := range m {
|
|
o.Metric(ctx, data)
|
|
}
|
|
}
|
|
func (m multi) Flush() {
|
|
for _, o := range m {
|
|
o.Flush()
|
|
}
|
|
}
|