Class: OpenCensus::Trace::Span

Inherits:
Object
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace_id, span_id, name, start_time, end_time, 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.



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/opencensus/trace/span.rb', line 179

def initialize trace_id, span_id, name, start_time, end_time,
               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
  @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
  @stack_trace_hash_id = [stack_trace, dropped_frames_count].hash
  @stack_trace_hash_id = -1 if @stack_trace_hash_id.zero?
  @dropped_frames_count = dropped_frames_count
  @time_events = time_events
  @dropped_annotations_count = dropped_annotations_count
  @dropped_message_events_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

#attributesHash<String, (TruncatableString, Integer, Boolean)> (readonly)

The properties of this span.

Returns:



76
77
78
# File 'lib/opencensus/trace/span.rb', line 76

def attributes
  @attributes
end

#child_span_countInteger? (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.

Returns:

  • (Integer, nil)


172
173
174
# File 'lib/opencensus/trace/span.rb', line 172

def child_span_count
  @child_span_count
end

#dropped_annotations_countInteger (readonly)

The number of dropped annotations in all the included time events. If the value is 0, then no annotations were dropped.

Returns:

  • (Integer)


124
125
126
# File 'lib/opencensus/trace/span.rb', line 124

def dropped_annotations_count
  @dropped_annotations_count
end

#dropped_attributes_countInteger (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.

Returns:

  • (Integer)


85
86
87
# File 'lib/opencensus/trace/span.rb', line 85

def dropped_attributes_count
  @dropped_attributes_count
end

#dropped_frames_countInteger (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.

Returns:

  • (Integer)


109
110
111
# File 'lib/opencensus/trace/span.rb', line 109

def dropped_frames_count
  @dropped_frames_count
end

The number of dropped links after the maximum size was enforced If the value is 0, then no links were dropped.

Returns:

  • (Integer)


147
148
149
# File 'lib/opencensus/trace/span.rb', line 147

def dropped_links_count
  @dropped_links_count
end

#dropped_message_events_countInteger (readonly)

The number of dropped message events in all the included time events. If the value is 0, then no message events were dropped.

Returns:

  • (Integer)


132
133
134
# File 'lib/opencensus/trace/span.rb', line 132

def dropped_message_events_count
  @dropped_message_events_count
end

#end_timeTime (readonly)

The ending timestamp of this span in UTC.

Returns:

  • (Time)


69
70
71
# File 'lib/opencensus/trace/span.rb', line 69

def end_time
  @end_time
end

The included links.

Returns:



139
140
141
# File 'lib/opencensus/trace/span.rb', line 139

def links
  @links
end

#nameTruncatableString (readonly)

The name of this span.

Returns:



55
56
57
# File 'lib/opencensus/trace/span.rb', line 55

def name
  @name
end

#parent_span_idString (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.

Returns:

  • (String)


48
49
50
# File 'lib/opencensus/trace/span.rb', line 48

def parent_span_id
  @parent_span_id
end

#same_process_as_parent_spanboolean? (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.

Returns:

  • (boolean, nil)


163
164
165
# File 'lib/opencensus/trace/span.rb', line 163

def same_process_as_parent_span
  @same_process_as_parent_span
end

#span_idString (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.

Returns:

  • (String)


39
40
41
# File 'lib/opencensus/trace/span.rb', line 39

def span_id
  @span_id
end

#stack_traceArray<Thread::Backtrace::Location> (readonly)

A stack trace captured at the start of the span.

Returns:

  • (Array<Thread::Backtrace::Location>)


92
93
94
# File 'lib/opencensus/trace/span.rb', line 92

def stack_trace
  @stack_trace
end

#stack_trace_hash_idInteger (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.

Returns:

  • (Integer)


101
102
103
# File 'lib/opencensus/trace/span.rb', line 101

def stack_trace_hash_id
  @stack_trace_hash_id
end

#start_timeTime (readonly)

The starting timestamp of this span in UTC.

Returns:

  • (Time)


62
63
64
# File 'lib/opencensus/trace/span.rb', line 62

def start_time
  @start_time
end

#statusStatus? (readonly)

An optional final status for this span.

Returns:



154
155
156
# File 'lib/opencensus/trace/span.rb', line 154

def status
  @status
end

#time_eventsArray<TimeEvent> (readonly)

The included time events.

Returns:



116
117
118
# File 'lib/opencensus/trace/span.rb', line 116

def time_events
  @time_events
end

#trace_idString (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.

Returns:

  • (String)


30
31
32
# File 'lib/opencensus/trace/span.rb', line 30

def trace_id
  @trace_id
end