Class: Datadog::Statsd::Telemetry
- Inherits:
-
Object
- Object
- Datadog::Statsd::Telemetry
- Defined in:
- lib/datadog/statsd/telemetry.rb
Constant Summary collapse
- MAX_TELEMETRY_MESSAGE_SIZE_WT_TAGS =
Rough estimation of maximum telemetry message size without tags
50
Instance Attribute Summary collapse
-
#bytes_dropped ⇒ Object
readonly
Returns the value of attribute bytes_dropped.
-
#bytes_sent ⇒ Object
readonly
Returns the value of attribute bytes_sent.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#packets_dropped ⇒ Object
readonly
Returns the value of attribute packets_dropped.
-
#packets_sent ⇒ Object
readonly
Returns the value of attribute packets_sent.
-
#service_checks ⇒ Object
readonly
Returns the value of attribute service_checks.
Instance Method Summary collapse
- #dropped(bytes: 0, packets: 0) ⇒ Object
- #flush ⇒ Object
-
#initialize(flush_interval, global_tags: [], transport_type: :udp) ⇒ Telemetry
constructor
bytes.
- #reset ⇒ Object
- #sent(metrics: 0, events: 0, service_checks: 0, bytes: 0, packets: 0) ⇒ Object
- #should_flush? ⇒ Boolean
- #would_fit_in?(max_buffer_payload_size) ⇒ Boolean
Constructor Details
#initialize(flush_interval, global_tags: [], transport_type: :udp) ⇒ Telemetry
bytes
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/datadog/statsd/telemetry.rb', line 18 def initialize(flush_interval, global_tags: [], transport_type: :udp) @flush_interval = flush_interval @global_tags = @transport_type = transport_type reset # TODO: Karim: I don't know why but telemetry tags are serialized # before global tags so by refactoring this, I am keeping the same behavior @serialized_tags = Serialization::TagSerializer.new( client: 'ruby', client_version: VERSION, client_transport: transport_type, ).format() end |
Instance Attribute Details
#bytes_dropped ⇒ Object (readonly)
Returns the value of attribute bytes_dropped.
11 12 13 |
# File 'lib/datadog/statsd/telemetry.rb', line 11 def bytes_dropped @bytes_dropped end |
#bytes_sent ⇒ Object (readonly)
Returns the value of attribute bytes_sent.
10 11 12 |
# File 'lib/datadog/statsd/telemetry.rb', line 10 def bytes_sent @bytes_sent end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
8 9 10 |
# File 'lib/datadog/statsd/telemetry.rb', line 8 def events @events end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
7 8 9 |
# File 'lib/datadog/statsd/telemetry.rb', line 7 def metrics @metrics end |
#packets_dropped ⇒ Object (readonly)
Returns the value of attribute packets_dropped.
13 14 15 |
# File 'lib/datadog/statsd/telemetry.rb', line 13 def packets_dropped @packets_dropped end |
#packets_sent ⇒ Object (readonly)
Returns the value of attribute packets_sent.
12 13 14 |
# File 'lib/datadog/statsd/telemetry.rb', line 12 def packets_sent @packets_sent end |
#service_checks ⇒ Object (readonly)
Returns the value of attribute service_checks.
9 10 11 |
# File 'lib/datadog/statsd/telemetry.rb', line 9 def service_checks @service_checks end |
Instance Method Details
#dropped(bytes: 0, packets: 0) ⇒ Object
57 58 59 60 |
# File 'lib/datadog/statsd/telemetry.rb', line 57 def dropped(bytes: 0, packets: 0) @bytes_dropped += bytes @packets_dropped += packets end |
#flush ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/datadog/statsd/telemetry.rb', line 66 def flush [ sprintf(pattern, 'metrics', @metrics), sprintf(pattern, 'events', @events), sprintf(pattern, 'service_checks', @service_checks), sprintf(pattern, 'bytes_sent', @bytes_sent), sprintf(pattern, 'bytes_dropped', @bytes_dropped), sprintf(pattern, 'packets_sent', @packets_sent), sprintf(pattern, 'packets_dropped', @packets_dropped), ] end |
#reset ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/datadog/statsd/telemetry.rb', line 37 def reset @metrics = 0 @events = 0 @service_checks = 0 @bytes_sent = 0 @bytes_dropped = 0 @packets_sent = 0 @packets_dropped = 0 @next_flush_time = now_in_s + @flush_interval end |
#sent(metrics: 0, events: 0, service_checks: 0, bytes: 0, packets: 0) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/datadog/statsd/telemetry.rb', line 48 def sent(metrics: 0, events: 0, service_checks: 0, bytes: 0, packets: 0) @metrics += metrics @events += events @service_checks += service_checks @bytes_sent += bytes @packets_sent += packets end |
#should_flush? ⇒ Boolean
62 63 64 |
# File 'lib/datadog/statsd/telemetry.rb', line 62 def should_flush? @next_flush_time < now_in_s end |
#would_fit_in?(max_buffer_payload_size) ⇒ Boolean
33 34 35 |
# File 'lib/datadog/statsd/telemetry.rb', line 33 def would_fit_in?(max_buffer_payload_size) MAX_TELEMETRY_MESSAGE_SIZE_WT_TAGS + .size < max_buffer_payload_size end |