Class: Datadog::Tracing::Transport::HTTP::Traces::API::Endpoint
- Inherits:
-
Core::Transport::HTTP::API::Endpoint
- Object
- Core::Transport::HTTP::API::Endpoint
- Datadog::Tracing::Transport::HTTP::Traces::API::Endpoint
- Defined in:
- lib/datadog/tracing/transport/http/traces.rb
Overview
Endpoint for submitting trace data
Constant Summary collapse
- HEADER_CONTENT_TYPE =
'Content-Type'- HEADER_TRACE_COUNT =
'X-Datadog-Trace-Count'- SERVICE_RATE_KEY =
'rate_by_service'
Instance Attribute Summary
Attributes inherited from Core::Transport::HTTP::API::Endpoint
Instance Method Summary collapse
- #call(env, &block) ⇒ Object
-
#initialize(path, encoder, options = {}) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #service_rates? ⇒ Boolean
Constructor Details
#initialize(path, encoder, options = {}) ⇒ Endpoint
Returns a new instance of Endpoint.
35 36 37 38 |
# File 'lib/datadog/tracing/transport/http/traces.rb', line 35 def initialize(path, encoder, = {}) super(:post, path, encoder: encoder) @service_rates = .fetch(:service_rates, false) end |
Instance Method Details
#call(env, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/datadog/tracing/transport/http/traces.rb', line 44 def call(env, &block) # Add trace count header env.headers[HEADER_TRACE_COUNT] = env.request.parcel.trace_count.to_s # Encode body & type env.headers[HEADER_CONTENT_TYPE] = encoder.content_type env.body = env.request.parcel.data # Query for response http_response = super # Process the response = {trace_count: env.request.parcel.trace_count}.tap do || # Parse service rates, if configured to do so. if service_rates? && !http_response.payload.to_s.empty? body = JSON.parse(http_response.payload) [:service_rates] = body[SERVICE_RATE_KEY] if body.is_a?(Hash) && body.key?(SERVICE_RATE_KEY) end end # Build and return a trace response Traces::Response.new(http_response, ) end |
#service_rates? ⇒ Boolean
40 41 42 |
# File 'lib/datadog/tracing/transport/http/traces.rb', line 40 def service_rates? @service_rates == true end |