Class: Datadog::Tracing::TraceSegment
- Inherits:
-
Object
- Object
- Datadog::Tracing::TraceSegment
- Defined in:
- lib/datadog/tracing/trace_segment.rb
Overview
Serializable construct representing a trace
Constant Summary collapse
- TAG_NAME =
'name'.freeze
- TAG_RESOURCE =
'resource'.freeze
- TAG_SERVICE =
'service'.freeze
Instance Attribute Summary collapse
-
#agent_sample_rate ⇒ Object
readonly
Returns the value of attribute agent_sample_rate.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#profiling_enabled ⇒ Object
readonly
Returns the value of attribute profiling_enabled.
-
#rate_limiter_rate ⇒ Object
readonly
Returns the value of attribute rate_limiter_rate.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#rule_sample_rate ⇒ Object
readonly
Returns the value of attribute rule_sample_rate.
-
#runtime_id ⇒ Object
readonly
Returns the value of attribute runtime_id.
-
#sample_rate ⇒ Object
readonly
Returns the value of attribute sample_rate.
-
#sampling_decision_maker ⇒ Object
readonly
Returns the value of attribute sampling_decision_maker.
-
#sampling_priority ⇒ Object
readonly
Returns the value of attribute sampling_priority.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#spans ⇒ Object
readonly
Returns the value of attribute spans.
Instance Method Summary collapse
-
#any? ⇒ Boolean
rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity.
- #count ⇒ Object
- #empty? ⇒ Boolean
- #high_order_tid ⇒ Object
-
#initialize(spans, agent_sample_rate: nil, hostname: nil, id: nil, lang: nil, name: nil, origin: nil, process_id: nil, rate_limiter_rate: nil, resource: nil, root_span_id: nil, rule_sample_rate: nil, runtime_id: nil, sample_rate: nil, sampling_priority: nil, service: nil, tags: nil, metrics: nil, profiling_enabled: nil) ⇒ TraceSegment
constructor
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
-
#keep! ⇒ void
If an active trace is present, forces it to be retained by the Datadog backend.
- #length ⇒ Object
-
#reject! ⇒ void
If an active trace is present, forces it to be dropped and not stored by the Datadog backend.
- #sampled? ⇒ Boolean
- #size ⇒ Object
Constructor Details
#initialize(spans, agent_sample_rate: nil, hostname: nil, id: nil, lang: nil, name: nil, origin: nil, process_id: nil, rate_limiter_rate: nil, resource: nil, root_span_id: nil, rule_sample_rate: nil, runtime_id: nil, sample_rate: nil, sampling_priority: nil, service: nil, tags: nil, metrics: nil, profiling_enabled: nil) ⇒ TraceSegment
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/datadog/tracing/trace_segment.rb', line 40 def initialize( spans, agent_sample_rate: nil, hostname: nil, id: nil, lang: nil, name: nil, origin: nil, process_id: nil, rate_limiter_rate: nil, resource: nil, root_span_id: nil, rule_sample_rate: nil, runtime_id: nil, sample_rate: nil, sampling_priority: nil, service: nil, tags: nil, metrics: nil, profiling_enabled: nil ) @id = id @root_span_id = root_span_id @spans = spans || [] # Does not make an effort to move metrics out of tags # The caller is expected to have done that @meta = ( && .dup) || {} @metrics = (metrics && metrics.dup) || {} # Set well-known tags, defaulting to getting the values from tags @agent_sample_rate = agent_sample_rate || agent_sample_rate_tag @hostname = hostname || hostname_tag @lang = lang || lang_tag @name = Core::Utils::SafeDup.frozen_or_dup(name || name_tag) @origin = Core::Utils::SafeDup.frozen_or_dup(origin || origin_tag) @process_id = process_id || process_id_tag @rate_limiter_rate = rate_limiter_rate || rate_limiter_rate_tag @resource = Core::Utils::SafeDup.frozen_or_dup(resource || resource_tag) @rule_sample_rate = rule_sample_rate_tag || rule_sample_rate @runtime_id = runtime_id || runtime_id_tag @sample_rate = sample_rate || sample_rate_tag @sampling_decision_maker = sampling_decision_maker_tag @sampling_priority = sampling_priority || sampling_priority_tag @service = Core::Utils::SafeDup.frozen_or_dup(service || service_tag) @profiling_enabled = profiling_enabled end |
Instance Attribute Details
#agent_sample_rate ⇒ Object
Returns the value of attribute agent_sample_rate.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def agent_sample_rate @agent_sample_rate end |
#hostname ⇒ Object
Returns the value of attribute hostname.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def hostname @hostname end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def id @id end |
#lang ⇒ Object
Returns the value of attribute lang.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def lang @lang end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def name @name end |
#origin ⇒ Object
Returns the value of attribute origin.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def origin @origin end |
#process_id ⇒ Object
Returns the value of attribute process_id.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def process_id @process_id end |
#profiling_enabled ⇒ Object (readonly)
Returns the value of attribute profiling_enabled.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def profiling_enabled @profiling_enabled end |
#rate_limiter_rate ⇒ Object
Returns the value of attribute rate_limiter_rate.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def rate_limiter_rate @rate_limiter_rate end |
#resource ⇒ Object
Returns the value of attribute resource.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def resource @resource end |
#rule_sample_rate ⇒ Object
Returns the value of attribute rule_sample_rate.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def rule_sample_rate @rule_sample_rate end |
#runtime_id ⇒ Object
Returns the value of attribute runtime_id.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def runtime_id @runtime_id end |
#sample_rate ⇒ Object
Returns the value of attribute sample_rate.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def sample_rate @sample_rate end |
#sampling_decision_maker ⇒ Object (readonly)
Returns the value of attribute sampling_decision_maker.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def sampling_decision_maker @sampling_decision_maker end |
#sampling_priority ⇒ Object
Returns the value of attribute sampling_priority.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def sampling_priority @sampling_priority end |
#service ⇒ Object
Returns the value of attribute service.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def service @service end |
#spans ⇒ Object (readonly)
Returns the value of attribute spans.
18 19 20 |
# File 'lib/datadog/tracing/trace_segment.rb', line 18 def spans @spans end |
Instance Method Details
#any? ⇒ Boolean
rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity
90 91 92 |
# File 'lib/datadog/tracing/trace_segment.rb', line 90 def any? @spans.any? end |
#count ⇒ Object
94 95 96 |
# File 'lib/datadog/tracing/trace_segment.rb', line 94 def count @spans.count end |
#empty? ⇒ Boolean
98 99 100 |
# File 'lib/datadog/tracing/trace_segment.rb', line 98 def empty? @spans.empty? end |
#high_order_tid ⇒ Object
133 134 135 136 137 |
# File 'lib/datadog/tracing/trace_segment.rb', line 133 def high_order_tid high_order = Tracing::Utils::TraceId.to_high_order(@id) high_order.to_s(16) if high_order != 0 end |
#keep! ⇒ void
This method returns an undefined value.
If an active trace is present, forces it to be retained by the Datadog backend.
Any sampling logic will not be able to change this decision.
115 116 117 |
# File 'lib/datadog/tracing/trace_segment.rb', line 115 def keep! self.sampling_priority = Sampling::Ext::Priority::USER_KEEP end |
#length ⇒ Object
102 103 104 |
# File 'lib/datadog/tracing/trace_segment.rb', line 102 def length @spans.length end |
#reject! ⇒ void
This method returns an undefined value.
If an active trace is present, forces it to be dropped and not stored by the Datadog backend.
Any sampling logic will not be able to change this decision.
124 125 126 |
# File 'lib/datadog/tracing/trace_segment.rb', line 124 def reject! self.sampling_priority = Sampling::Ext::Priority::USER_REJECT end |
#sampled? ⇒ Boolean
128 129 130 131 |
# File 'lib/datadog/tracing/trace_segment.rb', line 128 def sampled? sampling_priority == Sampling::Ext::Priority::AUTO_KEEP \ || sampling_priority == Sampling::Ext::Priority::USER_KEEP end |
#size ⇒ Object
106 107 108 |
# File 'lib/datadog/tracing/trace_segment.rb', line 106 def size @spans.size end |