aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/go.opencensus.io/trace/export.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/go.opencensus.io/trace/export.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/go.opencensus.io/trace/export.go')
-rw-r--r--vendor/go.opencensus.io/trace/export.go90
1 files changed, 90 insertions, 0 deletions
diff --git a/vendor/go.opencensus.io/trace/export.go b/vendor/go.opencensus.io/trace/export.go
new file mode 100644
index 0000000..77a8c73
--- /dev/null
+++ b/vendor/go.opencensus.io/trace/export.go
@@ -0,0 +1,90 @@
1// Copyright 2017, OpenCensus Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package trace
16
17import (
18 "sync"
19 "sync/atomic"
20 "time"
21)
22
23// Exporter is a type for functions that receive sampled trace spans.
24//
25// The ExportSpan method should be safe for concurrent use and should return
26// quickly; if an Exporter takes a significant amount of time to process a
27// SpanData, that work should be done on another goroutine.
28//
29// The SpanData should not be modified, but a pointer to it can be kept.
30type Exporter interface {
31 ExportSpan(s *SpanData)
32}
33
34type exportersMap map[Exporter]struct{}
35
36var (
37 exporterMu sync.Mutex
38 exporters atomic.Value
39)
40
41// RegisterExporter adds to the list of Exporters that will receive sampled
42// trace spans.
43//
44// Binaries can register exporters, libraries shouldn't register exporters.
45func RegisterExporter(e Exporter) {
46 exporterMu.Lock()
47 new := make(exportersMap)
48 if old, ok := exporters.Load().(exportersMap); ok {
49 for k, v := range old {
50 new[k] = v
51 }
52 }
53 new[e] = struct{}{}
54 exporters.Store(new)
55 exporterMu.Unlock()
56}
57
58// UnregisterExporter removes from the list of Exporters the Exporter that was
59// registered with the given name.
60func UnregisterExporter(e Exporter) {
61 exporterMu.Lock()
62 new := make(exportersMap)
63 if old, ok := exporters.Load().(exportersMap); ok {
64 for k, v := range old {
65 new[k] = v
66 }
67 }
68 delete(new, e)
69 exporters.Store(new)
70 exporterMu.Unlock()
71}
72
73// SpanData contains all the information collected by a Span.
74type SpanData struct {
75 SpanContext
76 ParentSpanID SpanID
77 SpanKind int
78 Name string
79 StartTime time.Time
80 // The wall clock time of EndTime will be adjusted to always be offset
81 // from StartTime by the duration of the span.
82 EndTime time.Time
83 // The values of Attributes each have type string, bool, or int64.
84 Attributes map[string]interface{}
85 Annotations []Annotation
86 MessageEvents []MessageEvent
87 Status
88 Links []Link
89 HasRemoteParent bool
90}