Skip to content

Commit

Permalink
Merge pull request #1464 from DataDog/feature/include-pid-when-report…
Browse files Browse the repository at this point in the history
…ing-profile

Include process pid when reporting profile
  • Loading branch information
ivoanjo committed Apr 20, 2021
2 parents d9ad5c7 + f03c9c7 commit 9625757
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/ddtrace/ext/profiling.rb
Expand Up @@ -29,6 +29,7 @@ module HTTP
FORM_FIELD_TAG_ENV = 'env'.freeze
FORM_FIELD_TAG_HOST = 'host'.freeze
FORM_FIELD_TAG_LANGUAGE = 'language'.freeze
FORM_FIELD_TAG_PID = 'pid'.freeze
FORM_FIELD_TAG_PROFILER_VERSION = 'profiler_version'.freeze
FORM_FIELD_TAG_RUNTIME = 'runtime'.freeze
FORM_FIELD_TAG_RUNTIME_ENGINE = 'runtime_engine'.freeze
Expand Down
1 change: 1 addition & 0 deletions lib/ddtrace/profiling/transport/http/api/endpoint.rb
Expand Up @@ -48,6 +48,7 @@ def build_form(env)
"#{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}",
Expand Down
Expand Up @@ -12,7 +12,7 @@

RSpec.describe 'Adapters::Net profiling integration tests' do
before do
skip unless ENV['TEST_DATADOG_INTEGRATION']
skip 'TEST_DATADOG_INTEGRATION is not defined' unless ENV['TEST_DATADOG_INTEGRATION']
skip 'Profiling is not supported.' unless Datadog::Profiling.supported?
end

Expand Down Expand Up @@ -50,8 +50,13 @@
end

after do
server.shutdown
@server_thread.join
unless RSpec.current_example.skipped?
# When the test is skipped, server has not been initialized and @server_thread would be nil; thus we only
# want to touch them when the test actually run, otherwise we would cause the server to start (incorrectly)
# and join to be called on a nil @server_thread
server.shutdown
@server_thread.join
end
end
end

Expand Down Expand Up @@ -105,6 +110,7 @@
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_ENGINE}:#{Datadog::Ext::Runtime::LANG_ENGINE}/o,
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_PLATFORM}:#{Datadog::Ext::Runtime::LANG_PLATFORM}/o,
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_VERSION}:#{Datadog::Ext::Runtime::LANG_VERSION}/o,
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_PID}:#{Process.pid}/o,
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_PROFILER_VERSION}:#{Datadog::Ext::Runtime::TRACER_VERSION}/o,
/#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_LANGUAGE}:#{Datadog::Ext::Runtime::LANG}/o
)
Expand Down
1 change: 1 addition & 0 deletions spec/ddtrace/profiling/transport/http/api/endpoint_spec.rb
Expand Up @@ -71,6 +71,7 @@
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_ENGINE}:#{flush.runtime_engine}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_PLATFORM}:#{flush.runtime_platform}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_RUNTIME_VERSION}:#{flush.runtime_version}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_PID}:#{Process.pid}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_PROFILER_VERSION}:#{flush.profiler_version}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_LANGUAGE}:#{flush.language}",
"#{Datadog::Ext::Profiling::Transport::HTTP::FORM_FIELD_TAG_HOST}:#{flush.host}"
Expand Down

0 comments on commit 9625757

Please sign in to comment.