Skip to content

Commit

Permalink
Merge pull request #1094 from arthfl/main
Browse files Browse the repository at this point in the history
Add multi-tech support to Dynatrace OneAgent integration
  • Loading branch information
pivotal-david-osullivan authored Jan 27, 2025
2 parents b8abc29 + 49ca7ea commit e5c8eb3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/framework-dynatrace_one_agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The credential payload of the service may contain the following entries:
| `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.
| `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!
| `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!
| 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|

## Configuration
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].
Expand Down
20 changes: 16 additions & 4 deletions lib/java_buildpack/framework/dynatrace_one_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def supports?

private

ADDTECHNOLOGIES = 'addtechnologies'

APIURL = 'apiurl'

APITOKEN = 'apitoken'
Expand Down Expand Up @@ -113,12 +115,12 @@ def supports?

SKIP_ERRORS = 'skiperrors'

private_constant :APIURL, :APITOKEN, :ENABLE_FIPS, :DT_APPLICATION_ID, :DT_CONNECTION_POINT, :DT_NETWORK_ZONE,
:DT_LOGSTREAM, :DT_TENANT, :DT_TENANTTOKEN, :LD_PRELOAD, :ENVIRONMENTID, :FILTER, :NETWORKZONE,
:SKIP_ERRORS
private_constant :ADDTECHNOLOGIES, :APIURL, :APITOKEN, :ENABLE_FIPS, :DT_APPLICATION_ID, :DT_CONNECTION_POINT,
:DT_NETWORK_ZONE, :DT_LOGSTREAM, :DT_TENANT, :DT_TENANTTOKEN, :LD_PRELOAD, :ENVIRONMENTID,
:FILTER, :NETWORKZONE, :SKIP_ERRORS

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

Expand All @@ -127,6 +129,16 @@ def agent_download_url
['latest', download_uri]
end

def technologies(credentials)
code_modules = "include=java"
if not credentials[ADDTECHNOLOGIES].empty?
credentials[ADDTECHNOLOGIES].split(",").each do |tech|
code_modules += "&include=#{tech}"
end
end
return code_modules
end

def agent_manifest
JSON.parse(File.read(@droplet.sandbox + 'manifest.json'))
end
Expand Down
13 changes: 7 additions & 6 deletions lib/java_buildpack/util/sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ def handle_params(params)

query_params = ''

params.each do |key, _|
params[key] = '***' if key.match(keywords)
query_params += key + '=' + params[key] + '&'
params.split("&").each do |single_param|
k, v = single_param.split("=")
if k.match(keywords)
v = "***"
end
query_params += k + '=' +v + '&'
end

query_params
end

Expand All @@ -53,8 +55,7 @@ def sanitize_uri
rich_uri.password = nil

if rich_uri.query
params = (URI.decode_www_form rich_uri.query).to_h
query_params = handle_params(params)
query_params = handle_params(rich_uri.query)
rich_uri.query = query_params.chop
end

Expand Down

0 comments on commit e5c8eb3

Please sign in to comment.