Skip to content

Commit 38e2ea3

Browse files
Christopher Frostnebhale
authored andcommitted
AppDynamics Tier Name in Credentials
Previously, the tier name provided to the AppDynamics agent was hard- coded in the component configuration file. This meant that the only way to change the tier name was to fork the buildpack; a heavy-weight exercise. This change makes the configured tier name, the "default" choice which can be overridden with a 'tier-name' entry in the service credentials. [#75252498][cloudfoundry#55][cloudfoundry#59]
1 parent 120c640 commit 38e2ea3

6 files changed

Lines changed: 29 additions & 15 deletions

File tree

Gemfile.lock

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ GEM
1212
debugger-ruby_core_source (1.3.5)
1313
diff-lcs (1.2.5)
1414
docile (1.1.5)
15-
json (1.8.1)
1615
multi_json (1.10.1)
17-
parser (2.2.0.pre.3)
16+
parser (2.2.0.pre.4)
1817
ast (>= 1.1, < 3.0)
1918
slop (~> 3.4, >= 3.4.5)
2019
powerpack (0.0.9)
@@ -25,17 +24,16 @@ GEM
2524
rspec-core (~> 3.0.0)
2625
rspec-expectations (~> 3.0.0)
2726
rspec-mocks (~> 3.0.0)
28-
rspec-core (3.0.3)
27+
rspec-core (3.0.4)
2928
rspec-support (~> 3.0.0)
30-
rspec-expectations (3.0.3)
29+
rspec-expectations (3.0.4)
3130
diff-lcs (>= 1.2.0, < 2.0)
3231
rspec-support (~> 3.0.0)
33-
rspec-mocks (3.0.3)
32+
rspec-mocks (3.0.4)
3433
rspec-support (~> 3.0.0)
35-
rspec-support (3.0.3)
36-
rubocop (0.24.1)
37-
json (>= 1.7.7, < 2)
38-
parser (>= 2.2.0.pre.3, < 3.0)
34+
rspec-support (3.0.4)
35+
rubocop (0.25.0)
36+
parser (>= 2.2.0.pre.4, < 3.0)
3937
powerpack (~> 0.0.6)
4038
rainbow (>= 1.99.1, < 3.0)
4139
ruby-progressbar (~> 1.4)

config/app_dynamics_agent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
---
1818
version: 3.8.+
1919
repository_root: "{default.repository.root}/app-dynamics"
20-
tier_name: CloudFoundry
20+
default_tier_name: CloudFoundry

docs/framework-app_dynamics_agent.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ When binding AppDynamics using a user-provided service, it must have name or tag
2222
| `host-name` | The controller host name
2323
| `port` | (Optional) The controller port
2424
| `ssl-enabled` | (Optional) Whether or not to use an SSL connection to the controller
25+
| `tier-name` | (Optional) the application's tier name
2526

2627
## Configuration
2728
For general information on configuring the buildpack, refer to [Configuration and Extension][].
@@ -30,8 +31,8 @@ The framework can be configured by modifying the [`config/app_dynamics_agent.yml
3031

3132
| Name | Description
3233
| ---- | -----------
34+
| `default_tier_name` | The default tier name for this application in the AppDynamics dashboard. This can be overridden with a `tier-name` entry in the credentials payload.
3335
| `repository_root` | The URL of the AppDynamics repository index ([details][repositories]).
34-
| `tier_name` | The tier_name for this application in the AppDynamics dashboard.
3536
| `version` | The version of AppDynamics to use. Candidate versions can be found in [this listing][].
3637

3738
### Additional Resources

java-buildpack.iml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,10 @@
273273
<orderEntry type="sourceFolder" forTests="false" />
274274
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, rbenv: 1.9.3-p547) [gem]" level="application" />
275275
<orderEntry type="library" scope="PROVIDED" name="ast (v2.0.0, rbenv: 1.9.3-p547) [gem]" level="application" />
276-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.3, rbenv: 1.9.3-p547) [gem]" level="application" />
277-
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.3.0, rbenv: 1.9.3-p547) [gem]" level="application" />
276+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.0, rbenv: 1.9.3-p547) [gem]" level="application" />
277+
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.4.0, rbenv: 1.9.3-p547) [gem]" level="application" />
278278
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, rbenv: 1.9.3-p547) [gem]" level="application" />
279+
<orderEntry type="library" scope="PROVIDED" name="debase (v0.0.9, rbenv: 1.9.3-p547) [gem]" level="application" />
279280
<orderEntry type="library" scope="PROVIDED" name="debugger-ruby_core_source (v1.3.5, rbenv: 1.9.3-p547) [gem]" level="application" />
280281
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 1.9.3-p547) [gem]" level="application" />
281282
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, rbenv: 1.9.3-p547) [gem]" level="application" />

lib/java_buildpack/framework/app_dynamics_agent.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def release
3838
java_opts
3939
.add_javaagent(@droplet.sandbox + 'javaagent.jar')
4040
.add_system_property('appdynamics.agent.applicationName', "'#{application_name}'")
41-
.add_system_property('appdynamics.agent.tierName', "'#{@configuration['tier_name']}'")
41+
.add_system_property('appdynamics.agent.tierName', "'#{tier_name(credentials)}'")
4242
.add_system_property('appdynamics.agent.nodeName',
4343
"$(expr \"$VCAP_APPLICATION\" : '.*instance_id[\": ]*\"\\([a-z0-9]\\+\\)\".*')")
4444

@@ -62,6 +62,10 @@ def supports?
6262

6363
private_constant :FILTER
6464

65+
def tier_name(credentials)
66+
credentials.key?('tier-name') ? credentials['tier-name'] : @configuration['default_tier_name']
67+
end
68+
6569
def application_name
6670
@application.details['application_name']
6771
end

spec/java_buildpack/framework/app_dynamics_agent_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
describe JavaBuildpack::Framework::AppDynamicsAgent do
2222
include_context 'component_helper'
2323

24-
let(:configuration) { { 'tier_name' => 'test-tier-name' } }
24+
let(:configuration) { { 'default_tier_name' => 'test-tier-name' } }
2525

2626
it 'should not detect without app-dynamics-n/a service' do
2727
expect(component.detect).to be_nil
@@ -67,6 +67,16 @@
6767
'\'.*instance_id[": ]*"\([a-z0-9]\+\)".*\')')
6868
end
6969

70+
context do
71+
let(:credentials) { super().merge 'tier-name' => 'another-test-tier-name' }
72+
73+
it 'should add tier_name from credentials to JAVA_OPTS if specified' do
74+
component.release
75+
76+
expect(java_opts).to include("-Dappdynamics.agent.tierName='another-test-tier-name'")
77+
end
78+
end
79+
7080
context do
7181
let(:credentials) { super().merge 'port' => 'test-port' }
7282

0 commit comments

Comments
 (0)