Skip to content

Commit

Permalink
[#104558394]Configuration for the DynaTrace agent name
Browse files Browse the repository at this point in the history
The commit allows users to set a default agent name in the
configuration for DynaTrace.

Closes #234
[#104558394]
  • Loading branch information
Christopher Frost committed Oct 1, 2015
1 parent 7e33cda commit 6e53039
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/dyna_trace_agent.yml
Expand Up @@ -17,3 +17,4 @@
---
version: 6.1.0_+
repository_root: ""
default_agent_name:
1 change: 1 addition & 0 deletions docs/framework-dyna_trace_agent.md
Expand Up @@ -66,6 +66,7 @@ The framework can be configured by modifying the [`config/dyna_trace_agent.yml`]
| ---- | -----------
| `repository_root` | The URL of the DynaTrace repository index ([details][repositories]).
| `version` | The version of DynaTrace to use. This buildpack framework has been tested on 6.1.0.
| `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.

### Additional Resources
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.
Expand Down
2 changes: 1 addition & 1 deletion lib/java_buildpack/framework/dyna_trace_agent.rb
Expand Up @@ -59,7 +59,7 @@ def agent_path
end

def agent_name
"#{@application.details['application_name']}_#{profile_name}"
@configuration['default_agent_name'] || "#{@application.details['application_name']}_#{profile_name}"
end

def architecture
Expand Down
24 changes: 19 additions & 5 deletions spec/java_buildpack/framework/dyna_trace_agent_spec.rb
Expand Up @@ -21,6 +21,10 @@
describe JavaBuildpack::Framework::DynaTraceAgent do
include_context 'component_helper'

let(:configuration) do
{ 'default_agent_name' => nil }
end

it 'does not detect without dynatrace-n/a service' do
expect(component.detect).to be_nil
end
Expand All @@ -45,23 +49,33 @@

it 'updates JAVA_OPTS' do
component.release
expect(java_opts).to include(
'-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
'libdtagent.so=name=test-application-name_Monitoring,server=test-host-name')
end

context do

let(:configuration) { { 'default_agent_name' => 'different-agent-name' } }

it 'updates JAVA_OPTS with configured agent name' do
component.release
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dyna_trace_agent/agent/lib64/'\
'libdtagent.so=name=different-agent-name,server=test-host-name')
end

end
end

context do
before do
allow(services).to receive(:one_service?).with(/dynatrace/, 'server').and_return(true)
allow(services).to receive(:find_service).and_return('credentials' => { 'server' => 'test-host-name',
allow(services).to receive(:find_service).and_return('credentials' => { 'server' => 'test-host-name',
'profile' => 'test-profile' })
end

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

Expand Down

0 comments on commit 6e53039

Please sign in to comment.