Skip to content

Commit 69abec6

Browse files
author
Christopher Frost
committed
Change to AppDynamics tier_name resolution
This commit sets the `default_application_name` and `default_tier_name` to empty properties in the AppDynamics config file. This mean they can be easily set by an environment variable. If they are left empty and no value is given by the credentials payload of the bound AppDynamics service, then `application_name` already uses to the application name set by Cloud Foundry but the `tier_name` will now also use the application name set by Cloud Foundry for its value. [#102469346]
1 parent 60700af commit 69abec6

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

config/app_dynamics_agent.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
---
1818
version: 4.1.+
1919
repository_root: ! '{default.repository.root}/app-dynamics'
20+
default_application_name:
2021
default_node_name: ! '$(expr "$VCAP_APPLICATION" : ''.*instance_index[": ]*\([[:digit:]]*\).*'')'
21-
default_tier_name: CloudFoundry
22+
default_tier_name:

docs/framework-app_dynamics_agent.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The AppDynamics Agent Framework causes an application to be automatically config
1313
Tags are printed to standard output by the buildpack detect script
1414

1515
## User-Provided Service
16-
When binding AppDynamics using a user-provided service, it must have name or tag with `app-dynamics` or `appdynamics` in it. The credential payload can contain the following entries:
16+
When binding AppDynamics using a user-provided service, it must have name or tag with `app-dynamics` or `appdynamics` in it. The credential payload can contain the following entries:
1717

1818
| Name | Description
1919
| ---- | -----------
@@ -31,18 +31,18 @@ To provide more complex values such as the `tier-name`, using the interactive mo
3131
## Configuration
3232
For general information on configuring the buildpack, refer to [Configuration and Extension][].
3333

34-
The framework can be configured by modifying the [`config/app_dynamics_agent.yml`][] file in the buildpack fork. The framework uses the [`Repository` utility support][repositories] and so it supports the [version syntax][] defined there.
34+
The framework can be configured by modifying the [`config/app_dynamics_agent.yml`][] file in the buildpack fork. The framework uses the [`Repository` utility support][repositories] and so it supports the [version syntax][] defined there.
3535

3636
| Name | Description
3737
| ---- | -----------
38-
| `default_application_name` | This is not provided by default but can be added to specify the application name in the AppDynamics dashboard. This can be overridden with an `application-name` entry in the credentials payload.
39-
| `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.
40-
| `default_node_name` | The default node name for this application in the AppDynamics dashboard. The default value is an expression that will be evaluated based on the `instance_index` of the application. This can be overridden with a `node-name` entry in the credentials payload.
38+
| `default_application_name` | This is omitted by default but can be added to specify the application name in the AppDynamics dashboard. This can be overridden by an `application-name` entry in the credentials payload. If neither are supplied the default is the `application_name` as specified by Cloud Foundry.
39+
| `default_node_name` | The default node name for this application in the AppDynamics dashboard. The default value is an expression that will be evaluated based on the `instance_index` of the application. This can be overridden by a `node-name` entry in the credentials payload.
40+
| `default_tier_name` | This is omitted by default but can be added to specify the tier name for this application in the AppDynamics dashboard. This can be overridden by a `tier-name` entry in the credentials payload. If neither are supplied the default is the `application_name` as specified by Cloud Foundry.
4141
| `repository_root` | The URL of the AppDynamics repository index ([details][repositories]).
4242
| `version` | The version of AppDynamics to use. Candidate versions can be found in [this listing][].
4343

4444
### Additional Resources
45-
The framework can also be configured by overlaying a set of resources on the default distribution. To do this, add files to the `resources/app_dynamics_agent` directory in the buildpack fork. For example, to override the default `app-agent-config.xml` add your custom file to `resources/app_dynamics_agent/conf/app-agent-config.xml`.
45+
The framework can also be configured by overlaying a set of resources on the default distribution. To do this, add files to the `resources/app_dynamics_agent` directory in the buildpack fork. For example, to override the default `app-agent-config.xml` add your custom file to `resources/app_dynamics_agent/conf/app-agent-config.xml`.
4646

4747
[`config/app_dynamics_agent.yml`]: ../config/app_dynamics_agent.yml
4848
[AppDynamics Service]: http://www.appdynamics.com

lib/java_buildpack/framework/app_dynamics_agent.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def ssl_enabled(java_opts, credentials)
9797
end
9898

9999
def tier_name(java_opts, credentials)
100-
name = credentials['tier-name'] || @configuration['default_tier_name']
100+
name = credentials['tier-name'] || @configuration['default_tier_name'] ||
101+
@application.details['application_name']
101102
java_opts.add_system_property('appdynamics.agent.tierName', "#{name}")
102103
end
103104

spec/java_buildpack/framework/app_dynamics_agent_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
include_context 'component_helper'
2323

2424
let(:configuration) do
25-
{ 'default_tier_name' => 'test-tier-name',
26-
'default_node_name' => "$(expr \"$VCAP_APPLICATION\" : '.*instance_index[\": ]*\\([[:digit:]]*\\).*')" }
25+
{ 'default_tier_name' => nil,
26+
'default_node_name' => "$(expr \"$VCAP_APPLICATION\" : '.*instance_index[\": ]*\\([[:digit:]]*\\).*')",
27+
'default_application_name' => nil }
2728
end
2829

2930
it 'does not detect without app-dynamics-n/a service' do
@@ -65,7 +66,7 @@
6566
expect(java_opts).to include('-javaagent:$PWD/.java-buildpack/app_dynamics_agent/javaagent.jar')
6667
expect(java_opts).to include('-Dappdynamics.controller.hostName=test-host-name')
6768
expect(java_opts).to include('-Dappdynamics.agent.applicationName=test-application-name')
68-
expect(java_opts).to include('-Dappdynamics.agent.tierName=test-tier-name')
69+
expect(java_opts).to include('-Dappdynamics.agent.tierName=test-application-name')
6970
expect(java_opts).to include('-Dappdynamics.agent.nodeName=$(expr "$VCAP_APPLICATION" : ' \
7071
'\'.*instance_index[": ]*\\([[:digit:]]*\\).*\')')
7172
end

0 commit comments

Comments
 (0)