Class: Datadog::Tracing::Transport::HTTP::Telemetry::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/tracing/transport/http/telemetry.rb

Instance Method Summary collapse

Constructor Details

#initialize(reporter, traces) ⇒ Batch

Returns a new instance of Batch.



24
25
26
27
28
29
# File 'lib/datadog/tracing/transport/http/telemetry.rb', line 24

def initialize(reporter, traces)
  @reporter = reporter
  @remaining_chunks = traces.length
  @remaining_spans = traces.sum(&:length)
  @reporter.record(spans_enqueued_for_serialization: @remaining_spans)
end

Instance Method Details

#record_oversized_drop(span_count) ⇒ Object



31
32
33
34
35
# File 'lib/datadog/tracing/transport/http/telemetry.rb', line 31

def record_oversized_drop(span_count)
  @remaining_chunks -= 1
  @remaining_spans -= span_count
  @reporter.record(chunks_dropped_payload_too_large: 1, spans_dropped_payload_too_large: span_count)
end

#sent(request, response, chunks, spans, bytes, fallback:) ⇒ Object



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
# File 'lib/datadog/tracing/transport/http/telemetry.rb', line 42

def sent(request, response, chunks, spans, bytes, fallback:)
  @reporter.record(requests_count: 1)
  return if fallback

  @remaining_chunks -= chunks
  @remaining_spans -= spans
  observations = {} #: Hash[Symbol, Integer]
  if (status = request.http_status)
    observations[:responses_count] = 1
    observations[:status_code] = status
  end
  success = status ? status.between?(200, 299) : request.http_success
  if success
    observations[:chunks_sent] = chunks
    observations[:bytes_sent] = bytes
  elsif status || success == false
    observations[:errors_status_code] = 1 if status
    observations[:chunks_dropped_send_failure] = chunks
    observations[:spans_dropped_api_error] = spans
  elsif response.is_a?(Core::Transport::InternalErrorResponse)
    error = response.error
    if error.is_a?(ArgumentError) || error.is_a?(TypeError)
      observations[:chunks_dropped_serialization_error] = chunks
      observations[:spans_dropped_serialization_error] = spans
    else
      observations[:chunks_dropped_send_failure] = chunks
      observations[:spans_dropped_api_error] = spans
      if error.is_a?(::Timeout::Error) || error.is_a?(Errno::ETIMEDOUT)
        observations[:errors_timeout] = 1
      elsif network_error?(error)
        observations[:errors_network] = 1
      end
    end
  end
  @reporter.record(observations)
rescue
  nil
end

#serialization_failed ⇒ Object



37
38
39
40
# File 'lib/datadog/tracing/transport/http/telemetry.rb', line 37

def serialization_failed
  @reporter.record(chunks_dropped_serialization_error: @remaining_chunks,
    spans_dropped_serialization_error: @remaining_spans)
end