Skip to content

Commit 0ae541e

Browse files
author
Christopher Frost
committed
Merge 104558394-dynatrace-agent-name to master
[Completes #104558394]
2 parents 7e33cda + 6e53039 commit 0ae541e

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

config/dyna_trace_agent.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
---
1818
version: 6.1.0_+
1919
repository_root: ""
20+
default_agent_name:

docs/framework-dyna_trace_agent.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ The framework can be configured by modifying the [`config/dyna_trace_agent.yml`]
6666
| ---- | -----------
6767
| `repository_root` | The URL of the DynaTrace repository index ([details][repositories]).
6868
| `version` | The version of DynaTrace to use. This buildpack framework has been tested on 6.1.0.
69+
| `default_agent_name` | This is omitted by default but can be added to set the DynaTrace agent name. If it is not specified then `#{application_name}_#{profile_name}` is used, where `application_name` is defined by Cloud Foundry.
6970

7071
### Additional Resources
7172
The framework can also be configured by overlaying a set of resources on the default distribution. To do this, add files to the `resources/dyna_trace_agent` directory in the buildpack fork.

lib/java_buildpack/framework/dyna_trace_agent.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def agent_path
5959
end
6060

6161
def agent_name
62-
"#{@application.details['application_name']}_#{profile_name}"
62+
@configuration['default_agent_name'] || "#{@application.details['application_name']}_#{profile_name}"
6363
end
6464

6565
def architecture

spec/java_buildpack/framework/dyna_trace_agent_spec.rb

+19-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
describe JavaBuildpack::Framework::DynaTraceAgent do
2222
include_context 'component_helper'
2323

24+
let(:configuration) do
25+
{ 'default_agent_name' => nil }
26+
end
27+
2428
it 'does not detect without dynatrace-n/a service' do
2529
expect(component.detect).to be_nil
2630
end
@@ -45,23 +49,33 @@
4549

4650
it 'updates JAVA_OPTS' do
4751
component.release
48-
expect(java_opts).to include(
49-
'-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
52+
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
5053
'libdtagent.so=name=test-application-name_Monitoring,server=test-host-name')
5154
end
55+
56+
context do
57+
58+
let(:configuration) { { 'default_agent_name' => 'different-agent-name' } }
59+
60+
it 'updates JAVA_OPTS with configured agent name' do
61+
component.release
62+
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
63+
'libdtagent.so=name=different-agent-name,server=test-host-name')
64+
end
65+
66+
end
5267
end
5368

5469
context do
5570
before do
5671
allow(services).to receive(:one_service?).with(/dynatrace/, 'server').and_return(true)
57-
allow(services).to receive(:find_service).and_return('credentials' => { 'server' => 'test-host-name',
72+
allow(services).to receive(:find_service).and_return('credentials' => { 'server' => 'test-host-name',
5873
'profile' => 'test-profile' })
5974
end
6075

6176
it 'updates JAVA_OPTS with custom profile' do
6277
component.release
63-
expect(java_opts).to include(
64-
'-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
78+
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
6579
'libdtagent.so=name=test-application-name_test-profile,server=test-host-name')
6680
end
6781

0 commit comments

Comments
 (0)