diff options
Diffstat (limited to 'vendor/go.opencensus.io/trace/basetypes.go')
-rw-r--r-- | vendor/go.opencensus.io/trace/basetypes.go | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/vendor/go.opencensus.io/trace/basetypes.go b/vendor/go.opencensus.io/trace/basetypes.go new file mode 100644 index 0000000..01f0f90 --- /dev/null +++ b/vendor/go.opencensus.io/trace/basetypes.go | |||
@@ -0,0 +1,114 @@ | |||
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 | |||
15 | package trace | ||
16 | |||
17 | import ( | ||
18 | "fmt" | ||
19 | "time" | ||
20 | ) | ||
21 | |||
22 | type ( | ||
23 | // TraceID is a 16-byte identifier for a set of spans. | ||
24 | TraceID [16]byte | ||
25 | |||
26 | // SpanID is an 8-byte identifier for a single span. | ||
27 | SpanID [8]byte | ||
28 | ) | ||
29 | |||
30 | func (t TraceID) String() string { | ||
31 | return fmt.Sprintf("%02x", t[:]) | ||
32 | } | ||
33 | |||
34 | func (s SpanID) String() string { | ||
35 | return fmt.Sprintf("%02x", s[:]) | ||
36 | } | ||
37 | |||
38 | // Annotation represents a text annotation with a set of attributes and a timestamp. | ||
39 | type Annotation struct { | ||
40 | Time time.Time | ||
41 | Message string | ||
42 | Attributes map[string]interface{} | ||
43 | } | ||
44 | |||
45 | // Attribute represents a key-value pair on a span, link or annotation. | ||
46 | // Construct with one of: BoolAttribute, Int64Attribute, or StringAttribute. | ||
47 | type Attribute struct { | ||
48 | key string | ||
49 | value interface{} | ||
50 | } | ||
51 | |||
52 | // BoolAttribute returns a bool-valued attribute. | ||
53 | func BoolAttribute(key string, value bool) Attribute { | ||
54 | return Attribute{key: key, value: value} | ||
55 | } | ||
56 | |||
57 | // Int64Attribute returns an int64-valued attribute. | ||
58 | func Int64Attribute(key string, value int64) Attribute { | ||
59 | return Attribute{key: key, value: value} | ||
60 | } | ||
61 | |||
62 | // StringAttribute returns a string-valued attribute. | ||
63 | func StringAttribute(key string, value string) Attribute { | ||
64 | return Attribute{key: key, value: value} | ||
65 | } | ||
66 | |||
67 | // LinkType specifies the relationship between the span that had the link | ||
68 | // added, and the linked span. | ||
69 | type LinkType int32 | ||
70 | |||
71 | // LinkType values. | ||
72 | const ( | ||
73 | LinkTypeUnspecified LinkType = iota // The relationship of the two spans is unknown. | ||
74 | LinkTypeChild // The current span is a child of the linked span. | ||
75 | LinkTypeParent // The current span is the parent of the linked span. | ||
76 | ) | ||
77 | |||
78 | // Link represents a reference from one span to another span. | ||
79 | type Link struct { | ||
80 | TraceID TraceID | ||
81 | SpanID SpanID | ||
82 | Type LinkType | ||
83 | // Attributes is a set of attributes on the link. | ||
84 | Attributes map[string]interface{} | ||
85 | } | ||
86 | |||
87 | // MessageEventType specifies the type of message event. | ||
88 | type MessageEventType int32 | ||
89 | |||
90 | // MessageEventType values. | ||
91 | const ( | ||
92 | MessageEventTypeUnspecified MessageEventType = iota // Unknown event type. | ||
93 | MessageEventTypeSent // Indicates a sent RPC message. | ||
94 | MessageEventTypeRecv // Indicates a received RPC message. | ||
95 | ) | ||
96 | |||
97 | // MessageEvent represents an event describing a message sent or received on the network. | ||
98 | type MessageEvent struct { | ||
99 | Time time.Time | ||
100 | EventType MessageEventType | ||
101 | MessageID int64 | ||
102 | UncompressedByteSize int64 | ||
103 | CompressedByteSize int64 | ||
104 | } | ||
105 | |||
106 | // Status is the status of a Span. | ||
107 | type Status struct { | ||
108 | // Code is a status code. Zero indicates success. | ||
109 | // | ||
110 | // If Code will be propagated to Google APIs, it ideally should be a value from | ||
111 | // https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto . | ||
112 | Code int32 | ||
113 | Message string | ||
114 | } | ||