Class: OpenCensus::Trace::Span
- Inherits:
-
Object
- Object
- OpenCensus::Trace::Span
- Defined in:
- lib/opencensus/trace/span.rb
Overview
Span represents a span in a trace record. Spans are contained in a trace and arranged in a forest. That is, each span may be a root span or have a parent span, and may have zero or more children.
Constant Summary collapse
- SPAN_KIND_UNSPECIFIED =
The span kind is unspecified
:SPAN_KIND_UNSPECIFIED- SERVER =
Indicates that the span covers server-side handling of an RPC or other remote network request.
:SERVER- CLIENT =
Indicates that the span covers the client-side wrapper around an RPC or other remote request.
:CLIENT
Instance Attribute Summary collapse
-
#attributes ⇒ Hash<String, (TruncatableString, Integer, Boolean)>
readonly
The properties of this span.
-
#child_span_count ⇒ Integer?
readonly
An optional number of child spans that were generated while this span was active.
-
#dropped_annotations_count ⇒ Integer
readonly
The number of dropped annotations in all the included time events.
-
#dropped_attributes_count ⇒ Integer
readonly
The number of attributes that were discarded.
-
#dropped_frames_count ⇒ Integer
readonly
The number of stack frames that were dropped because there were too many stack frames.
-
#dropped_links_count ⇒ Integer
readonly
The number of dropped links after the maximum size was enforced If the value is 0, then no links were dropped.
-
#dropped_message_events_count ⇒ Integer
readonly
The number of dropped message events in all the included time events.
-
#end_time ⇒ Time
readonly
The ending timestamp of this span in UTC.
-
#kind ⇒ Symbol
readonly
The kind of span.
-
#links ⇒ Array<Link>
readonly
The included links.
-
#name ⇒ TruncatableString
readonly
The name of this span.
-
#parent_span_id ⇒ String
readonly
The ‘span_id` of this span’s parent span.
-
#same_process_as_parent_span ⇒ boolean?
readonly
A highly recommended but not required flag that identifies when a trace crosses a process boundary.
-
#span_id ⇒ String
readonly
A unique identifier for a span within a trace, assigned when the span is created.
-
#stack_trace ⇒ Array<Thread::Backtrace::Location>
readonly
A stack trace captured at the start of the span.
-
#stack_trace_hash_id ⇒ Integer
readonly
A hash of the stack trace.
-
#start_time ⇒ Time
readonly
The starting timestamp of this span in UTC.
-
#status ⇒ Status?
readonly
An optional final status for this span.
-
#time_events ⇒ Array<TimeEvent>
readonly
The included time events.
-
#trace_id ⇒ String
readonly
A unique identifier for a trace.
Instance Method Summary collapse
Constructor Details
#initialize(trace_id, span_id, name, start_time, end_time, kind: SPAN_KIND_UNSPECIFIED, parent_span_id: "", attributes: {}, dropped_attributes_count: 0, stack_trace: [], dropped_frames_count: 0, time_events: [], dropped_annotations_count: 0, dropped_message_events_count: 0, links: [], dropped_links_count: 0, status: nil, same_process_as_parent_span: nil, child_span_count: nil) ⇒ Span
Create an empty Span object.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/opencensus/trace/span.rb', line 203 def initialize trace_id, span_id, name, start_time, end_time, kind: SPAN_KIND_UNSPECIFIED, parent_span_id: "", attributes: {}, dropped_attributes_count: 0, stack_trace: [], dropped_frames_count: 0, time_events: [], dropped_annotations_count: 0, dropped_message_events_count: 0, links: [], dropped_links_count: 0, status: nil, same_process_as_parent_span: nil, child_span_count: nil @name = name @kind = kind @trace_id = trace_id @span_id = span_id @parent_span_id = parent_span_id @start_time = start_time @end_time = end_time @attributes = attributes @dropped_attributes_count = dropped_attributes_count @stack_trace = stack_trace @dropped_frames_count = dropped_frames_count @stack_trace_hash_id = init_stack_trace_hash_id @time_events = time_events @dropped_annotations_count = dropped_annotations_count @dropped_message_events_count = @links = links @dropped_links_count = dropped_links_count @status = status @same_process_as_parent_span = same_process_as_parent_span @child_span_count = child_span_count end |
Instance Attribute Details
#attributes ⇒ Hash<String, (TruncatableString, Integer, Boolean)> (readonly)
The properties of this span.
100 101 102 |
# File 'lib/opencensus/trace/span.rb', line 100 def attributes @attributes end |
#child_span_count ⇒ Integer? (readonly)
An optional number of child spans that were generated while this span was active. If set, allows an implementation to detect missing child spans.
196 197 198 |
# File 'lib/opencensus/trace/span.rb', line 196 def child_span_count @child_span_count end |
#dropped_annotations_count ⇒ Integer (readonly)
The number of dropped annotations in all the included time events. If the value is 0, then no annotations were dropped.
148 149 150 |
# File 'lib/opencensus/trace/span.rb', line 148 def dropped_annotations_count @dropped_annotations_count end |
#dropped_attributes_count ⇒ Integer (readonly)
The number of attributes that were discarded. Attributes can be discarded because their keys are too long or because there are too many attributes. If this value is 0, then no attributes were dropped.
109 110 111 |
# File 'lib/opencensus/trace/span.rb', line 109 def dropped_attributes_count @dropped_attributes_count end |
#dropped_frames_count ⇒ Integer (readonly)
The number of stack frames that were dropped because there were too many stack frames. If this value is 0, then no stack frames were dropped.
133 134 135 |
# File 'lib/opencensus/trace/span.rb', line 133 def dropped_frames_count @dropped_frames_count end |
#dropped_links_count ⇒ Integer (readonly)
The number of dropped links after the maximum size was enforced If the value is 0, then no links were dropped.
171 172 173 |
# File 'lib/opencensus/trace/span.rb', line 171 def dropped_links_count @dropped_links_count end |
#dropped_message_events_count ⇒ Integer (readonly)
The number of dropped message events in all the included time events. If the value is 0, then no message events were dropped.
156 157 158 |
# File 'lib/opencensus/trace/span.rb', line 156 def @dropped_message_events_count end |
#end_time ⇒ Time (readonly)
The ending timestamp of this span in UTC.
93 94 95 |
# File 'lib/opencensus/trace/span.rb', line 93 def end_time @end_time end |
#kind ⇒ Symbol (readonly)
The kind of span. Can be used to specify additional relationships between spans in addition to a parent/child relationship. You should use the kind constants provided by this class.
79 80 81 |
# File 'lib/opencensus/trace/span.rb', line 79 def kind @kind end |
#links ⇒ Array<Link> (readonly)
The included links.
163 164 165 |
# File 'lib/opencensus/trace/span.rb', line 163 def links @links end |
#name ⇒ TruncatableString (readonly)
The name of this span.
70 71 72 |
# File 'lib/opencensus/trace/span.rb', line 70 def name @name end |
#parent_span_id ⇒ String (readonly)
The ‘span_id` of this span’s parent span. If this is a root span, then this field must be empty. The ID is an 8-byte value represented as a hexadecimal string.
63 64 65 |
# File 'lib/opencensus/trace/span.rb', line 63 def parent_span_id @parent_span_id end |
#same_process_as_parent_span ⇒ boolean? (readonly)
A highly recommended but not required flag that identifies when a trace crosses a process boundary. True when the parent_span belongs to the same process as the current span.
187 188 189 |
# File 'lib/opencensus/trace/span.rb', line 187 def same_process_as_parent_span @same_process_as_parent_span end |
#span_id ⇒ String (readonly)
A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte value represented as a hexadecimal string.
54 55 56 |
# File 'lib/opencensus/trace/span.rb', line 54 def span_id @span_id end |
#stack_trace ⇒ Array<Thread::Backtrace::Location> (readonly)
A stack trace captured at the start of the span.
116 117 118 |
# File 'lib/opencensus/trace/span.rb', line 116 def stack_trace @stack_trace end |
#stack_trace_hash_id ⇒ Integer (readonly)
A hash of the stack trace. This may be used by exporters to identify duplicate stack traces transmitted in the same request; only one copy of the actual data needs to be sent.
125 126 127 |
# File 'lib/opencensus/trace/span.rb', line 125 def stack_trace_hash_id @stack_trace_hash_id end |
#start_time ⇒ Time (readonly)
The starting timestamp of this span in UTC.
86 87 88 |
# File 'lib/opencensus/trace/span.rb', line 86 def start_time @start_time end |
#status ⇒ Status? (readonly)
An optional final status for this span.
178 179 180 |
# File 'lib/opencensus/trace/span.rb', line 178 def status @status end |
#time_events ⇒ Array<TimeEvent> (readonly)
The included time events.
140 141 142 |
# File 'lib/opencensus/trace/span.rb', line 140 def time_events @time_events end |
#trace_id ⇒ String (readonly)
A unique identifier for a trace. All spans from the same trace share the same ‘trace_id`. The ID is a 16-byte value represented as a hexadecimal string.
45 46 47 |
# File 'lib/opencensus/trace/span.rb', line 45 def trace_id @trace_id end |