Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-tech support to Dynatrace OneAgent integration #1094

Merged
merged 7 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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