Skip to content

Commit 950b2b3

Browse files
puppet: support .NET zero config on linux (#4791)
1 parent 63ffc6b commit 950b2b3

File tree

7 files changed

+162
-58
lines changed

7 files changed

+162
-58
lines changed

deployments/puppet/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Unreleased
44

5+
## puppet-v0.16.0
6+
7+
- Initial support for [Splunk OpenTelemetry for .NET](https://github.com/signalfx/splunk-otel-dotnet) Auto
8+
Instrumentation on Linux (x86_64/amd64 only):
9+
- The .NET SDK is activated by default if the `with_auto_instrumentation` option is set to `true` and
10+
`auto_instrumentation_version` is `latest` or >= `0.99.0`.
11+
- To skip .NET auto instrumentation, configure the `with_auto_instrumentation_sdks` option without `dotnet`.
12+
513
## puppet-v0.15.0
614

715
- Fix installation of `splunk-otel-js` for Node.js auto instrumentation.

deployments/puppet/README.md

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

deployments/puppet/manifests/init.pp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
$auto_instrumentation_enable_profiler_memory = false, # linux only
4848
$auto_instrumentation_enable_metrics = false, # linux only
4949
$auto_instrumentation_otlp_endpoint = 'http://127.0.0.1:4317', # linux only
50-
$with_auto_instrumentation_sdks = ['java', 'nodejs'], # linux only
50+
$with_auto_instrumentation_sdks = ['java', 'nodejs', 'dotnet'], # linux only
5151
$auto_instrumentation_npm_path = 'npm', # linux only
5252
$collector_additional_env_vars = {}
5353
) inherits splunk_otel_collector::params {
@@ -372,8 +372,10 @@
372372
$instrumentation_config_path = '/usr/lib/splunk-instrumentation/instrumentation.conf'
373373
$zeroconfig_java_config_path = '/etc/splunk/zeroconfig/java.conf'
374374
$zeroconfig_node_config_path = '/etc/splunk/zeroconfig/node.conf'
375+
$zeroconfig_dotnet_config_path = '/etc/splunk/zeroconfig/dotnet.conf'
375376
$zeroconfig_systemd_config_path = '/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf'
376377
$with_new_instrumentation = $auto_instrumentation_version == 'latest' or versioncmp($auto_instrumentation_version, '0.87.0') >= 0
378+
$dotnet_supported = $facts['os']['architecture'] in ['amd64', 'x86_64'] and ($auto_instrumentation_version == 'latest' or versioncmp($auto_instrumentation_version, '0.99.0') >= 0) # lint:ignore:140chars
377379

378380
if $::osfamily == 'debian' {
379381
package { $auto_instrumentation_package_name:
@@ -412,7 +414,7 @@
412414
}
413415

414416
if $auto_instrumentation_systemd {
415-
file { [$zeroconfig_java_config_path, $zeroconfig_node_config_path]:
417+
file { [$zeroconfig_java_config_path, $zeroconfig_node_config_path, $zeroconfig_dotnet_config_path, $instrumentation_config_path]:
416418
ensure => absent,
417419
require => Package[$auto_instrumentation_package_name],
418420
}
@@ -436,13 +438,32 @@
436438
content => template('splunk_otel_collector/java.conf.erb'),
437439
require => Package[$auto_instrumentation_package_name],
438440
}
441+
} else {
442+
file { $zeroconfig_java_config_path:
443+
ensure => absent,
444+
}
439445
}
440446
if 'nodejs' in $with_auto_instrumentation_sdks {
441447
file { $zeroconfig_node_config_path:
442448
ensure => file,
443449
content => template('splunk_otel_collector/node.conf.erb'),
444450
require => Exec['Install splunk-otel-js'],
445451
}
452+
} else {
453+
file { $zeroconfig_node_config_path:
454+
ensure => absent,
455+
}
456+
}
457+
if 'dotnet' in $with_auto_instrumentation_sdks and $dotnet_supported {
458+
file { $zeroconfig_dotnet_config_path:
459+
ensure => file,
460+
content => template('splunk_otel_collector/dotnet.conf.erb'),
461+
require => Package[$auto_instrumentation_package_name],
462+
}
463+
} else {
464+
file { $zeroconfig_dotnet_config_path:
465+
ensure => absent,
466+
}
446467
}
447468
} else {
448469
file { $instrumentation_config_path:

deployments/puppet/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "signalfx-splunk_otel_collector",
3-
"version": "0.15.0",
3+
"version": "0.16.0",
44
"author": "Splunk, Inc.",
55
"summary": "This module installs the Splunk OpenTelemetry Collector via distro packages and configures it.",
66
"license": "Apache-2.0",

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
<% if @with_auto_instrumentation_sdks.include?('java') -%>
33
DefaultEnvironment="JAVA_TOOL_OPTIONS=-javaagent:<%= @auto_instrumentation_java_agent_jar %>"
44
<% end -%>
5-
<% if @with_auto_instrumentation_sdks.include?('nodejs') -%>
5+
<% if @with_auto_instrumentation_sdks.include?('nodejs') && @with_new_instrumentation.to_s.downcase == 'true' -%>
66
DefaultEnvironment="NODE_OPTIONS=-r /usr/lib/splunk-instrumentation/splunk-otel-js/node_modules/@splunk/otel/instrument"
77
<% end -%>
8+
<% if @with_auto_instrumentation_sdks.include?('dotnet') && @dotnet_supported.to_s.downcase == 'true' -%>
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?(@auto_instrumentation_resource_attributes) && @auto_instrumentation_resource_attributes != "" -%>
919
DefaultEnvironment="OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>-systemd,<%= @auto_instrumentation_resource_attributes %>"
1020
<% else -%>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORECLR_ENABLE_PROFILING=1
2+
CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
3+
CORECLR_PROFILER_PATH=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so
4+
DOTNET_ADDITIONAL_DEPS=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/AdditionalDeps
5+
DOTNET_SHARED_STORE=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/store
6+
DOTNET_STARTUP_HOOKS=/usr/lib/splunk-instrumentation/splunk-otel-dotnet/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll
7+
OTEL_DOTNET_AUTO_HOME=/usr/lib/splunk-instrumentation/splunk-otel-dotnet
8+
OTEL_DOTNET_AUTO_PLUGINS=Splunk.OpenTelemetry.AutoInstrumentation.Plugin,Splunk.OpenTelemetry.AutoInstrumentation
9+
<% if defined?(@auto_instrumentation_resource_attributes) && @auto_instrumentation_resource_attributes != "" -%>
10+
OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>,<%= @auto_instrumentation_resource_attributes %>
11+
<% else -%>
12+
OTEL_RESOURCE_ATTRIBUTES=splunk.zc.method=splunk-otel-auto-instrumentation-<%= @auto_instrumentation_version %>
13+
<% end -%>
14+
<% if defined?(@auto_instrumentation_service_name) && @auto_instrumentation_service_name != "" -%>
15+
OTEL_SERVICE_NAME=<%= @auto_instrumentation_service_name %>
16+
<% end -%>
17+
SPLUNK_PROFILER_ENABLED=<%= @auto_instrumentation_enable_profiler.to_s.downcase %>
18+
SPLUNK_PROFILER_MEMORY_ENABLED=<%= @auto_instrumentation_enable_profiler_memory.to_s.downcase %>
19+
SPLUNK_METRICS_ENABLED=<%= @auto_instrumentation_enable_metrics.to_s.downcase %>
20+
OTEL_EXPORTER_OTLP_ENDPOINT=<%= @auto_instrumentation_otlp_endpoint %>

internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,22 @@
5656
SYSTEMD_CONFIG_PATH = "/usr/lib/systemd/system.conf.d/00-splunk-otel-auto-instrumentation.conf"
5757
JAVA_CONFIG_PATH = "/etc/splunk/zeroconfig/java.conf"
5858
NODE_CONFIG_PATH = "/etc/splunk/zeroconfig/node.conf"
59+
DOTNET_CONFIG_PATH = "/etc/splunk/zeroconfig/dotnet.conf"
5960
NODE_PREFIX = "/usr/lib/splunk-instrumentation/splunk-otel-js"
6061
NODE_OPTIONS = f"-r {NODE_PREFIX}/node_modules/@splunk/otel/instrument"
62+
DOTNET_HOME = "/usr/lib/splunk-instrumentation/splunk-otel-dotnet"
63+
DOTNET_AGENT_PATH = f"{DOTNET_HOME}/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so"
64+
DOTNET_VARS = {
65+
"CORECLR_ENABLE_PROFILING": "1",
66+
"CORECLR_PROFILER": "{918728DD-259F-4A6A-AC2B-B85E1B658318}",
67+
"CORECLR_PROFILER_PATH": DOTNET_AGENT_PATH,
68+
"DOTNET_ADDITIONAL_DEPS": f"{DOTNET_HOME}/AdditionalDeps",
69+
"DOTNET_SHARED_STORE": f"{DOTNET_HOME}/store",
70+
"DOTNET_STARTUP_HOOKS": f"{DOTNET_HOME}/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll",
71+
"OTEL_DOTNET_AUTO_HOME": DOTNET_HOME,
72+
"OTEL_DOTNET_AUTO_PLUGINS":
73+
"Splunk.OpenTelemetry.AutoInstrumentation.Plugin,Splunk.OpenTelemetry.AutoInstrumentation",
74+
}
6175

6276

6377
def run_puppet_apply(container, config):
@@ -124,6 +138,12 @@ def node_package_installed(container):
124138
return rc == 0
125139

126140

141+
def verify_dotnet_config(container, path, exists=True):
142+
for key, val in DOTNET_VARS.items():
143+
val = val if exists else ".*"
144+
verify_config_file(container, path, key, val, exists=exists)
145+
146+
127147
DEFAULT_CONFIG = f"""
128148
class {{ splunk_otel_collector:
129149
splunk_access_token => '{SPLUNK_ACCESS_TOKEN}',
@@ -256,25 +276,37 @@ def test_puppet_with_default_instrumentation(distro, puppet_release, version, wi
256276
if version == "latest":
257277
assert node_package_installed(container)
258278

259-
if version == "latest" or with_systemd == "true":
260-
config_path = SYSTEMD_CONFIG_PATH if with_systemd == "true" else JAVA_CONFIG_PATH
261-
verify_config_file(container, config_path, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
262-
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
263-
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", ".*", exists=False)
264-
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "false")
265-
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "false")
266-
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "false")
267-
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://127.0.0.1:4317")
268-
269-
config_path = SYSTEMD_CONFIG_PATH if with_systemd == "true" else NODE_CONFIG_PATH
270-
verify_config_file(container, config_path, "NODE_OPTIONS", NODE_OPTIONS)
271-
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
272-
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", ".*", exists=False)
273-
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "false")
274-
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "false")
275-
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "false")
276-
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://127.0.0.1:4317")
279+
if with_systemd == "true":
280+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH, INSTRUMENTATION_CONFIG_PATH]:
281+
assert not container_file_exists(container, config_path)
282+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
283+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
284+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", ".*", exists=False)
285+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_PROFILER_ENABLED", "false")
286+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_PROFILER_MEMORY_ENABLED", "false")
287+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_METRICS_ENABLED", "false")
288+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://127.0.0.1:4317")
289+
if version == "latest":
290+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "NODE_OPTIONS", NODE_OPTIONS)
291+
verify_dotnet_config(container, SYSTEMD_CONFIG_PATH)
292+
else:
293+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "NODE_OPTIONS", ".*", exists=False)
294+
verify_dotnet_config(container, SYSTEMD_CONFIG_PATH, exists=False)
295+
elif version == "latest":
296+
assert not container_file_exists(container, SYSTEMD_CONFIG_PATH)
297+
verify_config_file(container, JAVA_CONFIG_PATH, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
298+
verify_config_file(container, NODE_CONFIG_PATH, "NODE_OPTIONS", NODE_OPTIONS)
299+
verify_dotnet_config(container, DOTNET_CONFIG_PATH)
300+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH]:
301+
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
302+
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", ".*", exists=False)
303+
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "false")
304+
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "false")
305+
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "false")
306+
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://127.0.0.1:4317")
277307
else:
308+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH, SYSTEMD_CONFIG_PATH]:
309+
assert not container_file_exists(container, config_path)
278310
config_path = INSTRUMENTATION_CONFIG_PATH
279311
verify_package_version(container, "splunk-otel-auto-instrumentation", version)
280312
verify_config_file(container, config_path, "java_agent_jar", JAVA_AGENT_PATH)
@@ -346,25 +378,38 @@ def test_puppet_with_custom_instrumentation(distro, puppet_release, version, wit
346378
assert node_package_installed(container)
347379

348380
resource_attributes = rf"{resource_attributes},deployment.environment=test"
349-
if version == "latest" or with_systemd == "true":
350-
config_path = SYSTEMD_CONFIG_PATH if with_systemd == "true" else JAVA_CONFIG_PATH
351-
verify_config_file(container, config_path, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
352-
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
353-
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", "test")
354-
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "true")
355-
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "true")
356-
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "true")
357-
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://0.0.0.0:4317")
358-
359-
config_path = SYSTEMD_CONFIG_PATH if with_systemd == "true" else NODE_CONFIG_PATH
360-
verify_config_file(container, config_path, "NODE_OPTIONS", NODE_OPTIONS)
361-
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
362-
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", "test")
363-
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "true")
364-
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "true")
365-
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "true")
366-
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://0.0.0.0:4317")
381+
if with_systemd == "true":
382+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH, INSTRUMENTATION_CONFIG_PATH]:
383+
assert not container_file_exists(container, config_path)
384+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
385+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
386+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_SERVICE_NAME", "test")
387+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_PROFILER_ENABLED", "true")
388+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_PROFILER_MEMORY_ENABLED", "true")
389+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "SPLUNK_METRICS_ENABLED", "true")
390+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://0.0.0.0:4317")
391+
if version == "latest":
392+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "NODE_OPTIONS", NODE_OPTIONS)
393+
verify_dotnet_config(container, SYSTEMD_CONFIG_PATH)
394+
else:
395+
verify_config_file(container, SYSTEMD_CONFIG_PATH, "NODE_OPTIONS", ".*", exists=False)
396+
verify_dotnet_config(container, SYSTEMD_CONFIG_PATH, exists=False)
397+
elif version == "latest":
398+
for config_path in [SYSTEMD_CONFIG_PATH, INSTRUMENTATION_CONFIG_PATH]:
399+
assert not container_file_exists(container, config_path)
400+
verify_config_file(container, JAVA_CONFIG_PATH, "JAVA_TOOL_OPTIONS", rf"-javaagent:{JAVA_AGENT_PATH}")
401+
verify_config_file(container, NODE_CONFIG_PATH, "NODE_OPTIONS", NODE_OPTIONS)
402+
verify_dotnet_config(container, DOTNET_CONFIG_PATH)
403+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH]:
404+
verify_config_file(container, config_path, "OTEL_RESOURCE_ATTRIBUTES", resource_attributes)
405+
verify_config_file(container, config_path, "OTEL_SERVICE_NAME", "test")
406+
verify_config_file(container, config_path, "SPLUNK_PROFILER_ENABLED", "true")
407+
verify_config_file(container, config_path, "SPLUNK_PROFILER_MEMORY_ENABLED", "true")
408+
verify_config_file(container, config_path, "SPLUNK_METRICS_ENABLED", "true")
409+
verify_config_file(container, config_path, "OTEL_EXPORTER_OTLP_ENDPOINT", r"http://0.0.0.0:4317")
367410
else:
411+
for config_path in [JAVA_CONFIG_PATH, NODE_CONFIG_PATH, DOTNET_CONFIG_PATH, SYSTEMD_CONFIG_PATH]:
412+
assert not container_file_exists(container, config_path)
368413
config_path = INSTRUMENTATION_CONFIG_PATH
369414
verify_package_version(container, "splunk-otel-auto-instrumentation", version)
370415
verify_config_file(container, config_path, "java_agent_jar", JAVA_AGENT_PATH)

0 commit comments

Comments
 (0)