Class: Datadog::DataStreams::PathwayContext

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/data_streams/pathway_context.rb

Overview

Represents a pathway context for data streams monitoring

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_value:, pathway_start:, current_edge_start:) ⇒ PathwayContext

Returns a new instance of PathwayContext.



25
26
27
28
29
30
31
32
33
34
# File 'lib/datadog/data_streams/pathway_context.rb', line 25

def initialize(hash_value:, pathway_start:, current_edge_start:)
  @hash = hash_value
  @pathway_start = pathway_start
  @current_edge_start = current_edge_start
  @parent_hash = nil

  @previous_direction = nil
  @closest_opposite_direction_hash = 0
  @closest_opposite_direction_edge_start = current_edge_start
end

Instance Attribute Details

#closest_opposite_direction_edge_startObject

Edge start time of the closest opposite direction checkpoint



23
24
25
# File 'lib/datadog/data_streams/pathway_context.rb', line 23

def closest_opposite_direction_edge_start
  @closest_opposite_direction_edge_start
end

#closest_opposite_direction_hashObject

Hash value of the closest checkpoint in opposite direction (used for loop detection)



21
22
23
# File 'lib/datadog/data_streams/pathway_context.rb', line 21

def closest_opposite_direction_hash
  @closest_opposite_direction_hash
end

#current_edge_startObject

When the current edge started



15
16
17
# File 'lib/datadog/data_streams/pathway_context.rb', line 15

def current_edge_start
  @current_edge_start
end

#hashObject

The current pathway hash value (result of FNV-1a hash function)



11
12
13
# File 'lib/datadog/data_streams/pathway_context.rb', line 11

def hash
  @hash
end

#parent_hashObject

The hash value of the parent checkpoint



17
18
19
# File 'lib/datadog/data_streams/pathway_context.rb', line 17

def parent_hash
  @parent_hash
end

#pathway_startObject

When the pathway started



13
14
15
# File 'lib/datadog/data_streams/pathway_context.rb', line 13

def pathway_start
  @pathway_start
end

#previous_directionObject

The direction tag of the previous checkpoint (e.g., ‘direction:in’, ‘direction:out’), or nil if none



19
20
21
# File 'lib/datadog/data_streams/pathway_context.rb', line 19

def previous_direction
  @previous_direction
end

Class Method Details

.decode_b64(encoded_ctx) ⇒ Object

Decode pathway context from base64 encoded string



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/datadog/data_streams/pathway_context.rb', line 41

def self.decode_b64(encoded_ctx)
  return nil unless encoded_ctx && !encoded_ctx.empty?

  begin
    binary_data = Core::Utils::Base64.strict_decode64(encoded_ctx)
    decode(binary_data)
  rescue ArgumentError => e
    # Invalid base64 encoding - may indicate version mismatch or corruption
    Datadog.logger.debug("Failed to decode DSM pathway context: #{e.message}")
    nil
  end
end

Instance Method Details

#encode_b64Object



36
37
38
# File 'lib/datadog/data_streams/pathway_context.rb', line 36

def encode_b64
  Core::Utils::Base64.strict_encode64(encode)
end