Module: Datadog::CI::Transport::Telemetry

Defined in:
lib/datadog/ci/transport/telemetry.rb

Class Method Summary collapse

Class Method Details

.api_requests(metric_name, count, compressed:) ⇒ Object



68
69
70
71
72
73
# File 'lib/datadog/ci/transport/telemetry.rb', line 68

def self.api_requests(metric_name, count, compressed:)
  tags = {}
  tags[Ext::Telemetry::TAG_REQUEST_COMPRESSED] = "true" if compressed

  Utils::Telemetry.inc(metric_name, count, tags)
end

.api_requests_errors(metric_name, count, error_type:, status_code:) ⇒ Object



75
76
77
78
79
80
# File 'lib/datadog/ci/transport/telemetry.rb', line 75

def self.api_requests_errors(metric_name, count, error_type:, status_code:)
  tags = {}
  set_error_tags(tags, error_type: error_type, status_code: status_code)

  Utils::Telemetry.inc(metric_name, count, tags)
end

.endpoint_payload_bytes(bytesize, endpoint:) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/datadog/ci/transport/telemetry.rb', line 53

def self.endpoint_payload_bytes(bytesize, endpoint:)
  Utils::Telemetry.distribution(
    Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_BYTES,
    bytesize.to_f,
    tags(endpoint: endpoint)
  )
end

.endpoint_payload_dropped(count, endpoint:) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/datadog/ci/transport/telemetry.rb', line 30

def self.endpoint_payload_dropped(count, endpoint:)
  Utils::Telemetry.inc(
    Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_DROPPED,
    count,
    tags(endpoint: endpoint)
  )
end

.endpoint_payload_events_count(count, endpoint:) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/datadog/ci/transport/telemetry.rb', line 14

def self.endpoint_payload_events_count(count, endpoint:)
  Utils::Telemetry.distribution(
    Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_EVENTS_COUNT,
    count.to_f,
    tags(endpoint: endpoint)
  )
end

.endpoint_payload_requests(count, endpoint:, compressed:) ⇒ Object



38
39
40
41
42
43
# File 'lib/datadog/ci/transport/telemetry.rb', line 38

def self.endpoint_payload_requests(count, endpoint:, compressed:)
  tags = tags(endpoint: endpoint)
  tags[Ext::Telemetry::TAG_REQUEST_COMPRESSED] = "true" if compressed

  Utils::Telemetry.inc(Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_REQUESTS, count, tags)
end

.endpoint_payload_requests_errors(count, endpoint:, error_type:, status_code:) ⇒ Object



61
62
63
64
65
66
# File 'lib/datadog/ci/transport/telemetry.rb', line 61

def self.endpoint_payload_requests_errors(count, endpoint:, error_type:, status_code:)
  tags = tags(endpoint: endpoint)
  set_error_tags(tags, error_type: error_type, status_code: status_code)

  Utils::Telemetry.inc(Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_REQUESTS_ERRORS, count, tags)
end

.endpoint_payload_requests_ms(duration_ms, endpoint:) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/datadog/ci/transport/telemetry.rb', line 45

def self.endpoint_payload_requests_ms(duration_ms, endpoint:)
  Utils::Telemetry.distribution(
    Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_REQUESTS_MS,
    duration_ms,
    tags(endpoint: endpoint)
  )
end

.endpoint_payload_serialization_ms(duration_ms, endpoint:) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/datadog/ci/transport/telemetry.rb', line 22

def self.endpoint_payload_serialization_ms(duration_ms, endpoint:)
  Utils::Telemetry.distribution(
    Ext::Telemetry::METRIC_ENDPOINT_PAYLOAD_EVENTS_SERIALIZATION_MS,
    duration_ms,
    tags(endpoint: endpoint)
  )
end

.events_enqueued_for_serialization(count) ⇒ Object



10
11
12
# File 'lib/datadog/ci/transport/telemetry.rb', line 10

def self.events_enqueued_for_serialization(count)
  Utils::Telemetry.inc(Ext::Telemetry::METRIC_EVENTS_ENQUEUED, count)
end

.set_error_tags(tags, error_type:, status_code:) ⇒ Object



86
87
88
89
# File 'lib/datadog/ci/transport/telemetry.rb', line 86

def self.set_error_tags(tags, error_type:, status_code:)
  tags[Ext::Telemetry::TAG_ERROR_TYPE] = error_type if error_type
  tags[Ext::Telemetry::TAG_STATUS_CODE] = status_code.to_s if status_code
end

.tags(endpoint:) ⇒ Object



82
83
84
# File 'lib/datadog/ci/transport/telemetry.rb', line 82

def self.tags(endpoint:)
  {Ext::Telemetry::TAG_ENDPOINT => endpoint}
end