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.

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..0247340a6 --- /dev/null +++ b/gdi/get-data-in/application/otel-dotnet/instrumentation/advanced-config-iis-apps.rst @@ -0,0 +1,61 @@ +.. _advanced-config-iis-apps: + +******************************************* +Advanced configuration for IIS applications +******************************************* + +Follow these advanced configuration steps to make changes to specific application pools. + +Set environment variables +========================= + +You can set environment variables for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file `. + +For example: + +.. code-block:: xml + + + + + +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 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. + +#. 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. 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..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 @@ -53,30 +53,44 @@ 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.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. .. _azure-functions-dotnet-step-3: @@ -85,129 +99,197 @@ 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.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") + .SetSampler(new AlwaysOnSampler()) + // Add resource attributes to all spans + .SetResourceBuilder( + ResourceBuilder.CreateDefault() + .AddService(serviceName: serviceName, serviceVersion: "1.0.0") + .AddAzureAppServiceDetector() + .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 +298,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 +386,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 ====================== 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 diff --git a/gdi/private-connectivity/aws-privatelink.rst b/gdi/private-connectivity/aws-privatelink.rst index 930d99d97..1888745bf 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 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: .. image:: /_images/gdi/aws-privatelink-secgroups2.png