class Datadog::Transport::HTTP::Traces::API::Endpoint
Endpoint
for submitting trace data
Constants
- HEADER_CONTENT_TYPE
- HEADER_TRACE_COUNT
- SERVICE_RATE_KEY
Attributes
encoder[R]
Public Class Methods
new(path, encoder, options = {})
click to toggle source
Calls superclass method
Datadog::Transport::HTTP::API::Endpoint::new
# File lib/ddtrace/transport/http/traces.rb, line 100 def initialize(path, encoder, options = {}) super(:post, path) @encoder = encoder @service_rates = options.fetch(:service_rates, false) end
Public Instance Methods
call(env, &block)
click to toggle source
Calls superclass method
Datadog::Transport::HTTP::API::Endpoint#call
# File lib/ddtrace/transport/http/traces.rb, line 110 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(env, &block) # Process the response response_options = { trace_count: env.request.parcel.trace_count }.tap do |options| # Parse service rates, if configured to do so. if service_rates? && !http_response.payload.to_s.empty? body = JSON.parse(http_response.payload) options[: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, response_options) end
service_rates?()
click to toggle source
# File lib/ddtrace/transport/http/traces.rb, line 106 def service_rates? @service_rates == true end