Skip to content

Commit 39b156c

Browse files
committed
Add env var APPINSIGHTS_INSTRUMENTATIONKEY for compatibility
1 parent f6e9b5f commit 39b156c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/java_buildpack/framework/azure_application_insights_agent.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def release
4242
if credentials.key?(INSTRUMENTATION_KEY)
4343
@droplet.java_opts.add_system_property('APPLICATION_INSIGHTS_IKEY',
4444
credentials[INSTRUMENTATION_KEY])
45+
# add environment variable for compatibility with agent version 3.x
46+
# this triggers a warning message to switch to connection string
47+
@droplet.environment_variables.add_environment_variable('APPINSIGHTS_INSTRUMENTATIONKEY',
48+
credentials[INSTRUMENTATION_KEY])
4549
end
4650
@droplet.java_opts.add_javaagent(@droplet.sandbox + jar_name)
4751
end

spec/java_buildpack/framework/azure_application_insights_agent_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272
expect(java_opts).to include('-DAPPLICATION_INSIGHTS_IKEY=test-instrumentation-key')
7373
end
7474

75+
it 'updates environment variables' do
76+
allow(services).to receive(:find_service)
77+
.and_return('credentials' => { 'instrumentation_key' => 'test-instrumentation-key' })
78+
79+
component.release
80+
81+
expect(environment_variables).to include('APPINSIGHTS_INSTRUMENTATIONKEY=test-instrumentation-key')
82+
end
83+
7584
end
7685

7786
end

0 commit comments

Comments
 (0)