From 75ab7e35f03e3a510accf0063bc924637c32e3c4 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 12 Jul 2021 13:34:46 +0200 Subject: [PATCH 1/5] added networkzone paramter to agent download from API --- lib/java_buildpack/framework/dynatrace_one_agent.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/java_buildpack/framework/dynatrace_one_agent.rb b/lib/java_buildpack/framework/dynatrace_one_agent.rb index adb83b3bea..de83d79266 100644 --- a/lib/java_buildpack/framework/dynatrace_one_agent.rb +++ b/lib/java_buildpack/framework/dynatrace_one_agent.rb @@ -111,8 +111,16 @@ def supports? :DT_TENANT, :DT_TENANTTOKEN, :ENVIRONMENTID, :FILTER, :NETWORKZONE, :SKIP_ERRORS def agent_download_url + # setting the networkzone paramater to a sane default in case it's not set + if networkzone? + networkzone_value = credentials[NETWORKZONE] + else + networkzone_value = 'default' + download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \ - "&bitness=64&Api-Token=#{credentials[APITOKEN]}" + "&bitness=64" \ + "&networkzone=#{networkzone_value}" \ + "&Api-Token=#{credentials[APITOKEN]}" ['latest', download_uri] end From faaa9570dd13ef5590968257d07addb2c8e6092b Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 12 Jul 2021 13:35:45 +0200 Subject: [PATCH 2/5] removed Dynatrace appmon module since it isdeprecated for a while now --- .../framework/dynatrace_appmon_agent.rb | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 lib/java_buildpack/framework/dynatrace_appmon_agent.rb diff --git a/lib/java_buildpack/framework/dynatrace_appmon_agent.rb b/lib/java_buildpack/framework/dynatrace_appmon_agent.rb deleted file mode 100644 index d19a71ddb6..0000000000 --- a/lib/java_buildpack/framework/dynatrace_appmon_agent.rb +++ /dev/null @@ -1,108 +0,0 @@ -# frozen_string_literal: true - -# Cloud Foundry Java Buildpack -# Copyright 2013-2020 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require 'fileutils' -require 'java_buildpack/component/versioned_dependency_component' -require 'java_buildpack/framework' -require 'java_buildpack/util/qualify_path' - -module JavaBuildpack - module Framework - - # Encapsulates the functionality for enabling zero-touch Dynatrace support. - class DynatraceAppmonAgent < JavaBuildpack::Component::VersionedDependencyComponent - include JavaBuildpack::Util - - # (see JavaBuildpack::Component::BaseComponent#compile) - def compile - download(@version, @uri) { |file| expand file } - @droplet.copy_resources - end - - # (see JavaBuildpack::Component::BaseComponent#release) - def release - @droplet.java_opts.add_agentpath_with_props(agent_path, name: agent_name, server: server) - @droplet.java_opts.add_preformatted_options('-Xshare:off') - end - - protected - - # (see JavaBuildpack::Component::VersionedDependencyComponent#supports?) - def supports? - (@application.services.one_service? FILTER, 'server') && - !(@application.services.one_service? FILTER, 'tenant') && - !(@application.services.one_service? FILTER, 'tenanttoken') - end - - private - - FILTER = /dynatrace/.freeze - - private_constant :FILTER - - def agent_dir - @droplet.sandbox + 'agent' - end - - def agent_path - agent_dir + lib_name + 'libdtagent.so' - end - - def agent_name - @configuration['default_agent_name'] || "#{@application.details['application_name']}_#{profile_name}" - end - - def architecture - `uname -m`.strip - end - - def expand(file) - with_timing "Expanding Dynatrace Appmon to #{@droplet.sandbox.relative_path_from(@droplet.root)}" do - Dir.mktmpdir do |root| - root_path = Pathname.new(root) - shell "unzip -qq #{file.path} -d #{root_path} 2>&1" - unpack_agent root_path - end - end - end - - def lib_name - architecture == 'x86_64' || architecture == 'i686' ? 'lib64' : 'lib' - end - - def agent_unpack_path - architecture == 'x86_64' || architecture == 'i686' ? 'linux-x86-64/agent' : 'linux-x86-32/agent' - end - - def unpack_agent(root) - FileUtils.mkdir_p(agent_dir) - FileUtils.mv(root + 'agent' + agent_unpack_path + 'conf', agent_dir) - FileUtils.mv(root + 'agent' + agent_unpack_path + lib_name, agent_dir) - end - - def profile_name - @application.services.find_service(FILTER)['credentials']['profile'] || 'Monitoring' - end - - def server - @application.services.find_service(FILTER)['credentials']['server'] - end - - end - - end -end From fb9855c2be09db2742c36e10c626cc9ab7fcaa5b Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Mon, 12 Jul 2021 13:37:47 +0200 Subject: [PATCH 3/5] removed Dynatrace appmon parts since it isdeprecated for a while now --- config/dynatrace_appmon_agent.yml | 20 ---- docs/framework-dynatrace_appmon_agent.md | 94 ------------------- .../framework/dynatrace_appmon_agent_spec.rb | 89 ------------------ 3 files changed, 203 deletions(-) delete mode 100644 config/dynatrace_appmon_agent.yml delete mode 100644 docs/framework-dynatrace_appmon_agent.md delete mode 100644 spec/java_buildpack/framework/dynatrace_appmon_agent_spec.rb diff --git a/config/dynatrace_appmon_agent.yml b/config/dynatrace_appmon_agent.yml deleted file mode 100644 index 79126c66a3..0000000000 --- a/config/dynatrace_appmon_agent.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Cloud Foundry Java Buildpack -# Copyright 2013-2020 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Configuration for the Dynatrace framework ---- -version: 7.1.0_+ -repository_root: https://files.dynatrace.com/downloads/appmon/cloudfoundry/buildpack/java -default_agent_name: diff --git a/docs/framework-dynatrace_appmon_agent.md b/docs/framework-dynatrace_appmon_agent.md deleted file mode 100644 index a720a4a9df..0000000000 --- a/docs/framework-dynatrace_appmon_agent.md +++ /dev/null @@ -1,94 +0,0 @@ -# Dynatrace Appmon Agent Framework -The Dynatrace Appmon Agent Framework causes an application to be automatically configured to work with a bound [Dynatrace Service][] instance (Free trials available). - -The application's Cloud Foundry name is used as the `agent group` in Dynatrace Appmon, and must be pre-configured on the Dynatrace server. - -**NOTE** - -* The Dynatrace Appmon agent may slow down the start up time of large applications at first, but gets faster over time. Setting the application manifest to contain `maximum_health_check_timeout` of 180 or more and/or using `cf push -t 180` or more when pushing the application may help. -* Unsuccessful `cf push`s will cause dead entries to build up in the Dynatrace Appmon dashboard, as CF launches/disposes application containers. These can be hidden but will collect in the Dynatrace database. - - - - - - - - - -
Detection CriterionExistence of a single bound Dynatrace Appmon service. -
    -
  • Existence of a Dynatrace Appmon service is defined as the VCAP_SERVICES payload containing a service who's name, label or tag has dynatrace as a substring and contains server field in the credentials. Note: The credentials must NOT contain tenant and tenanttoken in order to make sure the detection mechanism does not interfere with Dynatrace SaaS/Managed integration.
  • -
-
Tagsdynatrace-appmon-agent=<version>
-Tags are printed to standard output by the buildpack detect script - -## User-Provided Service -Users must provide their own Dynatrace Appmon service. A user-provided Dynatrace Appmon service must have a name or tag with `dynatrace` in it so that the Dynatrace Appmon Agent Framework will automatically configure the application to work with the service. - -The credential payload of the service may contain the following entries: - -| Name | Description -| ---- | ----------- -| `server` | The Dynatrace collector hostname to connect to. Use `host:port` format for a specific port number. -| `profile` | (Optional) The Dynatrace server profile this is associated with. Uses `Monitoring` by default. - -### Example Dynatrace User-Provided Service Payload -``` -{ - "server":"my-dynatrace-server:my-port", - "profile":"my-dynatrace-profile" -} -``` - -### Creating Dynatrace User-Provided Service Payload -In order to create the Dynatrace configuration payload, you should collapse the JSON payload to a single line and set it like the following... The user-provided Dynatrace Appmon service must have a name of or tag with `dynatrace` in it. For example: my-dynatrace-service. - -``` -cf cups my-dynatrace-service -p '{"server":"my-dynatrace-server:my-port","profile":"my-dynatrace-profile"}' -cf bind-service my-app-name my-dynatrace-service -``` - -**NOTE** - -Be sure to open an Application Security Group to your Dynatrace collector prior to starting the application: -``` -$ cat security.json - [ - { - "protocol": "tcp", - "destination": "dynatrace_host", - "ports": "9998" - } - ] - -$ cf create-security-group dynatrace_group ./security.json -Creating security group dynatrace_group as admin -OK - -$ cf bind-running-security-group dynatrace_group -Binding security group dynatrace_group to defaults for running as admin -OK - -TIP: Changes will not apply to existing running applications until they are restarted. -``` - -## Configuration -For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][]. - -The framework can be configured by modifying the [`config/dynatrace_appmon_agent.yml`][] file in the buildpack fork. The framework uses the [`Repository` utility support][repositories] and so it supports the [version syntax][] defined there. - -| Name | Description -| ---- | ----------- -| `repository_root` | The URL of the Dynatrace Appmon repository index ([details][repositories]). -| `version` | The version of Dynatrace Appmon 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 Appmon 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/dynatrace_appmon_agent` directory in the buildpack fork. - -[Configuration and Extension]: ../README.md#configuration-and-extension -[`config/dynatrace_appmon_agent.yml`]: ../config/dynatrace_appmon_agent.yml -[Dynatrace Service]: https://www.dynatrace.com/ -[repositories]: extending-repositories.md -[version syntax]: extending-repositories.md#version-syntax-and-ordering diff --git a/spec/java_buildpack/framework/dynatrace_appmon_agent_spec.rb b/spec/java_buildpack/framework/dynatrace_appmon_agent_spec.rb deleted file mode 100644 index 08f0a0d9e0..0000000000 --- a/spec/java_buildpack/framework/dynatrace_appmon_agent_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -# frozen_string_literal: true - -# Cloud Foundry Java Buildpack -# Copyright 2013-2020 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -require 'spec_helper' -require 'component_helper' -require 'java_buildpack/framework/dynatrace_appmon_agent' - -describe JavaBuildpack::Framework::DynatraceAppmonAgent do - include_context 'with component help' - - 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 - - context do - - before do - allow(services).to receive(:one_service?).with(/dynatrace/, 'server').and_return(true) - allow(services).to receive(:one_service?).with(/dynatrace/, 'tenant').and_return(false) - allow(services).to receive(:one_service?).with(/dynatrace/, 'tenanttoken').and_return(false) - allow(services).to receive(:find_service).and_return('credentials' => { 'server' => 'test-host-name' }) - end - - it 'detects with dynatrace-n/a service' do - expect(component.detect).to eq("dynatrace-appmon-agent=#{version}") - end - - it 'expands DynaTrace agent zip', - cache_fixture: 'stub-dynatrace-appmon-agent.jar' do - - component.compile - expect(sandbox + 'agent/lib64/libdtagent.so').to exist - end - - it 'updates JAVA_OPTS and share set to off' do - component.release - expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dynatrace_appmon_agent/agent/lib64/'\ - 'libdtagent.so=name=test-application-name_Monitoring,server=test-host-name') - expect(java_opts).to include('-Xshare:off') - 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/dynatrace_appmon_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(:one_service?).with(/dynatrace/, 'tenant').and_return(false) - allow(services).to receive(:one_service?).with(/dynatrace/, 'tenanttoken').and_return(false) - 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/dynatrace_appmon_agent/agent/lib64/'\ - 'libdtagent.so=name=test-application-name_test-profile,server=test-host-name') - end - - end -end From 1c24208a4d171f97d7ecd5483ff2aa8bdc3a9815 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Wed, 14 Jul 2021 13:19:59 +0200 Subject: [PATCH 4/5] removed default fallback for networkzone parameter again --- lib/java_buildpack/framework/dynatrace_one_agent.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/java_buildpack/framework/dynatrace_one_agent.rb b/lib/java_buildpack/framework/dynatrace_one_agent.rb index de83d79266..e171e9bda5 100644 --- a/lib/java_buildpack/framework/dynatrace_one_agent.rb +++ b/lib/java_buildpack/framework/dynatrace_one_agent.rb @@ -111,16 +111,14 @@ def supports? :DT_TENANT, :DT_TENANTTOKEN, :ENVIRONMENTID, :FILTER, :NETWORKZONE, :SKIP_ERRORS def agent_download_url - # setting the networkzone paramater to a sane default in case it's not set - if networkzone? - networkzone_value = credentials[NETWORKZONE] - else - networkzone_value = 'default' - download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \ "&bitness=64" \ - "&networkzone=#{networkzone_value}" \ "&Api-Token=#{credentials[APITOKEN]}" + # + # setting networkzone parameter if it's configured + if networkzone? + download_uri += "&networkzone=#{networkzone_value}" + ['latest', download_uri] end From a23c2447435e0fdb57399b7955cce379e35499a7 Mon Sep 17 00:00:00 2001 From: Florian Arthofer Date: Wed, 14 Jul 2021 13:20:27 +0200 Subject: [PATCH 5/5] removed Dynatrace appmon parts since it isdeprecated for a while now --- README.md | 1 - rakelib/versions_task.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index c0ed3b1fb2..1c66c9838b 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ The buildpack supports extension through the use of Git repository forking. The * [Container Security Provider](docs/framework-container_security_provider.md) ([Configuration](docs/framework-container_security_provider.md#configuration)) * [Contrast Security Agent](docs/framework-contrast_security_agent.md) ([Configuration](docs/framework-contrast_security_agent.md#configuration)) * [Debug](docs/framework-debug.md) ([Configuration](docs/framework-debug.md#configuration)) - * [Dynatrace Appmon Agent](docs/framework-dynatrace_appmon_agent.md) ([Configuration](docs/framework-dynatrace_appmon_agent.md#configuration)) * [Elastic APM Agent](docs/framework-elastic_apm_agent.md) ([Configuration](docs/framework-elastic_apm_agent.md#configuration)) * [Dynatrace SaaS/Managed OneAgent](docs/framework-dynatrace_one_agent.md) ([Configuration](docs/framework-dynatrace_one_agent.md#configuration)) * [Google Stackdriver Debugger](docs/framework-google_stackdriver_debugger.md) ([Configuration](docs/framework-google_stackdriver_debugger.md#configuration)) diff --git a/rakelib/versions_task.rb b/rakelib/versions_task.rb index ebc7313d98..0ca08ce06f 100644 --- a/rakelib/versions_task.rb +++ b/rakelib/versions_task.rb @@ -61,7 +61,6 @@ def initialize 'container_security_provider' => 'Container Security Provider', 'contrast_security_agent' => 'Contrast Security Agent', 'datadog_javaagent' => 'Datadog APM Javaagent', - 'dynatrace_appmon_agent' => 'Dynatrace Appmon Agent', 'dynatrace_one_agent' => 'Dynatrace OneAgent', 'elastic_apm_agent' => 'Elastic APM Agent', 'geode_store' => 'Geode Tomcat Session Store',