Skip to content

Commit e5c8eb3

Browse files
Merge pull request #1094 from arthfl/main
Add multi-tech support to Dynatrace OneAgent integration
2 parents b8abc29 + 49ca7ea commit e5c8eb3

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

docs/framework-dynatrace_one_agent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The credential payload of the service may contain the following entries:
3131
| `networkzone` | (Optional) Network zones are Dynatrace entities that represent your network structure. They help you to route the traffic efficiently, avoiding unnecessary traffic across data centers and network regions. Enter the network zone you wish to pass to the server during the OneAgent Download.
3232
| `skiperrors` | (Optional) The errors during agent download are skipped and the injection is disabled. Use this option at your own risk. Possible values are 'true' and 'false'. This option is disabled by default!
3333
| `enablefips`| (Optional) Enables the use of [FIPS 140 cryptographic algorithms](https://docs.dynatrace.com/docs/shortlink/oneagentctl#fips-140). Possible values are 'true' and 'false'. This option is disabled by default!
34+
| addtechnologies | (Optional) Adds additional OneAgent code-modules via a comma-separated list. See [supported values](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/deployment/oneagent/download-oneagent-version#parameters) in the "included" row|
3435

3536
## Configuration
3637
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].

lib/java_buildpack/framework/dynatrace_one_agent.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def supports?
8585

8686
private
8787

88+
ADDTECHNOLOGIES = 'addtechnologies'
89+
8890
APIURL = 'apiurl'
8991

9092
APITOKEN = 'apitoken'
@@ -113,12 +115,12 @@ def supports?
113115

114116
SKIP_ERRORS = 'skiperrors'
115117

116-
private_constant :APIURL, :APITOKEN, :ENABLE_FIPS, :DT_APPLICATION_ID, :DT_CONNECTION_POINT, :DT_NETWORK_ZONE,
117-
:DT_LOGSTREAM, :DT_TENANT, :DT_TENANTTOKEN, :LD_PRELOAD, :ENVIRONMENTID, :FILTER, :NETWORKZONE,
118-
:SKIP_ERRORS
118+
private_constant :ADDTECHNOLOGIES, :APIURL, :APITOKEN, :ENABLE_FIPS, :DT_APPLICATION_ID, :DT_CONNECTION_POINT,
119+
:DT_NETWORK_ZONE, :DT_LOGSTREAM, :DT_TENANT, :DT_TENANTTOKEN, :LD_PRELOAD, :ENVIRONMENTID,
120+
:FILTER, :NETWORKZONE, :SKIP_ERRORS
119121

120122
def agent_download_url
121-
download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \
123+
download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?#{technologies(credentials)}" \
122124
'&bitness=64' \
123125
"&Api-Token=#{credentials[APITOKEN]}"
124126

@@ -127,6 +129,16 @@ def agent_download_url
127129
['latest', download_uri]
128130
end
129131

132+
def technologies(credentials)
133+
code_modules = "include=java"
134+
if not credentials[ADDTECHNOLOGIES].empty?
135+
credentials[ADDTECHNOLOGIES].split(",").each do |tech|
136+
code_modules += "&include=#{tech}"
137+
end
138+
end
139+
return code_modules
140+
end
141+
130142
def agent_manifest
131143
JSON.parse(File.read(@droplet.sandbox + 'manifest.json'))
132144
end

lib/java_buildpack/util/sanitizer.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ def handle_params(params)
3636

3737
query_params = ''
3838

39-
params.each do |key, _|
40-
params[key] = '***' if key.match(keywords)
41-
query_params += key + '=' + params[key] + '&'
39+
params.split("&").each do |single_param|
40+
k, v = single_param.split("=")
41+
if k.match(keywords)
42+
v = "***"
43+
end
44+
query_params += k + '=' +v + '&'
4245
end
43-
4446
query_params
4547
end
4648

@@ -53,8 +55,7 @@ def sanitize_uri
5355
rich_uri.password = nil
5456

5557
if rich_uri.query
56-
params = (URI.decode_www_form rich_uri.query).to_h
57-
query_params = handle_params(params)
58+
query_params = handle_params(rich_uri.query)
5859
rich_uri.query = query_params.chop
5960
end
6061

0 commit comments

Comments
 (0)