Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bcedd1c
[File-Based] Add traces exporter configuration
ysolomchenko Sep 23, 2025
00dda04
[FileBased] Add traces Tests
ysolomchenko Sep 23, 2025
d6ec27a
[File-Based] Add Batch options
ysolomchenko Sep 29, 2025
a64259e
Merge branch 'main' into FileBasedConfiguration-Traces
ysolomchenko Sep 30, 2025
d35c375
[File-Based] Add Tracer Provider Docs
ysolomchenko Sep 30, 2025
bee1a0c
fix docs
ysolomchenko Sep 30, 2025
44bc7f1
Merge branch 'main' into FileBasedConfiguration-Traces
ysolomchenko Oct 13, 2025
afd0ece
Add note about multiple processor support
ysolomchenko Oct 13, 2025
6ad3fbc
fix no_code
ysolomchenko Oct 13, 2025
1e188bb
Merge branch 'main' into FileBasedConfiguration-Traces
Kielek Oct 14, 2025
56eb56c
remove redundant usings
Kielek Oct 14, 2025
89c9f2b
refactor tests
ysolomchenko Oct 14, 2025
90590b8
[File Based] accept multiple processors
ysolomchenko Oct 15, 2025
f24901e
update tests
ysolomchenko Oct 16, 2025
de5d74f
update docs
ysolomchenko Oct 16, 2025
ea0f538
Merge branch 'main' into FileBasedConfiguration-Traces
ysolomchenko Oct 16, 2025
28eb9cd
fix
ysolomchenko Oct 17, 2025
ba3800b
Merge branch 'FileBasedConfiguration-Traces' of https://github.com/ys…
ysolomchenko Oct 17, 2025
4820495
fix
ysolomchenko Oct 17, 2025
1416380
Merge branch 'main' into FileBasedConfiguration-Traces
ysolomchenko Oct 20, 2025
21b860a
fix var name
ysolomchenko Oct 20, 2025
5276b25
fix test
ysolomchenko Oct 20, 2025
0faa54f
Separate configuration for batch/simple processors
Kielek Oct 23, 2025
ff00c98
Validate configuration while configuring exporters
Kielek Oct 23, 2025
4b2b887
Merge branch 'main' into FileBasedConfiguration-Traces
Kielek Oct 23, 2025
3f1651d
Merge branch 'main' into FileBasedConfiguration-Traces
Kielek Oct 24, 2025
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
56 changes: 56 additions & 0 deletions docs/file-based-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,62 @@ fail_fast: false
flush_on_unhandled_exception: false
```

### Tracer Provider Configuration

``` yaml
tracer_provider:
processors:
# Configure a batch span processor.
# Support for multiple processors is not available yet (which does not comply with the specification).
batch:
# Configure delay interval (in milliseconds) between two consecutive exports.
# Value must be non-negative.
# If omitted or null, 5000 is used.
schedule_delay: 5000
# Configure maximum allowed time (in milliseconds) to export data.
# Value must be non-negative. A value of 0 indicates no limit (infinity).
# If omitted or null, 30000 is used.
export_timeout: 30000
# Configure maximum queue size. Value must be positive.
# If omitted or null, 2048 is used.
max_queue_size: 2048
# Configure maximum batch size. Value must be positive.
# If omitted or null, 512 is used.
max_export_batch_size: 512
# Configure exporters.
exporter:
# Configure the OTLP with HTTP transport exporter to enable it.
otlp_http:
# Configure endpoint, including the trace specific path.
# If omitted or null, http://localhost:4318/v1/traces is used
endpoint: http://localhost:4318/v1/traces
# Configure max time (in milliseconds) to wait for each export.
# Value must be non-negative. A value of 0 indicates no limit (infinity).
# If omitted or null, 10000 is used.
timeout: 10000
# Configure headers. Entries have higher priority than entries from .headers_list.
# If an entry's .value is null, the entry is ignored.
headers:
- name: api-key
value: "1234"
# Configure headers. Entries have lower priority than entries from .headers.
# The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details.
# If omitted or null, no headers are added.
headers_list: ${OTEL_EXPORTER_OTLP_TRACES_HEADERS}
# Configure the OTLP with gRPC transport exporter to enable it.
otlp_grpc:
# Configuration otlp_grpc is the same as otlp_http.
# if otlp_http is used it will override otlp_grpc.
# On .NET Framework, the grpc OTLP exporter protocol is not supported.
# Configure the zipkin exporter to enable it.
zipkin:
# Configure endpoint.
# If omitted or null, http://localhost:9411/api/v2/spans is used.
endpoint: http://localhost:9411/api/v2/spans
# Add the console exporter to enable it.
console:
```

### Resource Configuration

You can configure resource attributes directly in YAML or via the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.CompilerServices;
using OpenTelemetry.AutoInstrumentation.Loading;
using OpenTelemetry.AutoInstrumentation.Plugins;
using OpenTelemetry.Exporter;
using OpenTelemetry.Trace;

namespace OpenTelemetry.AutoInstrumentation.Configurations;
Expand Down Expand Up @@ -92,7 +93,7 @@ private static TracerProviderBuilder SetExporter(this TracerProviderBuilder buil
{
builder = traceExporter switch
{
TracesExporter.Zipkin => Wrappers.AddZipkinExporter(builder, pluginManager),
TracesExporter.Zipkin => Wrappers.AddZipkinExporter(builder, settings, pluginManager),
TracesExporter.Otlp => Wrappers.AddOtlpExporter(builder, settings, pluginManager),
TracesExporter.Console => Wrappers.AddConsoleExporter(builder, pluginManager),
_ => throw new ArgumentOutOfRangeException($"Traces exporter '{traceExporter}' is incorrect")
Expand Down Expand Up @@ -218,9 +219,16 @@ public static TracerProviderBuilder AddConsoleExporter(TracerProviderBuilder bui
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static TracerProviderBuilder AddZipkinExporter(TracerProviderBuilder builder, PluginManager pluginManager)
public static TracerProviderBuilder AddZipkinExporter(TracerProviderBuilder builder, TracerSettings settings, PluginManager pluginManager)
{
return builder.AddZipkinExporter(pluginManager.ConfigureTracesOptions);
return builder.AddZipkinExporter(options =>
{
// Copy Auto settings to SDK settings
settings.BatchProcessorConfig?.CopyTo(options.BatchExportProcessorOptions);
settings.ZipkinSettings?.CopyTo(options);

pluginManager.ConfigureTracesOptions(options);
});
}

[MethodImpl(MethodImplOptions.NoInlining)]
Expand All @@ -229,6 +237,7 @@ public static TracerProviderBuilder AddOtlpExporter(TracerProviderBuilder builde
return builder.AddOtlpExporter(options =>
{
// Copy Auto settings to SDK settings
settings.BatchProcessorConfig?.CopyTo(options.BatchExportProcessorOptions);
settings.OtlpSettings?.CopyTo(options);

pluginManager.ConfigureTracesOptions(options);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using OpenTelemetry.Exporter;
using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class BatchProcessorConfig
{
/// <summary>
/// Gets or sets the delay interval (in milliseconds) between two consecutive exports.
/// Value must be non-negative.
/// If omitted or null, 5000 is used.
/// </summary>
[YamlMember(Alias = "schedule_delay")]
public int ScheduleDelay { get; set; } = 5000;

/// <summary>
/// Gets or sets the maximum allowed time (in milliseconds) to export data.
/// Value must be non-negative. A value of 0 indicates no limit (infinity).
/// If omitted or null, 30000 is used.
/// </summary>
[YamlMember(Alias = "export_timeout")]
public int ExportTimeout { get; set; } = 30000;

/// <summary>
/// Gets or sets the maximum queue size.
/// Value must be positive.
/// If omitted or null, 2048 is used.
/// </summary>
[YamlMember(Alias = "max_queue_size")]
public int MaxQueueSize { get; set; } = 2048;

/// <summary>
/// Gets or sets the maximum batch size.
/// Value must be positive.
/// If omitted or null, 512 is used.
/// </summary>
[YamlMember(Alias = "max_export_batch_size")]
public int MaxExportBatchSize { get; set; } = 512;

/// <summary>
/// Gets or sets the exporters.
/// </summary>
[YamlMember(Alias = "exporter")]
public ExporterConfig? Exporter { get; set; }

public void CopyTo(BatchExportProcessorOptions<Activity> options)
{
options.ScheduledDelayMilliseconds = ScheduleDelay;
options.ExporterTimeoutMilliseconds = ExportTimeout;
options.MaxQueueSize = MaxQueueSize;
options.MaxExportBatchSize = MaxExportBatchSize;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class ExporterConfig
{
/// <summary>
/// Gets or sets the OTLP HTTP exporter configuration.
/// </summary>
[YamlMember(Alias = "otlp_http")]
public OtlpHttpExporterConfig? OtlpHttp { get; set; }

/// <summary>
/// Gets or sets the OTLP gRPC exporter configuration.
/// </summary>
[YamlMember(Alias = "otlp_grpc")]
public OtlpGrpcExporterConfig? OtlpGrpc { get; set; }

/// <summary>
/// Gets or sets the Zipkin exporter configuration.
/// </summary>
[YamlMember(Alias = "zipkin")]
public ZipkinExporterConfig? Zipkin { get; set; }

/// <summary>
/// Gets or sets the Prometheus exporter configuration.
/// </summary>
[YamlMember(Alias = "prometheus")]
public object? Prometheus { get; set; }

/// <summary>
/// Gets or sets the console exporter configuration.
/// </summary>
[YamlMember(Alias = "console")]
public object? Console { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class Header
{
/// <summary>
/// Gets or sets the name of the header.
/// </summary>
[YamlMember(Alias = "name")]
public string? Name { get; set; }

/// <summary>
/// Gets or sets the value of the header.
/// </summary>
[YamlMember(Alias = "value")]
public string? Value { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class OtlpGrpcExporterConfig
{
/// <summary>
/// Gets or sets the endpoint for the OTLP gRPC exporter.
/// Configure endpoint.
/// If omitted or null, http://localhost:4317 is used.
/// </summary>
[YamlMember(Alias = "endpoint")]
public string? Endpoint { get; set; }

/// <summary>
/// Gets or sets the headers for the exporter.
/// Configure headers. Entries have higher priority than entries from <c>headers_list</c>.
/// If an entry's value is null, the entry is ignored.
/// </summary>
[YamlMember(Alias = "headers")]
public List<Header>? Headers { get; set; }

/// <summary>
/// Gets or sets the headers list for the exporter.
/// Configure headers. Entries have lower priority than entries from <c>headers</c>.
/// The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS.
/// If omitted or null, no headers are added.
/// </summary>
[YamlMember(Alias = "headers_list")]
public string? HeadersList { get; set; }

/// <summary>
/// Gets or sets the maximum time (in milliseconds) to wait for each export.
/// Value must be non-negative. A value of 0 indicates no limit (infinity).
/// If omitted or null, 10000 is used.
/// </summary>
[YamlMember(Alias = "timeout")]
public int? Timeout { get; set; } = 10000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class OtlpHttpExporterConfig
{
/// <summary>
/// Gets or sets the endpoint for the OTLP HTTP exporter.
/// Configure endpoint.
/// If omitted or null, http://localhost:4318 is used.
/// </summary>
[YamlMember(Alias = "endpoint")]
public string? Endpoint { get; set; }

/// <summary>
/// Gets or sets the headers for the exporter.
/// Configure headers. Entries have higher priority than entries from <c>headers_list</c>.
/// If an entry's value is null, the entry is ignored.
/// </summary>
[YamlMember(Alias = "headers")]
public List<Header>? Headers { get; set; }

/// <summary>
/// Gets or sets the headers list for the exporter.
/// Configure headers. Entries have lower priority than entries from <c>headers</c>.
/// The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS.
/// If omitted or null, no headers are added.
/// </summary>
[YamlMember(Alias = "headers_list")]
public string? HeadersList { get; set; }

/// <summary>
/// Gets or sets the maximum time (in milliseconds) to wait for each export.
/// Value must be non-negative. A value of 0 indicates no limit (infinity).
/// If omitted or null, 10000 is used.
/// </summary>
[YamlMember(Alias = "timeout")]
public int? Timeout { get; set; } = 10000;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class TracerProviderConfiguration
{
[YamlMember(Alias = "processors")]
public Dictionary<string, BatchProcessorConfig> Processors { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;
Expand All @@ -23,6 +24,14 @@ internal class YamlConfiguration
[YamlMember(Alias = "resource")]
public ResourceConfiguration? Resource { get; set; }

/// <summary>
/// Gets or sets the tracer provider configuration.
/// Configure tracer provider.
/// If omitted, a noop tracer provider is used.
/// </summary>
[YamlMember(Alias = "tracer_provider")]
public TracerProviderConfiguration? TracerProvider { get; set; }

/// <summary>
/// Gets or sets the text map context propagator configuration.
/// If omitted, a noop propagator is used.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.Exporter;
using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class ZipkinExporterConfig
{
/// <summary>
/// Gets or sets the Zipkin endpoint URL to which spans are exported.
/// If omitted or null, the default value "http://localhost:9411/api/v2/spans" is used.
/// </summary>
[YamlMember(Alias = "endpoint")]
public string Endpoint { get; set; } = "http://localhost:9411/api/v2/spans";

public void CopyTo(ZipkinExporterOptions options)
{
options.Endpoint = new Uri(Endpoint);
}
}
Loading
Loading