Class: Datadog::Tracing::Transport::Native::Response
- Inherits:
-
Object
- Object
- Datadog::Tracing::Transport::Native::Response
- Defined in:
- lib/datadog/tracing/transport/native/response.rb
Overview
Response from the native trace exporter.
Constructed by the C extension after a send completes (or fails). Implements the same predicate interface as the HTTP transport's response so callers can treat both uniformly.
Constant Summary collapse
- SERVICE_RATE_KEY =
"rate_by_service"
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#trace_count ⇒ Object
readonly
Returns the value of attribute trace_count.
Instance Method Summary collapse
- #client_error? ⇒ Boolean
-
#initialize(ok:, internal_error: false, server_error: false, client_error: false, not_found: false, unsupported: false, trace_count: 0, payload: nil) ⇒ Response
constructor
A new instance of Response.
- #internal_error? ⇒ Boolean
- #not_found? ⇒ Boolean
- #ok? ⇒ Boolean
- #server_error? ⇒ Boolean
-
#service_rates ⇒ Object
Parse the agent's JSON response body and extract the
rate_by_servicemap. - #unsupported? ⇒ Boolean
Constructor Details
#initialize(ok:, internal_error: false, server_error: false, client_error: false, not_found: false, unsupported: false, trace_count: 0, payload: nil) ⇒ Response
Returns a new instance of Response.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 19 def initialize(ok:, internal_error: false, server_error: false, client_error: false, not_found: false, unsupported: false, trace_count: 0, payload: nil) @ok = ok @internal_error = internal_error @server_error = server_error @client_error = client_error @not_found = not_found @unsupported = unsupported @trace_count = trace_count @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
17 18 19 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 17 def payload @payload end |
#trace_count ⇒ Object (readonly)
Returns the value of attribute trace_count.
17 18 19 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 17 def trace_count @trace_count end |
Instance Method Details
#client_error? ⇒ Boolean
43 44 45 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 43 def client_error? @client_error end |
#internal_error? ⇒ Boolean
35 36 37 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 35 def internal_error? @internal_error end |
#not_found? ⇒ Boolean
47 48 49 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 47 def not_found? @not_found end |
#ok? ⇒ Boolean
31 32 33 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 31 def ok? @ok end |
#server_error? ⇒ Boolean
39 40 41 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 39 def server_error? @server_error end |
#service_rates ⇒ Object
Parse the agent's JSON response body and extract the
rate_by_service map. Returns nil when the payload
is absent or does not contain sampling rates.
58 59 60 61 62 63 64 65 66 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 58 def service_rates payload = @payload return nil if payload.nil? || payload.empty? parsed = JSON.parse(payload) parsed[SERVICE_RATE_KEY] if parsed.is_a?(Hash) rescue JSON::ParserError nil end |
#unsupported? ⇒ Boolean
51 52 53 |
# File 'lib/datadog/tracing/transport/native/response.rb', line 51 def unsupported? @unsupported end |