Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/datadog/core/process_discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_metadata(settings)
service_name: settings.service || '',
service_env: settings.env || '',
service_version: settings.version || '',
# TODO: Implement process tags and container id
# TODO: Implement process tags and container id and determine how it changes with this PR
process_tags: '',
container_id: ''
}
Expand Down
7 changes: 7 additions & 0 deletions lib/datadog/profiling/tag_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require_relative '../core/tag_builder'
require_relative '../core/utils'
require_relative '../core/environment/ext'

require 'set'

Expand Down Expand Up @@ -36,6 +37,7 @@ module TagBuilder
'runtime_version',
'runtime-id',
'process_id',
'process_tags',
'profiler_version',
'profile_seq',
]
Expand All @@ -50,6 +52,11 @@ def self.call(
FORM_FIELD_TAG_PROFILER_VERSION => profiler_version,
'profile_seq' => profile_seq.to_s,
)

if settings.experimental_propagate_process_tags_enabled
hash['process_tags'] = Core::Environment::Process.serialized
end

user_tag_keys = settings.tags.keys
hash.keep_if { |tag| user_tag_keys.include?(tag) || ALLOWED_TAGS.include?(tag) }
Core::Utils.encode_tags(hash)
Expand Down
24 changes: 24 additions & 0 deletions spec/datadog/profiling/tag_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,29 @@
end
end
end

describe "process tags" do
context 'when process tags are enabled' do
before do
settings.experimental_propagate_process_tags_enabled = true
end

it "includes the process tags" do
expect(call).to include("process_tags" => Datadog::Core::Environment::Process.serialized)
process_tags_values = call["process_tags"]

expect(process_tags_values).to include("entrypoint.type:script")
expect(process_tags_values).to include("entrypoint.workdir:app")
expect(process_tags_values).to include("entrypoint.name:rspec")
expect(process_tags_values).to include("entrypoint.basedir:bin")
end
end
context 'when process tags are not enabled' do
it "excludes the process tags" do
# it is off by default
expect(call).to_not include("process_tags")
end
end
end
end
end
Loading