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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
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