class Datadog::Profiling::Transport::HTTP::API::Endpoint
Constants
- TAGS_TO_IGNORE_IN_TAGS_HASH
These tags are read from the flush object (see below) directly and so we ignore any extra copies that may come in the tags hash to avoid duplicates.
Attributes
encoder[R]
Public Class Methods
new(path, encoder)
click to toggle source
Calls superclass method
Datadog::Transport::HTTP::API::Endpoint::new
# File lib/ddtrace/profiling/transport/http/api/endpoint.rb, line 26 def initialize(path, encoder) super(:post, path) @encoder = encoder end
Public Instance Methods
build_form(env)
click to toggle source
# File lib/ddtrace/profiling/transport/http/api/endpoint.rb, line 42 def build_form(env) flush = env.request.parcel.data pprof_file, types = build_pprof(flush) form = { # NOTE: Redundant w/ 'runtime-id' tag below; may want to remove this later. FORM_FIELD_RUNTIME_ID => flush.runtime_id, FORM_FIELD_RECORDING_START => flush.start.utc.iso8601, FORM_FIELD_RECORDING_END => flush.finish.utc.iso8601, FORM_FIELD_TAGS => [ "#{FORM_FIELD_TAG_RUNTIME}:#{flush.language}", "#{FORM_FIELD_TAG_RUNTIME_ID}:#{flush.runtime_id}", "#{FORM_FIELD_TAG_RUNTIME_ENGINE}:#{flush.runtime_engine}", "#{FORM_FIELD_TAG_RUNTIME_PLATFORM}:#{flush.runtime_platform}", "#{FORM_FIELD_TAG_RUNTIME_VERSION}:#{flush.runtime_version}", "#{FORM_FIELD_TAG_PID}:#{Process.pid}", "#{FORM_FIELD_TAG_PROFILER_VERSION}:#{flush.profiler_version}", # NOTE: Redundant w/ 'runtime'; may want to remove this later. "#{FORM_FIELD_TAG_LANGUAGE}:#{flush.language}", "#{FORM_FIELD_TAG_HOST}:#{flush.host}", *flush .tags .reject { |tag_key| TAGS_TO_IGNORE_IN_TAGS_HASH.include?(tag_key) } .map { |tag_key, tag_value| "#{tag_key}:#{tag_value}" } ], FORM_FIELD_DATA => pprof_file, FORM_FIELD_RUNTIME => flush.language, FORM_FIELD_FORMAT => FORM_FIELD_FORMAT_PPROF } # Add types form[FORM_FIELD_TYPES] = types.join(',') # Optional fields form[FORM_FIELD_TAGS] << "#{FORM_FIELD_TAG_SERVICE}:#{flush.service}" unless flush.service.nil? form[FORM_FIELD_TAGS] << "#{FORM_FIELD_TAG_ENV}:#{flush.env}" unless flush.env.nil? form[FORM_FIELD_TAGS] << "#{FORM_FIELD_TAG_VERSION}:#{flush.version}" unless flush.version.nil? form end
build_pprof(flush)
click to toggle source
# File lib/ddtrace/profiling/transport/http/api/endpoint.rb, line 83 def build_pprof(flush) pprof = encoder.encode(flush) # Wrap pprof as a gzipped file gzipped_data = Datadog::Utils::Compression.gzip(pprof.data) pprof_file = Datadog::Vendor::Multipart::Post::UploadIO.new( StringIO.new(gzipped_data), HEADER_CONTENT_TYPE_OCTET_STREAM, PPROF_DEFAULT_FILENAME ) [pprof_file, [FORM_FIELD_TYPES_AUTO]] end
call(env, &block)
click to toggle source
Calls superclass method
Datadog::Transport::HTTP::API::Endpoint#call
# File lib/ddtrace/profiling/transport/http/api/endpoint.rb, line 31 def call(env, &block) # Build request env.form = build_form(env) # Send request http_response = super(env, &block) # Build response Profiling::Transport::HTTP::Response.new(http_response) end