Skip to content

Commit 93226a3

Browse files
committed
Migrate dynatrace integration to LD_PRELOAD
Migrate the dnytrace integration to use the LD_PRELOAD method as used within other buildpacks. * Set LD_PRELOAD environment variable instead of java options * adapt tests and test fixtures
1 parent 0858662 commit 93226a3

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

lib/java_buildpack/framework/dynatrace_one_agent.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def release
6868

6969
manifest = agent_manifest
7070

71-
@droplet.java_opts.add_agentpath(agent_path(manifest))
72-
@droplet.java_opts.add_preformatted_options('-Xshare:off')
71+
environment_variables = @droplet.environment_variables
72+
environment_variables.add_environment_variable(LD_PRELOAD, agent_path(manifest))
7373

7474
dynatrace_environment_variables(manifest)
7575
end
@@ -99,6 +99,8 @@ def supports?
9999

100100
DT_NETWORK_ZONE = 'DT_NETWORK_ZONE'
101101

102+
LD_PRELOAD = 'LD_PRELOAD'
103+
102104
ENVIRONMENTID = 'environmentid'
103105

104106
FILTER = /dynatrace/.freeze
@@ -126,8 +128,8 @@ def agent_manifest
126128

127129
def agent_path(manifest)
128130
technologies = manifest['technologies']
129-
java_binaries = technologies['java']['linux-x86-64']
130-
loader = java_binaries.find { |bin| bin['binarytype'] == 'loader' }
131+
java_binaries = technologies['process']['linux-x86-64']
132+
loader = java_binaries.find { |bin| bin['binarytype'] == 'primary' }
131133
@droplet.sandbox + loader['path']
132134
end
133135

spec/fixtures/framework_dynatrace_one_agent/.java-buildpack/dynatrace_one_agent/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"technologies" : {
3-
"java" : {
3+
"process" : {
44
"linux-x86-64" : [
55
{
6-
"path": "agent/lib64/liboneagentloader.so",
7-
"binarytype" : "loader"
6+
"path": "agent/lib64/liboneagentproc.so",
7+
"binarytype" : "primary"
88
}
99
]
1010
}
132 Bytes
Binary file not shown.

spec/java_buildpack/framework/dynatrace_one_agent_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,17 @@
5050

5151
component.compile
5252

53-
expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist
53+
expect(sandbox + 'agent/lib64/liboneagentproc.so').to exist
5454
expect(sandbox + 'manifest.json').to exist
5555
end
5656

57-
it 'updates JAVA_OPTS with agent loader and share set to off',
57+
it 'sets LD_PRELOAD with liboneagentproc',
5858
app_fixture: 'framework_dynatrace_one_agent' do
5959

6060
component.release
6161

62-
expect(java_opts).to include('-agentpath:$PWD/.java-buildpack/dynatrace_one_agent/agent/lib64/' \
63-
'liboneagentloader.so')
64-
expect(java_opts).to include('-Xshare:off')
62+
expect(environment_variables).to include('LD_PRELOAD=$PWD/.java-buildpack/dynatrace_one_agent/agent/lib64/' \
63+
'liboneagentproc.so')
6564
end
6665

6766
it 'updates environment variables',
@@ -112,7 +111,7 @@
112111

113112
component.compile
114113

115-
expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist
114+
expect(sandbox + 'agent/lib64/liboneagentproc.so').to exist
116115
expect(sandbox + 'manifest.json').to exist
117116
end
118117
end

0 commit comments

Comments
 (0)