Skip to content

Commit e6bb731

Browse files
author
Daniel Mikusa
committed
Enable pulling the application version for DataDog from the DD_VERSION environment variable.
1 parent 26618ea commit e6bb731

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/java_buildpack/framework/datadog_javaagent.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ def release
5050
java_opts.add_system_property('dd.service', "\\\"#{app_name}\\\"")
5151
end
5252

53-
return if @application.environment.key?('DD_VERSION') || !@application.details['application_version']
54-
55-
version = @configuration['default_application_version'] || @application.details['application_version']
53+
version = @application.environment['DD_VERSION'] || @configuration['default_application_version'] ||
54+
@application.details['application_version']
5655
java_opts.add_system_property('dd.version', version)
5756
end
5857

spec/java_buildpack/framework/datadog_javaagent_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,21 @@
110110

111111
context 'when dd_version environment variable is provided' do
112112
let(:environment) do
113-
super().update({ 'DD_VERSION' => 'test-application-version' })
113+
super().update({ 'DD_VERSION' => 'env-variable-version' })
114114
end
115115

116-
it 'release updates JAVA_OPTS' do
116+
before do
117+
FileUtils.mkdir_p File.join(context[:droplet].root, 'datadog')
118+
end
119+
120+
after do
121+
FileUtils.rmdir File.join(context[:droplet].root, 'datadog')
122+
end
123+
124+
it 'release updates JAVA_OPTS with env variable version' do
117125
component.release
118126

119-
expect(java_opts).not_to include('-Ddd.version=test-application-version')
127+
expect(java_opts).to include('-Ddd.version=env-variable-version')
120128
end
121129
end
122130
end

0 commit comments

Comments
 (0)