1 // Copyright 2017, OpenCensus Authors
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
23 // TraceID is a 16-byte identifier for a set of spans.
26 // SpanID is an 8-byte identifier for a single span.
30 func (t TraceID) String() string {
31 return fmt.Sprintf("%02x", t[:])
34 func (s SpanID) String() string {
35 return fmt.Sprintf("%02x", s[:])
38 // Annotation represents a text annotation with a set of attributes and a timestamp.
39 type Annotation struct {
42 Attributes map[string]interface{}
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 {
52 // BoolAttribute returns a bool-valued attribute.
53 func BoolAttribute(key string, value bool) Attribute {
54 return Attribute{key: key, value: value}
57 // Int64Attribute returns an int64-valued attribute.
58 func Int64Attribute(key string, value int64) Attribute {
59 return Attribute{key: key, value: value}
62 // Float64Attribute returns a float64-valued attribute.
63 func Float64Attribute(key string, value float64) Attribute {
64 return Attribute{key: key, value: value}
67 // StringAttribute returns a string-valued attribute.
68 func StringAttribute(key string, value string) Attribute {
69 return Attribute{key: key, value: value}
72 // LinkType specifies the relationship between the span that had the link
73 // added, and the linked span.
78 LinkTypeUnspecified LinkType = iota // The relationship of the two spans is unknown.
79 LinkTypeChild // The linked span is a child of the current span.
80 LinkTypeParent // The linked span is the parent of the current span.
83 // Link represents a reference from one span to another span.
88 // Attributes is a set of attributes on the link.
89 Attributes map[string]interface{}
92 // MessageEventType specifies the type of message event.
93 type MessageEventType int32
95 // MessageEventType values.
97 MessageEventTypeUnspecified MessageEventType = iota // Unknown event type.
98 MessageEventTypeSent // Indicates a sent RPC message.
99 MessageEventTypeRecv // Indicates a received RPC message.
102 // MessageEvent represents an event describing a message sent or received on the network.
103 type MessageEvent struct {
105 EventType MessageEventType
107 UncompressedByteSize int64
108 CompressedByteSize int64
111 // Status is the status of a Span.
113 // Code is a status code. Zero indicates success.
115 // If Code will be propagated to Google APIs, it ideally should be a value from
116 // https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto .