Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docset.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project: 'EDOT documentation'

Check notice on line 1 in docs/docset.yml

View workflow job for this annotation

GitHub Actions / docs-preview / build

The following keys: 'edot, ecloud, ech, ess, ece, serverless-full, security-app, stack-manage-app, stack-monitor-app, rules-ui, connectors-ui, connectors-feature, hosted-ems, data-sources, agent, agents, fleet, fleet-server, package-manager, stack, es, kib, ls, security-features, stack-security-features, endpoint-sec, swimlane, sn, sn-itsm, sn-itom, sn-sir, ibm-r, webhook, webhook-cm, opsgenie, bedrock, gemini, hive, report-features, ml, ccs, anomaly-job, observability, kib-repo, kib-pull' are not used in any file
cross_links:
- apm-agent-android
- apm-agent-dotnet
Expand All @@ -19,6 +19,7 @@
- elasticsearch
- kibana
- integrations
- integration-docs
toc:
- toc: reference
# - toc: release-notes
Expand Down
90 changes: 34 additions & 56 deletions docs/reference/edot-sdks/dotnet/configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
navigation_title: Configuration
description: Configure the Elastic Distribution of OpenTelemetry .NET (EDOT .NET) to send data to Elastic.
applies_to:
stack:
serverless:
Expand All @@ -10,7 +11,7 @@ products:
- id: edot-dotnet
---

# Configuring the EDOT .NET SDK
# Configure the EDOT .NET SDK

Configure the Elastic Distribution of OpenTelemetry .NET (EDOT .NET) to send data to Elastic.

Expand All @@ -19,32 +20,25 @@ Configure the Elastic Distribution of OpenTelemetry .NET (EDOT .NET) to send dat
Configure the OpenTelemetry SDK using the mechanisms listed in the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/net/automatic/configuration/),
including:

* Setting [environment variables](#environment-variables)
* Using the [`IConfiguration` integration](#iconfiguration-integration)
* [Manually configuring](#manual-configuration) EDOT .NET
* Setting [environment variables](#environment-variables).
* Using the [`IConfiguration` integration](#iconfiguration-integration).
* [Manually configuring](#manual-configuration) EDOT .NET.

Configuration options set manually in code take precedence over environment variables, and
environment variables take precedence over configuration options set using the `IConfiguration` system.
Configuration options set manually in code take precedence over environment variables, and environment variables take precedence over configuration options set using the `IConfiguration` system.

### Environment variables

EDOT .NET can be configured using environment variables. This is a cross-platform way to configure EDOT .NET and is especially
useful in containerized environments.
You can configure EDOT .NET using environment variables. This is a cross-platform way to configure EDOT .NET and is especially useful in containerized environments.

Environment variables are read at startup and can be used to configure EDOT .NET. For details of the various EDOT-specific options
available and their corresponding environment variable names, see [Configuration options](#configuration-options).
Environment variables are read at startup and can be used to configure EDOT .NET. For details of the various EDOT-specific options available and their corresponding environment variable names, see [Configuration options](#configuration-options).

All OpenTelemetry environment variables from the upstream SDK may also be used to configure the SDK behavior for features
such as resources, samples and exporters.
All OpenTelemetry environment variables from the upstream SDK may also be used to configure the SDK behavior for features such as resources, samples and exporters.

### IConfiguration integration

In applications that use the [".NET generic host"](https://learn.microsoft.com/dotnet/core/extensions/generic-host), such as
[ASP.NET Core](https://learn.microsoft.com/aspnet/core/introduction-to-aspnet-core) and
[worker services](https://learn.microsoft.com/dotnet/core/extensions/workers), EDOT .NET can be configured using the `IConfiguration` integration.
In applications that use the [".NET generic host"](https://learn.microsoft.com/dotnet/core/extensions/generic-host), such as [ASP.NET Core](https://learn.microsoft.com/aspnet/core/introduction-to-aspnet-core) and [worker services](https://learn.microsoft.com/dotnet/core/extensions/workers), EDOT .NET can be configured using the `IConfiguration` integration.

When using an `IHostApplicationBuilder` in modern ASP.NET Core applications, the `AddElasticOpenTelemetry` extension method
enables EDOT .NET and configuration from `IHostApplicationBuilder.Configuration` is passed in automatically.
When using an `IHostApplicationBuilder` in modern ASP.NET Core applications, the `AddElasticOpenTelemetry` extension method turns on EDOT .NET and configuration from `IHostApplicationBuilder.Configuration` is passed in automatically. For example:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand All @@ -53,9 +47,7 @@ var builder = WebApplication.CreateBuilder(args);
builder.AddElasticOpenTelemetry();
```

By default, at this stage, the configuration will be populated from the default configuration sources,
including the `appsettings.json` file(s) and command-line arguments. You may use these sources to define
the configuration for the Elastic Distribution of OpenTelemetry .NET.
By default, at this stage the configuration is populated from the default configuration sources, including the `appsettings.json` file(s) and command-line arguments. You can use these sources to define the configuration for the Elastic Distribution of OpenTelemetry .NET.

For example, you can define the configuration for the Elastic Distribution of OpenTelemetry .NET in the `appsettings.json` file:

Expand All @@ -70,14 +62,12 @@ For example, you can define the configuration for the Elastic Distribution of Op
```

:::{note}
This example sets the file log directory to `C:\Logs` which enables diagnostic file logging.
This example sets the file log directory to `C:\Logs` which activates diagnostic file logging.
:::

Configuration parsed from the `Elastic:OpenTelemetry` section of the `IConfiguration` instance will be
bound to the `ElasticOpenTelemetryOptions` instance used to configure EDOT .NET.
Configuration parsed from the `Elastic:OpenTelemetry` section of the `IConfiguration` instance is bound to the `ElasticOpenTelemetryOptions` instance used to configure EDOT .NET.

In situations (such as console applications) where the application may not depend on the hosting APIs, but
uses the dependency injection APIs instead, an `IConfiguration` instance can be passed in manually.
In situations where the application might not depend on the hosting APIs, but uses the dependency injection APIs instead, an `IConfiguration` instance can be passed in manually. This is usually the case with console applications. For example:

```csharp
var configuration = new ConfigurationBuilder()
Expand All @@ -91,18 +81,15 @@ var services = new ServiceCollection();
services.AddElasticOpenTelemetry(configuration);
```

To learn more about the Microsoft configuration system, see
[Configuration in ASP.NET Core](https://learn.microsoft.com/aspnet/core/fundamentals/configuration).
To learn more about the Microsoft configuration system, see [Configuration in ASP.NET Core](https://learn.microsoft.com/aspnet/core/fundamentals/configuration).

### Manual configuration

In all other scenarios, you can configure EDOT .NET manually in code.

Create an instance of `ElasticOpenTelemetryOptions` and pass it to an overload of the `WithElasticDefaults` extension methods
available on the `IHostApplicationBuilder`, the `IServiceCollection` and the specific signal providers such as `TracerProviderBuilder`.
Create an instance of `ElasticOpenTelemetryOptions` and pass it to an overload of the `WithElasticDefaults` extension methods available on the `IHostApplicationBuilder`, the `IServiceCollection` and the specific signal providers such as `TracerProviderBuilder`.

For example, in traditional console applications, you can configure the
Elastic Distribution of OpenTelemetry .NET like this:
For example, in traditional console applications, you can configure the Elastic Distribution of OpenTelemetry .NET like this:

```csharp
using OpenTelemetry;
Expand All @@ -125,8 +112,7 @@ using var sdk = OpenTelemetrySdk.Create(builder => builder

## Configuration options

Because the Elastic Distribution of OpenTelemetry .NET (EDOT .NET) is an extension of the
[OpenTelemetry .NET SDK](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation), it supports both:
Because the Elastic Distribution of OpenTelemetry .NET (EDOT .NET) is an extension of the [OpenTelemetry .NET SDK](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation), it supports both:

* General OpenTelemetry SDK configuration options
* Elastic-specific configuration options that are only available when using EDOT .NET
Expand All @@ -141,12 +127,10 @@ EDOT .NET supports the following Elastic-specific options.

#### `LogDirectory`

* _Type_: String
* _Default_: `string.Empty`
* Type: String
* Default: `string.Empty`

A string specifying the output directory where the Elastic Distribution of OpenTelemetry .NET will write diagnostic log files.
When not provided, no file logging will occur. Each new .NET process will create a new log file in the
specified directory.
A string specifying the output directory where the Elastic Distribution of OpenTelemetry .NET writes diagnostic log files. When not provided, no file logging occurs. Each new .NET process creates a new log file in the specified directory.

| Configuration method | Key |
|---|---|
Expand All @@ -155,12 +139,10 @@ specified directory.

#### `LogLevel`

* _Type_: String
* _Default_: `Information`
* Type: String
* Default: `Information`

Sets the logging level for EDOT .NET.

Valid options: `Critical`, `Error`, `Warning`, `Information`, `Debug`, `Trace` and `None` (`None` disables the logging).
Sets the logging level for EDOT .NET. Valid options are `Critical`, `Error`, `Warning`, `Information`, `Debug`, `Trace`, and `None`. `None` disables the logging.

| Configuration method | Key |
|---|---|
Expand All @@ -169,14 +151,12 @@ Valid options: `Critical`, `Error`, `Warning`, `Information`, `Debug`, `Trace` a

#### `LogTargets`

* _Type_: String
* _Default_: `Information`
* Type: String
* Default: `Information`

A comma-separated list of targets for log output. When global logging is unconfigured (a log directory or
target is not specified) this defaults to `none`. When the instrumented application is running
within a container, this defaults to direct logs to `stdout`. Otherwise, defaults to `file`.
A comma-separated list of targets for log output. When global logging is not configured (a log directory or target is not specified) this defaults to `none`. When the instrumented application is running within a container, this defaults to direct logs to `stdout`. Otherwise defaults to `file`.

Valid options: `file`, `stdout` and `none` (`None` disables the logging).
Valid options are `file`, `stdout` and `none`. `None` disables the logging.

| Configuration method | Key |
|---|---|
Expand All @@ -185,8 +165,8 @@ Valid options: `file`, `stdout` and `none` (`None` disables the logging).

#### `SkipOtlpExporter`

* _Type_: Bool
* _Default_: `false`
* Type: Bool
* Default: `false`

Allows EDOT .NET to be used with its defaults, but without enabling the export of telemetry data to
an OTLP endpoint. This can be useful when you want to test applications without sending telemetry data.
Expand All @@ -198,12 +178,10 @@ an OTLP endpoint. This can be useful when you want to test applications without

#### `SkipInstrumentationAssemblyScanning`

* _Type_: Bool
* _Default_: `false`
* Type: Bool
* Default: `false`

Allows EDOT .NET to be used without the instrumentation assembly scanning feature enabled. This
prevents the automatic registration of instrumentation from referenced [OpenTelemetry contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib)
instrumentation packages.
Allows EDOT .NET to be used without the instrumentation assembly scanning feature turned on. This prevents the automatic registration of instrumentation from referenced [OpenTelemetry contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) instrumentation packages.

| Configuration method | Key |
|---|---|
Expand Down
1 change: 1 addition & 0 deletions docs/reference/edot-sdks/dotnet/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
navigation_title: EDOT .NET
description: The Elastic Distribution of OpenTelemetry (EDOT) .NET provides an extension of the OpenTelemetry SDK for .NET, configured for the best experience with Elastic Observability.
applies_to:
stack:
serverless:
Expand Down
Loading