From 157f00e0a933f78a9fce3db26f9b51bc54834f2c Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Wed, 11 Sep 2024 15:19:36 -0700 Subject: [PATCH 01/12] Add .NET 8 in-process function tabs --- .../instrument-azure-functions-dotnet.rst | 511 ++++++++++-------- 1 file changed, 294 insertions(+), 217 deletions(-) diff --git a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst index c8d63ab24..a9f7d98e7 100644 --- a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst +++ b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst @@ -53,30 +53,43 @@ Add the required libraries using NuGet Add the following libraries using NuGet in Visual Studio: -Isolated worker process function ----------------------------------------------------- +.. tabs:: -#. Activate the :strong:`Include prerelease` setting. -#. Install the latest version of the following libraries: + .. tab:: Isolated worker process function - - :new-page:`OpenTelemetry ` - - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol ` - - :new-page:`OpenTelemetry.Instrumentation.Http ` - - :new-page:`OpenTelemetry.ResourceDetectors.Azure ` + #. Activate the :strong:`Include prerelease` setting. + #. Install the latest version of the following libraries: -In-process function ----------------------------------------------------- + - :new-page:`OpenTelemetry ` + - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol ` + - :new-page:`OpenTelemetry.Instrumentation.Http ` + - :new-page:`OpenTelemetry.ResourceDetectors.Azure ` -#. Activate the :strong:`Include prerelease` setting. -#. Install the specified version of the following libraries: + .. tab:: .NET 6 In-process function + + #. Activate the :strong:`Include prerelease` setting. + #. Install the specified version of the following libraries: - - :new-page:`OpenTelemetry version 1.3.2 ` - - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol version 1.3.2 ` - - :new-page:`OpenTelemetry.Instrumentation.Http version 1.0.0-rc9.4 ` - - :new-page:`OpenTelemetry.Instrumentation.AspNetCore version 1.0.0-rc9.4 ` - - :new-page:`Microsoft.Azure.Functions.Extensions version 1.1.0 ` + - :new-page:`OpenTelemetry version 1.3.2 ` + - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol version 1.3.2 ` + - :new-page:`OpenTelemetry.Instrumentation.Http version 1.0.0-rc9.4 ` + - :new-page:`OpenTelemetry.Instrumentation.AspNetCore version 1.0.0-rc9.4 ` + - :new-page:`Microsoft.Azure.Functions.Extensions version 1.1.0 ` + + .. note:: Due to runtime dependencies, only the indicated versions are guaranteed to work when instrumenting in-process functions. -.. note:: Due to runtime dependencies, only the indicated versions are guaranteed to work when instrumenting in-process functions. + .. tab:: .NET 8 In-process function + + #. Activate the :strong:`Include prerelease` setting. + #. Install the specified version of the following libraries: + + - :new-page:`OpenTelemetry version 1.3.2 ` + - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol version 1.3.2 ` + - :new-page:`OpenTelemetry.Instrumentation.Http version 1.0.0-rc9.4 ` + - :new-page:`OpenTelemetry.Instrumentation.AspNetCore version 1.0.0-rc9.4 ` + - :new-page:`Microsoft.Azure.Functions.Extensions version 1.1.0 ` + + .. note:: Due to runtime dependencies, only the indicated versions are guaranteed to work when instrumenting in-process functions. .. _azure-functions-dotnet-step-3: @@ -85,129 +98,193 @@ Initialize OpenTelemetry in the code After adding the dependencies, initialize OpenTelemetry in your function. -Isolated worker process function ----------------------------------------------------- - -Add startup initialization in the Program.cs file: - -.. code-block:: csharp - - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Hosting; - using OpenTelemetry; - using OpenTelemetry.Exporter; - using OpenTelemetry.ResourceDetectors.Azure; - using OpenTelemetry.Resources; - using OpenTelemetry.Trace; - using System.Diagnostics; - - // Get environment variables from function configuration - // You need a valid Splunk Observability Cloud access token and realm - var serviceName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; - var accessToken = Environment.GetEnvironmentVariable("SPLUNK_ACCESS_TOKEN")?.Trim(); - var realm = Environment.GetEnvironmentVariable("SPLUNK_REALM")?.Trim(); - - ArgumentNullException.ThrowIfNull(accessToken, "SPLUNK_ACCESS_TOKEN"); - ArgumentNullException.ThrowIfNull(realm, "SPLUNK_REALM"); - - var tp = Sdk.CreateTracerProviderBuilder() - // Use Add[instrumentation-name]Instrumentation to instrument missing services - // Use Nuget to find different instrumentation libraries - .AddHttpClientInstrumentation(opts => - { - // This filter prevents background (parent-less) http client activity - opts.FilterHttpWebRequest = req => Activity.Current?.Parent != null; - opts.FilterHttpRequestMessage = req => Activity.Current?.Parent != null; - }) - // Use AddSource to add your custom DiagnosticSource source names - //.AddSource("My.Source.Name") - // Creates root spans for function executions - .AddSource("Microsoft.Azure.Functions.Worker") - .SetSampler(new AlwaysOnSampler()) - .ConfigureResource(configure => configure - .AddService(serviceName: serviceName, serviceVersion: "1.0.0") - // See https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.ResourceDetectors.Azure - // for other types of Azure detectors - .AddDetector(new AppServiceResourceDetector())) - .AddOtlpExporter(opts => - { - opts.Endpoint = new Uri($"https://ingest.{realm}.signalfx.com/v2/trace/otlp"); - opts.Protocol = OtlpExportProtocol.HttpProtobuf; - opts.Headers = $"X-SF-TOKEN={accessToken}"; - }) - .Build(); - - var host = new HostBuilder() - .ConfigureFunctionsWorkerDefaults() - .ConfigureServices(services => services.AddSingleton(tp)) - .Build(); - - host.Run(); - -.. note:: When instrumenting isolated worker process functions, you can encapsulate startup initialization and parameters into other functions. - -In-process function ----------------------------------------------------- - -Define a startup function and decorate the assembly with it. The startup function uses the Azure.Functions.Extensions package to collect useful metadata. - -.. code-block:: csharp - - using Microsoft.Azure.Functions.Extensions.DependencyInjection; - using Microsoft.Extensions.DependencyInjection; - using OpenTelemetry; - using OpenTelemetry.Exporter; - using OpenTelemetry.Resources; - using OpenTelemetry.Trace; - using System; - using System.Collections.Generic; - - // Decorate assembly with startup function - [assembly: FunctionsStartup(typeof(OtelManualExample.Startup))] - - namespace OtelManualExample - { - public class Startup : FunctionsStartup - { - public override void Configure(IFunctionsHostBuilder builder) +.. tabs:: + + .. tab:: Isolated worker process function + + Add startup initialization in the Program.cs file: + + .. code-block:: csharp + + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; + using OpenTelemetry; + using OpenTelemetry.Exporter; + using OpenTelemetry.ResourceDetectors.Azure; + using OpenTelemetry.Resources; + using OpenTelemetry.Trace; + using System.Diagnostics; + + // Get environment variables from function configuration + // You need a valid Splunk Observability Cloud access token and realm + var serviceName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; + var accessToken = Environment.GetEnvironmentVariable("SPLUNK_ACCESS_TOKEN")?.Trim(); + var realm = Environment.GetEnvironmentVariable("SPLUNK_REALM")?.Trim(); + + ArgumentNullException.ThrowIfNull(accessToken, "SPLUNK_ACCESS_TOKEN"); + ArgumentNullException.ThrowIfNull(realm, "SPLUNK_REALM"); + + var tp = Sdk.CreateTracerProviderBuilder() + // Use Add[instrumentation-name]Instrumentation to instrument missing services + // Use Nuget to find different instrumentation libraries + .AddHttpClientInstrumentation(opts => + { + // This filter prevents background (parent-less) http client activity + opts.FilterHttpWebRequest = req => Activity.Current?.Parent != null; + opts.FilterHttpRequestMessage = req => Activity.Current?.Parent != null; + }) + // Use AddSource to add your custom DiagnosticSource source names + //.AddSource("My.Source.Name") + // Creates root spans for function executions + .AddSource("Microsoft.Azure.Functions.Worker") + .SetSampler(new AlwaysOnSampler()) + .ConfigureResource(configure => configure + .AddService(serviceName: serviceName, serviceVersion: "1.0.0") + // See https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.ResourceDetectors.Azure + // for other types of Azure detectors + .AddDetector(new AppServiceResourceDetector())) + .AddOtlpExporter(opts => + { + opts.Endpoint = new Uri($"https://ingest.{realm}.signalfx.com/v2/trace/otlp"); + opts.Protocol = OtlpExportProtocol.HttpProtobuf; + opts.Headers = $"X-SF-TOKEN={accessToken}"; + }) + .Build(); + + var host = new HostBuilder() + .ConfigureFunctionsWorkerDefaults() + .ConfigureServices(services => services.AddSingleton(tp)) + .Build(); + + host.Run(); + + .. note:: When instrumenting isolated worker process functions, you can encapsulate startup initialization and parameters into other functions. + + .. tab:: .NET 6 In-process function + + Define a startup function and decorate the assembly with it. The startup function uses the Azure.Functions.Extensions package to collect useful metadata. + + .. code-block:: csharp + + using Microsoft.Azure.Functions.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using OpenTelemetry; + using OpenTelemetry.Exporter; + using OpenTelemetry.Resources; + using OpenTelemetry.Trace; + using System; + using System.Collections.Generic; + + // Decorate assembly with startup function + [assembly: FunctionsStartup(typeof(OtelManualExample.Startup))] + + namespace OtelManualExample { - // Get environment variables from function configuration - // You need a valid Splunk Observability Cloud access token and realm - var serviceName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; - var accessToken = Environment.GetEnvironmentVariable("SPLUNK_ACCESS_TOKEN")?.Trim(); - var realm = Environment.GetEnvironmentVariable("SPLUNK_REALM")?.Trim(); - - ArgumentNullException.ThrowIfNull(accessToken, "SPLUNK_ACCESS_TOKEN"); - ArgumentNullException.ThrowIfNull(realm, "SPLUNK_REALM"); - - var tp = Sdk.CreateTracerProviderBuilder() - // Use Add[instrumentation-name]Instrumentation to instrument missing services - // Use Nuget to find different instrumentation libraries - .AddHttpClientInstrumentation(opts => - // This filter prevents background (parent-less) http client activity - opts.Filter = req => Activity.Current?.Parent != null) - .AddAspNetCoreInstrumentation() - // Use AddSource to add your custom DiagnosticSource source names - //.AddSource("My.Source.Name") - .SetSampler(new AlwaysOnSampler()) - // Add resource attributes to all spans - .SetResourceBuilder( - ResourceBuilder.CreateDefault() - .AddService(serviceName: serviceName, serviceVersion: "1.0.0") - .AddAttributes(new Dictionary() { - { "faas.instance", Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") } - })) - .AddOtlpExporter(opts => + public class Startup : FunctionsStartup + { + public override void Configure(IFunctionsHostBuilder builder) { - opts.Endpoint = new Uri($"https://ingest.{realm}.signalfx.com/v2/trace/otlp"); - opts.Protocol = OtlpExportProtocol.HttpProtobuf; - opts.Headers = $"X-SF-TOKEN={accessToken}"; - }) - .Build(); + // Get environment variables from function configuration + // You need a valid Splunk Observability Cloud access token and realm + var serviceName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; + var accessToken = Environment.GetEnvironmentVariable("SPLUNK_ACCESS_TOKEN")?.Trim(); + var realm = Environment.GetEnvironmentVariable("SPLUNK_REALM")?.Trim(); + + ArgumentNullException.ThrowIfNull(accessToken, "SPLUNK_ACCESS_TOKEN"); + ArgumentNullException.ThrowIfNull(realm, "SPLUNK_REALM"); + + var tp = Sdk.CreateTracerProviderBuilder() + // Use Add[instrumentation-name]Instrumentation to instrument missing services + // Use Nuget to find different instrumentation libraries + .AddHttpClientInstrumentation(opts => + // This filter prevents background (parent-less) http client activity + opts.Filter = req => Activity.Current?.Parent != null) + .AddAspNetCoreInstrumentation() + // Use AddSource to add your custom DiagnosticSource source names + //.AddSource("My.Source.Name") + .SetSampler(new AlwaysOnSampler()) + // Add resource attributes to all spans + .SetResourceBuilder( + ResourceBuilder.CreateDefault() + .AddService(serviceName: serviceName, serviceVersion: "1.0.0") + .AddAttributes(new Dictionary() { + { "faas.instance", Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") } + })) + .AddOtlpExporter(opts => + { + opts.Endpoint = new Uri($"https://ingest.{realm}.signalfx.com/v2/trace/otlp"); + opts.Protocol = OtlpExportProtocol.HttpProtobuf; + opts.Headers = $"X-SF-TOKEN={accessToken}"; + }) + .Build(); + + builder.Services.AddSingleton(tp); + } + } + } + + .. tab:: .NET 8 In-process function + + Define a startup function and decorate the assembly with it. The startup function uses the Azure.Functions.Extensions package to collect useful metadata. - builder.Services.AddSingleton(tp); + .. code-block:: csharp + + using Microsoft.Azure.Functions.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using OpenTelemetry; + using OpenTelemetry.Exporter; + using OpenTelemetry.Resources; + using OpenTelemetry.Trace; + using System; + using System.Collections.Generic; + + // Decorate assembly with startup function + [assembly: FunctionsStartup(typeof(OtelManualExample.Startup))] + + namespace OtelManualExample + { + public class Startup : FunctionsStartup + { + public override void Configure(IFunctionsHostBuilder builder) + { + // Get environment variables from function configuration + // You need a valid Splunk Observability Cloud access token and realm + var serviceName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "Unknown"; + var accessToken = Environment.GetEnvironmentVariable("SPLUNK_ACCESS_TOKEN")?.Trim(); + var realm = Environment.GetEnvironmentVariable("SPLUNK_REALM")?.Trim(); + + ArgumentNullException.ThrowIfNull(accessToken, "SPLUNK_ACCESS_TOKEN"); + ArgumentNullException.ThrowIfNull(realm, "SPLUNK_REALM"); + + var tp = Sdk.CreateTracerProviderBuilder() + // Use Add[instrumentation-name]Instrumentation to instrument missing services + // Use Nuget to find different instrumentation libraries + .AddHttpClientInstrumentation(opts => + // This filter prevents background (parent-less) http client activity + opts.Filter = req => Activity.Current?.Parent != null) + .AddAspNetCoreInstrumentation() + // Use AddSource to add your custom DiagnosticSource source names + //.AddSource("My.Source.Name") + .SetSampler(new AlwaysOnSampler()) + // Add resource attributes to all spans + .SetResourceBuilder( + ResourceBuilder.CreateDefault() + .AddService(serviceName: serviceName, serviceVersion: "1.0.0") + .AddAttributes(new Dictionary() { + { "faas.instance", Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") } + })) + .AddOtlpExporter(opts => + { + opts.Endpoint = new Uri($"https://ingest.{realm}.signalfx.com/v2/trace/otlp"); + opts.Protocol = OtlpExportProtocol.HttpProtobuf; + opts.Headers = $"X-SF-TOKEN={accessToken}"; + }) + .Build(); + + builder.Services.AddSingleton(tp); + } + } } - } .. _azure-functions-dotnet-step-4: @@ -216,86 +293,86 @@ Instrument the code to send spans Next, instrument your code using OpenTelemetry. Use the following examples as a starting point to instrument your code. See :new-page:`https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings ` in Microsoft Azure documentation for steps to add environment variables to an Azure function. -Isolated worker process function ----------------------------------------------------- +.. tabs:: -The following example shows how to instrument a function using start and stop helper functions: + .. tab:: Isolated worker process function -.. code-block:: csharp + The following example shows how to instrument a function using start and stop helper functions: - using System.Diagnostics; - using System.Net; - using Microsoft.Azure.Functions.Worker; - using Microsoft.Azure.Functions.Worker.Http; - using Microsoft.Extensions.Logging; - - namespace OtelManualIsolatedExample - { - public class ExampleFunction - { - private readonly ILogger _logger; - - public ExampleFunction(ILoggerFactory loggerFactory) - { - _logger = loggerFactory.CreateLogger(); - } - // Define helper functions for manual instrumentation - public static ActivitySource ManualInstrumentationSource = new ActivitySource("manualInstrumentation"); - public static Activity? StartActivity(HttpRequestData req, FunctionContext fc) - { - // Retrieve resource attributes - var answer = ManualInstrumentationSource.StartActivity(req.Method.ToUpper() + " " + req.Url.AbsolutePath, ActivityKind.Server); - answer?.AddTag("http.url", req.Url); - answer?.AddTag("faas.invocation_id", fc.InvocationId.ToString()); - answer?.AddTag("faas.name", Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") + "/" + fc.FunctionDefinition.Name); - return answer; - } - public static HttpResponseData FinishActivity(HttpResponseData response, Activity? activity) - { - activity?.AddTag("http.status_code", ((int)response.StatusCode)); - return response; - } - - [Function("ExampleFunction")] - // Add the FunctionContext parameter to capture per-invocation information - public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, FunctionContext fc) + .. code-block:: csharp + + using System.Diagnostics; + using System.Net; + using Microsoft.Azure.Functions.Worker; + using Microsoft.Azure.Functions.Worker.Http; + using Microsoft.Extensions.Logging; + + namespace OtelManualIsolatedExample { - using (var activity = StartActivity(req, fc)) + public class ExampleFunction + { + private readonly ILogger _logger; + + public ExampleFunction(ILoggerFactory loggerFactory) { - var response = req.CreateResponse(HttpStatusCode.OK); - response.Headers.Add("Content-Type", "text/plain; charset=utf-8"); - - response.WriteString("The current time is " + DateTime.Now.ToLongTimeString()); - - return FinishActivity(response, activity); + _logger = loggerFactory.CreateLogger(); } + // Define helper functions for manual instrumentation + public static ActivitySource ManualInstrumentationSource = new ActivitySource("manualInstrumentation"); + public static Activity? StartActivity(HttpRequestData req, FunctionContext fc) + { + // Retrieve resource attributes + var answer = ManualInstrumentationSource.StartActivity(req.Method.ToUpper() + " " + req.Url.AbsolutePath, ActivityKind.Server); + answer?.AddTag("http.url", req.Url); + answer?.AddTag("faas.invocation_id", fc.InvocationId.ToString()); + answer?.AddTag("faas.name", Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") + "/" + fc.FunctionDefinition.Name); + return answer; + } + public static HttpResponseData FinishActivity(HttpResponseData response, Activity? activity) + { + activity?.AddTag("http.status_code", ((int)response.StatusCode)); + return response; + } + + [Function("ExampleFunction")] + // Add the FunctionContext parameter to capture per-invocation information + public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, FunctionContext fc) + { + using (var activity = StartActivity(req, fc)) + { + var response = req.CreateResponse(HttpStatusCode.OK); + response.Headers.Add("Content-Type", "text/plain; charset=utf-8"); + + response.WriteString("The current time is " + DateTime.Now.ToLongTimeString()); + + return FinishActivity(response, activity); + } + } + } } - } - } -In-process function ----------------------------------------------------- + .. tab:: In-process function -The following example shows how to retrieve ``faas`` attributes: + The following example shows how to retrieve ``faas`` attributes: -.. code-block:: csharp - - public static class ExampleFunction - { - [FunctionName("ExampleFunction")] - // Add the ExecutionContext parameter to capture per-invocation information - public static async Task Run( - [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, - ILogger log, ExecutionContext context) - { - // You can also factor this out into a helper method to use across all functions - Activity.Current.AddTag("faas.invocation_id", context.InvocationId.ToString()); - Activity.Current.AddTag("faas.name", Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") + "/" + context.FunctionName); - - string responseMessage = "The current time is " + DateTime.Now.ToLongTimeString(); - return new OkObjectResult(responseMessage); - } - } + .. code-block:: csharp + + public static class ExampleFunction + { + [FunctionName("ExampleFunction")] + // Add the ExecutionContext parameter to capture per-invocation information + public static async Task Run( + [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, + ILogger log, ExecutionContext context) + { + // You can also factor this out into a helper method to use across all functions + Activity.Current.AddTag("faas.invocation_id", context.InvocationId.ToString()); + Activity.Current.AddTag("faas.name", Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") + "/" + context.FunctionName); + + string responseMessage = "The current time is " + DateTime.Now.ToLongTimeString(); + return new OkObjectResult(responseMessage); + } + } .. _azure-functions-dotnet-step-5: @@ -304,21 +381,21 @@ Check that data is coming in Run your function and search for its spans in Splunk APM. See :ref:`span-search` for more information. -Isolated worker process function ----------------------------------------------------- +.. tabs:: + + .. tab:: Isolated worker process function -The following image shows a span sent by an isolated worker process function. Notice the ``faas`` tags: + The following image shows a span sent by an isolated worker process function. Notice the ``faas`` tags: -.. image:: /_images/gdi/isolated_span.png - :alt: Span details from an isolated worker process function + .. image:: /_images/gdi/isolated_span.png + :alt: Span details from an isolated worker process function -In-process function ----------------------------------------------------- + .. tab:: In-process function -The following image shows a span sent by an in-process function. Notice the ``faas`` tags: + The following image shows a span sent by an in-process function. Notice the ``faas`` tags: -.. image:: /_images/gdi/inprocess_span.png - :alt: Span details from an in-process function + .. image:: /_images/gdi/inprocess_span.png + :alt: Span details from an in-process function Troubleshooting ====================== From 2de72d6cb067d8083c59fca18fe28b465e8b93d0 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Wed, 11 Sep 2024 17:40:16 -0700 Subject: [PATCH 02/12] Add advanced config options for IIS apps --- .../application/otel-dotnet/get-started.rst | 1 + .../advanced-config-iis-apps.rst | 59 +++++++++++++++++++ .../instrument-dotnet-application.rst | 15 ++--- 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst diff --git a/gdi/get-data-in/application/otel-dotnet/get-started.rst b/gdi/get-data-in/application/otel-dotnet/get-started.rst index 0f53a4b11..3944c49c0 100644 --- a/gdi/get-data-in/application/otel-dotnet/get-started.rst +++ b/gdi/get-data-in/application/otel-dotnet/get-started.rst @@ -13,6 +13,7 @@ Instrument .NET applications for Splunk Observability Cloud (OpenTelemetry) Requirements Pre-checks Instrument your .NET application + Advanced configuration for IIS applications Instrument Azure Web Apps Instrument Azure Web Jobs Configure the .NET instrumentation diff --git a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst new file mode 100644 index 000000000..938fb5371 --- /dev/null +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst @@ -0,0 +1,59 @@ +.. _advanced-config-iis-apps: + +******************************************* +Advanced configuration for IIS applications +******************************************* + +Follow these advanced configuration steps to make changes to specific application pools. + +Set resource attributes +======================= + +You can set the resource attributes for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file `. + +For example: + +.. code-block:: xml + + + + + +.. note:: + + If you set the ``OTEL_RESOURCE_ATTRIBUTES`` environment variable in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. + +Active or deactivate instrumentation +===================================== + +Use the PowerShell module to activate or deactivate the instrumentation for specific application pools. + +#. Import the PowerShell module: + + .. code-block:: powershell + + Import-Module "OpenTelemetry.DotNet.Auto.psm1" + + .. note:: + + The application pool name is case sensitive. + +#. Activate or deactivate the application pool. + + * Activate instrumentation for the application pool: + + .. code-block:: powershell + + Enable-OpenTelemetryForIISAppPool -AppPoolName + + * Deactivate instrumentation for the application pool: + + .. code-block:: powershell + + Disable-OpenTelemetryForIISAppPool -AppPoolName + +#. Restart the application pool: + + .. code-block:: powershell + + Restart-WebAppPool -Name \ No newline at end of file diff --git a/gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.rst b/gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.rst index b89107936..33ba345f0 100644 --- a/gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.rst +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.rst @@ -238,16 +238,9 @@ Windows Start-Process "iisreset.exe" -NoNewWindow -Wait - You can also set the resource attributes for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file `. For example: - - .. code-block:: xml - - - - - .. note:: - If the ``OTEL_SERVICE_NAME`` or ``OTEL_RESOURCE_ATTRIBUTES`` environment variables are set for a process, settings with the same names from ``appSettings`` block of web.config are ignored. + + For advanced IIS application configuration options, see :ref:`advanced-config-iis-apps`. .. tab:: IIS (ASP.NET Core) @@ -266,6 +259,10 @@ Windows Start-Process "iisreset.exe" -NoNewWindow -Wait + .. note:: + + For advanced IIS application configuration options, see :ref:`advanced-config-iis-apps`. + .. tab:: Windows service For .NET Framework applications, you can configure resource attributes in the ``appSettings`` block of the app.config file. From aa567cd18563dea84f631eb088b06e4f062fb5ba Mon Sep 17 00:00:00 2001 From: pauljwil Date: Fri, 13 Sep 2024 09:34:53 -0700 Subject: [PATCH 03/12] Update gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst Co-authored-by: Rasmus Kuusmann --- .../azure/instrument-azure-functions-dotnet.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst index a9f7d98e7..57e8f2414 100644 --- a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst +++ b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst @@ -83,10 +83,11 @@ Add the following libraries using NuGet in Visual Studio: #. Activate the :strong:`Include prerelease` setting. #. Install the specified version of the following libraries: - - :new-page:`OpenTelemetry version 1.3.2 ` - - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol version 1.3.2 ` - - :new-page:`OpenTelemetry.Instrumentation.Http version 1.0.0-rc9.4 ` - - :new-page:`OpenTelemetry.Instrumentation.AspNetCore version 1.0.0-rc9.4 ` + - :new-page:`OpenTelemetry version 1.9.0 ` + - :new-page:`OpenTelemetry.Exporter.OpenTelemetryProtocol version 1.9.0 ` + - :new-page:`OpenTelemetry.Instrumentation.Http version 1.9.0 ` + - :new-page:`OpenTelemetry.Instrumentation.AspNetCore version 1.9.0 ` + - :new-page:`OpenTelemetry.Resources.Azure version 1.0.0-beta.8 ` - :new-page:`Microsoft.Azure.Functions.Extensions version 1.1.0 ` .. note:: Due to runtime dependencies, only the indicated versions are guaranteed to work when instrumenting in-process functions. From 10e04596bf0af57ccb52bd774f0b939ecbc3ab75 Mon Sep 17 00:00:00 2001 From: pauljwil Date: Fri, 13 Sep 2024 09:35:52 -0700 Subject: [PATCH 04/12] Update gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst Co-authored-by: Rasmus Kuusmann --- .../azure/instrument-azure-functions-dotnet.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst index 57e8f2414..2cd8182cd 100644 --- a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst +++ b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst @@ -260,9 +260,12 @@ After adding the dependencies, initialize OpenTelemetry in your function. var tp = Sdk.CreateTracerProviderBuilder() // Use Add[instrumentation-name]Instrumentation to instrument missing services // Use Nuget to find different instrumentation libraries - .AddHttpClientInstrumentation(opts => - // This filter prevents background (parent-less) http client activity - opts.Filter = req => Activity.Current?.Parent != null) + .AddHttpClientInstrumentation(opts => + { + // This filter prevents background (parent-less) http client activity + opts.FilterHttpRequestMessage = req => Activity.Current?.Parent != null; + opts.FilterHttpWebRequest = req => Activity.Current?.Parent != null; + }) .AddAspNetCoreInstrumentation() // Use AddSource to add your custom DiagnosticSource source names //.AddSource("My.Source.Name") From ab32e10334841de9c3aa463d301107ab92957c33 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Fri, 13 Sep 2024 09:50:46 -0700 Subject: [PATCH 05/12] Make changes from Rasmus --- .../instrumentation/advanced-config-iis-apps.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst index 938fb5371..010fda9a4 100644 --- a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst @@ -6,10 +6,10 @@ Advanced configuration for IIS applications Follow these advanced configuration steps to make changes to specific application pools. -Set resource attributes -======================= +Set environment variables +========================= -You can set the resource attributes for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file `. +You can set environment variables for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file `. For example: @@ -19,14 +19,16 @@ For example: +For all IIS applications, consider setting common environment variables for W3SVC and WAS Windows Services. For more information, see :new-page:`Instrument a Windows Service running a .NET application ` in the OpenTelemetry documentation. + .. note:: - If you set the ``OTEL_RESOURCE_ATTRIBUTES`` environment variable in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. + If the same environment variables are set in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. Active or deactivate instrumentation ===================================== -Use the PowerShell module to activate or deactivate the instrumentation for specific application pools. +For .NET Framework applications, use the PowerShell module to activate or deactivate the instrumentation for specific application pools. #. Import the PowerShell module: From 959d8a50c90ad3073f7de5f6c41f44e05eb13988 Mon Sep 17 00:00:00 2001 From: pauljwil Date: Mon, 16 Sep 2024 13:51:36 -0700 Subject: [PATCH 06/12] Update gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst Co-authored-by: Rasmus Kuusmann --- .../serverless/azure/instrument-azure-functions-dotnet.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst index 2cd8182cd..884c30808 100644 --- a/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst +++ b/gdi/get-data-in/serverless/azure/instrument-azure-functions-dotnet.rst @@ -274,6 +274,7 @@ After adding the dependencies, initialize OpenTelemetry in your function. .SetResourceBuilder( ResourceBuilder.CreateDefault() .AddService(serviceName: serviceName, serviceVersion: "1.0.0") + .AddAzureAppServiceDetector() .AddAttributes(new Dictionary() { { "faas.instance", Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") } })) From f2c0aab865be1f6d1cbf35339ef3bb28e6954bed Mon Sep 17 00:00:00 2001 From: puribe-splunk Date: Wed, 18 Sep 2024 09:18:41 -0700 Subject: [PATCH 07/12] DOCS-4567 - Changing Inc. to LLC --- _templates/404.html | 4 ++-- _templates/layout.html | 4 ++-- _templates/search.html | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_templates/404.html b/_templates/404.html index 5d963dbfc..6c248975b 100644 --- a/_templates/404.html +++ b/_templates/404.html @@ -204,8 +204,8 @@

Was this Privacy | Terms | Export Control | - © 2005 - 2023 Splunk Inc. All rights reserved. -
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.
+ © 2005 - 2023 Splunk LLC All rights reserved. +
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk LLC in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.
diff --git a/_templates/layout.html b/_templates/layout.html index 8b173af17..553856012 100644 --- a/_templates/layout.html +++ b/_templates/layout.html @@ -206,8 +206,8 @@

Was this Privacy | Terms | Export Control | - © 2005 - 2023 Splunk Inc. All rights reserved. -
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.
+ © 2005 - 2023 Splunk LLC All rights reserved. +
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk LLC in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.

diff --git a/_templates/search.html b/_templates/search.html index 6e9fe858a..348395afa 100644 --- a/_templates/search.html +++ b/_templates/search.html @@ -268,8 +268,8 @@

Was this Privacy | Terms | Export Control | - © 2005 - 2023 Splunk Inc. All rights reserved. -
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.
+ © 2005 - 2023 Splunk LLC All rights reserved. +
Splunk, Splunk>, Turn Data Into Doing, and Data-to-Everything are trademarks or registered trademarks of Splunk LLC in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.

From 040fc223e1670699d1d32aa7267e8aeb3c28d0fe Mon Sep 17 00:00:00 2001 From: pauljwil Date: Wed, 18 Sep 2024 14:26:49 -0700 Subject: [PATCH 08/12] Update gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst Co-authored-by: mbechtold-splunk <107698185+mbechtold-splunk@users.noreply.github.com> --- .../otel-dotnet/instrumentation/advanced-config-iis-apps.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst index 010fda9a4..40bf5e4dd 100644 --- a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst @@ -25,7 +25,7 @@ For all IIS applications, consider setting common environment variables for W3SV If the same environment variables are set in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. -Active or deactivate instrumentation +Activate or deactivate instrumentation ===================================== For .NET Framework applications, use the PowerShell module to activate or deactivate the instrumentation for specific application pools. From 7ea4f85cd24ea32512ed4236de1b945e9e1281d9 Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Wed, 18 Sep 2024 14:34:46 -0700 Subject: [PATCH 09/12] Extend header line --- .../otel-dotnet/instrumentation/advanced-config-iis-apps.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst index 40bf5e4dd..0247340a6 100644 --- a/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst @@ -26,7 +26,7 @@ For all IIS applications, consider setting common environment variables for W3SV If the same environment variables are set in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. Activate or deactivate instrumentation -===================================== +====================================== For .NET Framework applications, use the PowerShell module to activate or deactivate the instrumentation for specific application pools. From f2714ece8e7c5ea43b9eeefd55b2f70d2218d079 Mon Sep 17 00:00:00 2001 From: Anna Urbiztondo Date: Thu, 19 Sep 2024 06:29:26 +0200 Subject: [PATCH 10/12] Minor clarification --- gdi/opentelemetry/components/postgresql-receiver.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdi/opentelemetry/components/postgresql-receiver.rst b/gdi/opentelemetry/components/postgresql-receiver.rst index 12db40543..fb335f833 100644 --- a/gdi/opentelemetry/components/postgresql-receiver.rst +++ b/gdi/opentelemetry/components/postgresql-receiver.rst @@ -7,7 +7,7 @@ PostgreSQL receiver .. meta:: :description: The PostgreSQL receiver allows the Splunk Distribution of OpenTelemetry Collector to collect metrics from PostgreSQL through its statistics collector. -The PostgreSQL receiver allows the Splunk Distribution of the OpenTelemetry Collector to collect metrics from PostgreSQL through its statistics collector. The supported pipeline type is ``metrics``. See :ref:`otel-data-processing` for more information. +The PostgreSQL receiver allows the Splunk Distribution of the OpenTelemetry Collector to collect metrics from PostgreSQL using the PostgreSQL statistics collector. The supported pipeline type is ``metrics``. See :ref:`otel-data-processing` for more information. .. note:: Use the PostgreSQL receiver in place of the SignalFx Smart Agent ``postgresql`` monitor type. @@ -16,7 +16,7 @@ Requirements This receiver supports PostgreSQL version 9.6 and higher. -To let the receiver collect data, grant the monitoring user ``SELECT`` permissions for ``pg_stat_database``. +To let the receiver collect data, grant the monitoring user ``SELECT`` permissions for ``pg_stat_database``. Learn more at the official :new-page:`PostgreSQL statistics collector ` documentation. Get started ====================== @@ -47,7 +47,7 @@ configuration file, as shown in the following example: username: otel password: ${env:PGSQL_PASSWORD} databases: - - + - otel collection_interval: 10s tls: insecure: false From 0ecb7c0923503e2830934cea16b9c40e5ad45aed Mon Sep 17 00:00:00 2001 From: Anna Urbiztondo Date: Thu, 19 Sep 2024 07:27:45 +0200 Subject: [PATCH 11/12] Feedback --- gdi/private-connectivity/aws-privatelink.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdi/private-connectivity/aws-privatelink.rst b/gdi/private-connectivity/aws-privatelink.rst index 930d99d97..dc8b0fcbd 100644 --- a/gdi/private-connectivity/aws-privatelink.rst +++ b/gdi/private-connectivity/aws-privatelink.rst @@ -240,8 +240,8 @@ To create a VPC endpoint, follow these steps: 7. Set the IP address type to ``IPv4``. -8. Specify the security group or groups controlling inbound and outbound traffic for the endpoint, and set the outbound rule for the selected security groups open for port ``443``. - +8. Specify the security group or groups controlling inbound and outbound traffic for the endpoint, and set the outbound rule for the selected security groups open for port ``443``. If you're using HTTPS, you need to configure inbound rules only. + The following image shows the security options for AWS PrivateLink: .. image:: /_images/gdi/aws-privatelink-secgroups2.png @@ -250,7 +250,7 @@ To create a VPC endpoint, follow these steps: 9. Review the configuration details and select :guilabel:`Create Endpoint`. -10. Before proceeding to :ref:`aws-privatelink-step4`, confirm with Splunk Customer Support that you created the endpoint, that the service name has been verified, and that Support has activated the endpoint urls. +10. Before proceeding to :ref:`aws-privatelink-step4`, confirm with Splunk Customer Support that you created the endpoint, that the service name has been verified, and that Support has activated the endpoint urls. .. _aws-privatelink-step4: From 4b6c25a6799010fa59226ae5c2ed024b858d34f9 Mon Sep 17 00:00:00 2001 From: Anna Urbiztondo Date: Thu, 19 Sep 2024 08:27:50 +0200 Subject: [PATCH 12/12] Correction --- gdi/private-connectivity/aws-privatelink.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdi/private-connectivity/aws-privatelink.rst b/gdi/private-connectivity/aws-privatelink.rst index dc8b0fcbd..1888745bf 100644 --- a/gdi/private-connectivity/aws-privatelink.rst +++ b/gdi/private-connectivity/aws-privatelink.rst @@ -240,7 +240,7 @@ To create a VPC endpoint, follow these steps: 7. Set the IP address type to ``IPv4``. -8. Specify the security group or groups controlling inbound and outbound traffic for the endpoint, and set the outbound rule for the selected security groups open for port ``443``. If you're using HTTPS, you need to configure inbound rules only. +8. Specify the security group controlling traffic for the endpoint. Set the inbound rule to HTTPS protocol and the ``443`` port. The following image shows the security options for AWS PrivateLink: @@ -250,7 +250,7 @@ To create a VPC endpoint, follow these steps: 9. Review the configuration details and select :guilabel:`Create Endpoint`. -10. Before proceeding to :ref:`aws-privatelink-step4`, confirm with Splunk Customer Support that you created the endpoint, that the service name has been verified, and that Support has activated the endpoint urls. +10. Before proceeding to :ref:`aws-privatelink-step4`, confirm with Splunk Customer Support that you created the endpoint, that the service name has been verified, and that Support has activated the endpoint urls. .. _aws-privatelink-step4: