Skip to content

Commit 4056fa3

Browse files
test
1 parent 80cdaea commit 4056fa3

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

.github/workflows/chef-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- main
8+
- dotnet-zc-chef
89
paths:
910
- '.github/workflows/chef-test.yml'
1011
- 'deployments/chef/**'

deployments/chef/attributes/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@
100100
default['splunk_otel_collector']['auto_instrumentation_enable_profiler_memory'] = false
101101
default['splunk_otel_collector']['auto_instrumentation_enable_metrics'] = false
102102
default['splunk_otel_collector']['auto_instrumentation_otlp_endpoint'] = 'http://127.0.0.1:4317'
103-
default['splunk_otel_collector']['with_auto_instrumentation_sdks'] = %w(java nodejs)
103+
default['splunk_otel_collector']['with_auto_instrumentation_sdks'] = %w(java nodejs dotnet)
104104
default['splunk_otel_collector']['auto_instrumentation_npm_path'] = 'npm'
105105
end

deployments/chef/recipes/auto_instrumentation.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
with_systemd = node['splunk_otel_collector']['auto_instrumentation_systemd'].to_s.downcase == 'true'
66
with_java = node['splunk_otel_collector']['with_auto_instrumentation_sdks'].include?('java')
77
with_nodejs = node['splunk_otel_collector']['with_auto_instrumentation_sdks'].include?('nodejs') && with_new_instrumentation
8+
dotnet_supported = node['cpu']['architecture'] == 'x86_64' && (node['splunk_otel_collector']['auto_instrumentation_version'] == 'latest' || Gem::Version.new(node['splunk_otel_collector']['auto_instrumentation_version']) >= Gem::Version.new('0.99.0'))
9+
with_dotnet = node['splunk_otel_collector']['with_auto_instrumentation_sdks'].include?('dotnet') && dotnet_supported
810
npm_path = node['splunk_otel_collector']['auto_instrumentation_npm_path']
911
lib_dir = '/usr/lib/splunk-instrumentation'
1012
splunk_otel_js_path = "#{lib_dir}/splunk-otel-js.tgz"
@@ -13,6 +15,7 @@
1315
zc_config_dir = '/etc/splunk/zeroconfig'
1416
java_config_file = "#{zc_config_dir}/java.conf"
1517
nodejs_config_file = "#{zc_config_dir}/node.conf"
18+
dotnet_config_file = "#{zc_config_dir}/dotnet.conf"
1619
old_config_file = "#{lib_dir}/instrumentation.conf"
1720
systemd_config_dir = '/usr/lib/systemd/system.conf.d'
1821
systemd_config_file = "#{systemd_config_dir}/00-splunk-otel-auto-instrumentation.conf"
@@ -66,7 +69,7 @@
6669
end
6770

6871
if with_systemd
69-
[java_config_file, nodejs_config_file, old_config_file].each do |config_file|
72+
[java_config_file, nodejs_config_file, dotnet_config_file, old_config_file].each do |config_file|
7073
file config_file do
7174
action :delete
7275
end
@@ -79,10 +82,11 @@
7982
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] },
8083
with_java: lazy { with_java },
8184
with_nodejs: lazy { node.run_state[:with_nodejs] }
85+
with_dotnet: lazy { with_dotnet },
8286
)
8387
source '00-splunk-otel-auto-instrumentation.conf.erb'
8488
notifies :run, 'execute[reload systemd]', :delayed
85-
only_if { with_java || node.run_state[:with_nodejs] }
89+
only_if { with_java || node.run_state[:with_nodejs] || with_dotnet }
8690
end
8791
elsif with_new_instrumentation
8892
[old_config_file, systemd_config_file].each do |config_file|
@@ -115,8 +119,15 @@
115119
source 'node.conf.erb'
116120
only_if { node.run_state[:with_nodejs] }
117121
end
122+
template dotnet_config_file do
123+
variables(
124+
installed_version: lazy { node['packages']['splunk-otel-auto-instrumentation']['version'] }
125+
)
126+
source 'dotnet.conf.erb'
127+
only_if { node.run_state[:with_dotnet] }
128+
end
118129
else
119-
[java_config_file, nodejs_config_file, systemd_config_file].each do |config_file|
130+
[java_config_file, nodejs_config_file, dotnet_config_file, systemd_config_file].each do |config_file|
120131
file config_file do
121132
action :delete
122133
end
@@ -135,6 +146,7 @@
135146
with_systemd: lazy { with_systemd },
136147
with_java: lazy { with_java },
137148
with_nodejs: lazy { node.run_state[:with_nodejs] }
149+
with_dotnet: lazy { with_dotnet },
138150
)
139151
source 'ld.so.preload.erb'
140152
end

deployments/chef/templates/00-splunk-otel-auto-instrumentation.conf.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:<%= node['splunk_otel_collector
55
<% if @with_nodejs -%>
66
DefaultEnvironment="NODE_OPTIONS=-r /usr/lib/splunk-instrumentation/splunk-otel-js/node_modules/@splunk/otel/instrument"
77
<% end -%>
8+
<% if @with_dotnet -%>
9+
DefaultEnvironment="CORECLR_ENABLE_PROFILING=1"
10+
DefaultEnvironment="CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}"
11+
DefaultEnvironment="CORECLR_PROFILER_PATH=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so"
12+
DefaultEnvironment="DOTNET_ADDITIONAL_DEPS=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/AdditionalDeps"
13+
DefaultEnvironment="DOTNET_SHARED_STORE=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/store"
14+
DefaultEnvironment="DOTNET_STARTUP_HOOKS=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
15+
DefaultEnvironment="OTEL_DOTNET_AUTO_HOME=/usr/lib/splunk-instrumentation/splunk-otel-dotnet"
16+
DefaultEnvironment="OTEL_DOTNET_AUTO_PLUGINS=Splunk.OpenTelemetry.AutoInstrumentation.Plugin,Splunk.OpenTelemetry.AutoInstrumentation"
17+
<% end -%>
818
<% if defined?(node['splunk_otel_collector']['auto_instrumentation_resource_attributes']) && node['splunk_otel_collector']['auto_instrumentation_resource_attributes'] != "" -%>
919
DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @installed_version %>-systemd,<%= node['splunk_otel_collector']['auto_instrumentation_resource_attributes'] %>"
1020
<% else -%>

0 commit comments

Comments
 (0)