Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 6d32965

Browse files
committed
Recommend NuGet packages
1 parent d8f6296 commit 6d32965

File tree

1 file changed

+89
-65
lines changed

1 file changed

+89
-65
lines changed

gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.rst

Lines changed: 89 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,92 @@ Instrument your .NET application for Splunk Observability Cloud (OpenTelemetry)
99

1010
The Splunk Distribution of OpenTelemetry .NET automatically instruments .NET applications, Windows services running .NET applications, and ASP.NET applications deployed on IIS.
1111

12-
To get started, use the guided setup, follow the instructions manually, or automatically instrument your application. See :ref:`discovery_mode` for more information.
12+
You can install the .NET instrumentation using the NuGet packages, a guided setup, or manual instructions. The NuGet packages are the best method for avoiding dependency version conflicts, but are not well-suited for instrumenting multiple applications running on the same machine. Review the various installation methods on this page to identify the best method for your application environment.
13+
14+
To learn about automatic discovery, see :ref:`discovery_mode`.
15+
16+
.. _otel-dotnet-nuget-pkg:
17+
18+
Install the OpenTelemetry .NET instrumentation using the NuGet packages
19+
=======================================================================
20+
21+
You can deploy the Splunk Distribution of OpenTelemetry .NET instrumentation automatically through the official NuGet packages. Your instrumented application project must support NuGet packages.
22+
23+
The following scenarios are ideal for using the NuGet packages:
24+
25+
* You control the application build but not the machine or container where the application is running.
26+
* You're instrumenting a self-contained application. See :new-page:`Publish self-contained <https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained>` in the .NET documentation.
27+
* You want to facilitate developer experimentation with automatic instrumentation through NuGet packages.
28+
* You need to solve version conflicts between the dependencies used by the application and the automatic instrumentation.
29+
30+
However, you shouldn't use the NuGet packages if any of the following apply to your scenario:
31+
32+
* You're unable to add the NuGet packages to the application project. This can be the case when instrumenting a third-party application.
33+
* You can't accommodate the increased disk use required by installing the NuGet packages separately for each instrumented application running on the same machine.
34+
* You need to instrument a legacy application that can't be migrated to the SDK-style project. To verify whether your project is SDK style, see `Identify the project format <https://learn.microsoft.com/en-us/nuget/resources/check-project-format>`__ in the NuGet documentation.
35+
36+
.. note::
37+
38+
For advanced configuration of the .NET automatic instrumentation, such as changing trace propagation formats or changing the endpoint URLs, see :ref:`advanced-dotnet-otel-configuration`.
39+
40+
Instrument your application using the NuGet packages
41+
----------------------------------------------------
42+
43+
To automatically instrument your application using the NuGet packages, add the ``Splunk.OpenTelemetry.AutoInstrumentation`` package to your project.
44+
45+
#. In a terminal, navigate to the root directory of your .NET application.
46+
47+
#. Add the NuGet packages using the following command, replacing ``<project>`` with the ``.csproj`` file name:
48+
49+
.. code-block:: powershell
50+
51+
dotnet add <project> package Splunk.OpenTelemetry.AutoInstrumentation --prerelease
52+
53+
If the build fails and prompts you to add missing instrumentation packages, add the instrumentation package or skip the instrumentation of the listed package by adding it to the ``SkippedInstrumentation`` property. For example:
54+
55+
.. code-block:: xml
56+
57+
<PropertyGroup>
58+
<SkippedInstrumentations>MongoDB.Driver.Core;StackExchange.Redis</SkippedInstrumentations>
59+
</PropertyGroup>
60+
61+
Alternatively, you can set the ``SkippedInstrumentation`` property from the terminal. Rewrite the ``;`` separator as ``%3B``. For example:
62+
63+
.. code-block:: powershell
64+
65+
dotnet build -p:SkippedInstrumentations=StackExchange.Redis%3BMongoDB.Driver.Core
66+
67+
To distribute the appropriate native runtime components with your .NET application, specify a Runtime Identifier (RID) to build the application using ``dotnet build`` or ``dotnet publish``.
68+
69+
Both self-contained and framework-dependent applications are compatible with automatic instrumentation. See :new-page:`.NET application publishing overview <https://learn.microsoft.com/en-us/dotnet/core/deploying/>` in the .NET documentation for more information.
70+
71+
Run the instrumented application
72+
--------------------------------
73+
74+
The instrumentation procedure in the previous section produces launch scripts in the output folder of the build. The Windows script is ``splunk-launch.cmd`` and the Linux script is ``splunk-launch.sh``. The script passes all the command-line parameters that you provide to the application. Use the following steps to run your instrumented application:
75+
76+
#. Identify the launch script in your build output.
77+
78+
#. Optional. If you want to verify that the instrumentation is working by viewing the telemetry data output in your console, set the following environment variables to ``true``:
79+
80+
* ``OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED``
81+
* ``OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED``
82+
* ``OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED``
83+
84+
#. Run the instrumented application using the launch script:
85+
86+
* Using the executable:
87+
88+
- Windows: ``splunk-launch.cmd <application_executable>``.
89+
- Linux: ``splunk-launch.sh <application_executable>``.
90+
91+
* Using the ``dotnet`` CLI:
92+
93+
- Windows: ``splunk-launch.cmd dotnet <application>``.
94+
- Linux: ``splunk-launch.sh dotnet <application>``.
1395

1496
Generate customized instructions using the guided setup
15-
====================================================================
97+
=======================================================
1698

1799
To generate all the basic installation commands for your environment and application, use the .NET OpenTelemetry guided setup. To access the .NET OpenTelemetry guided setup, follow these steps:
18100

@@ -26,7 +108,7 @@ To generate all the basic installation commands for your environment and applica
26108
#. Select the :guilabel:`.NET (OpenTelemetry)` tile to open the .NET OpenTelemetry guided setup.
27109

28110
Install the Splunk Distribution of OpenTelemetry .NET manually
29-
==================================================================
111+
==============================================================
30112

31113
If you don't use the guided setup, follow these instructions to manually install the Splunk Distribution of OpenTelemetry .NET:
32114

@@ -38,7 +120,7 @@ To install the distribution using the official NuGet packages, see :ref:`otel-do
38120
.. _install-dotnet-otel-instrumentation:
39121

40122
Instrument your .NET application
41-
---------------------------------------------
123+
--------------------------------
42124

43125
Use the following steps to automatically instrument your application.
44126

@@ -52,7 +134,7 @@ Use the following steps to automatically instrument your application.
52134
* ``DOTNET_EnableDiagnostics_Debugger=0``
53135

54136
Windows
55-
^^^^^^^^^^^^
137+
^^^^^^^
56138

57139
#. Check that you meet the requirements. See :ref:`dotnet-otel-requirements`.
58140

@@ -180,7 +262,7 @@ If no data appears in APM, see :ref:`common-dotnet-otel-troubleshooting`.
180262
.. note:: If you need to add custom attributes to spans or want to manually generate spans and metrics, instrument your .NET application or service manually. See :ref:`dotnet-otel-manual-instrumentation`.
181263

182264
Linux
183-
^^^^^^^^^^^^^^^^^
265+
^^^^^
184266

185267
#. Check that you meet the requirements. See :ref:`dotnet-otel-requirements`.
186268

@@ -216,7 +298,7 @@ If no data appears in APM, see :ref:`common-dotnet-otel-troubleshooting`.
216298
.. _activate-profiling-dotnet-otel:
217299

218300
Activate AlwaysOn Profiling
219-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
301+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
220302

221303
To activate AlwaysOn Profiling, set the ``SPLUNK_PROFILER_ENABLED`` environment variable to ``true``.
222304

@@ -238,64 +320,6 @@ Starting from version 1.4.0, the .NET OTel instrumentation collects database que
238320

239321
SQL statements might contain sensitive information. To configure this behavior, see ``OTEL_DOTNET_AUTO_SQLCLIENT_SET_DBSTATEMENT_FOR_TEXT`` and ``OTEL_DOTNET_AUTO_ENTITYFRAMEWORKCORE_SET_DBSTATEMENT_FOR_TEXT`` in :ref:`dotnet-otel-instrumentation-settings`.
240322

241-
242-
.. _otel-dotnet-nuget-pkg:
243-
244-
Install the OpenTelemetry .NET instrumentation using the NuGet packages
245-
--------------------------------------------------------------------------
246-
247-
You can deploy the Splunk Distribution of OpenTelemetry .NET instrumentation automatically through the official NuGet packages. The project of your instrumented application must support NuGet packages.
248-
249-
Use the NuGet package in the following scenarios:
250-
251-
1. You control the application build but not the machine or container where the application is running.
252-
2. You're instrumenting a self-contained application. See :new-page:`Publish self-contained <https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained>` in the .NET documentation.
253-
3. You want to facilitate developer experimentation with automatic instrumentation through NuGet packages.
254-
4. You need to solve version conflicts between the dependencies used by the application and the automatic instrumentation.
255-
256-
Instrument your application using the NuGet packages
257-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
258-
259-
To automatically instrument your application using the NuGet packages, add the ``Splunk.OpenTelemetry.AutoInstrumentation`` package to your project. For example:
260-
261-
.. code-block:: powershell
262-
263-
dotnet add [<PROJECT>] package Splunk.OpenTelemetry.AutoInstrumentation --prerelease
264-
265-
If the build fails and prompts you to add missing instrumentation packages, add the instrumentation package or skip the instrumentation of the listed package by adding it to the ``SkippedInstrumentation`` property. For example:
266-
267-
.. code-block:: xml
268-
269-
<PropertyGroup>
270-
<SkippedInstrumentations>MongoDB.Driver.Core;StackExchange.Redis</SkippedInstrumentations>
271-
</PropertyGroup>
272-
273-
You can also set the ``SkippedInstrumentation`` property from the terminal. Rewrite the ``;`` separator as ``%3B``. For example:
274-
275-
.. code-block:: powershell
276-
277-
dotnet build -p:SkippedInstrumentations=StackExchange.Redis%3BMongoDB.Driver.Core
278-
279-
To distribute the appropriate native runtime components with your .NET application, specify a Runtime Identifier (RID) to build the application using ``dotnet build`` or ``dotnet publish``.
280-
281-
Both self-contained and framework-dependent applications are compatible with automatic instrumentation. See :new-page:`.NET application publishing overview <https://learn.microsoft.com/en-us/dotnet/core/deploying/>` in the .NET documentation for more information.
282-
283-
Run the instrumented application
284-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285-
286-
Use the script in the output folder of the build to run the application with automatic instrumentation activated.
287-
288-
- On Windows, use ``splunk-launch.cmd <application_executable>``.
289-
- On Linux, use ``splunk-launch.sh <application_executable>``.
290-
291-
If you run the application using the ``dotnet`` CLI, add ``dotnet`` after the script.
292-
293-
- On Windows, use ``splunk-launch.cmd dotnet <application>``.
294-
- On Linux, use ``splunk-launch.sh dotnet <application>``.
295-
296-
The script passes all the command-line parameters you provide to the application.
297-
298-
299323
.. _docker-install-otel-dotnet:
300324

301325
Instrument an application running within a Docker container

0 commit comments

Comments
 (0)