-
Notifications
You must be signed in to change notification settings - Fork 123
[FileBasedConfiguration] Instrumentation Configuration #4492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 20 commits
10d1342
a5ac594
9038aef
bde4ef5
bb63fe8
0eab3d1
255c2e5
b9833e3
9bf9d1e
bffc31d
ee5baf5
4eabeac
a929a87
f5f1396
241ea19
548f7e4
2c36af4
65692bc
2b1b8dd
8e7658e
0ec2986
ea047c0
554d0b2
138a943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,98 @@ propagator: | |
| composite_list: ${OTEL_PROPAGATORS} | ||
| ``` | ||
|
|
||
| ## Instrumentation Configuration | ||
|
|
||
| You can configure traces, metrics, and logs instrumentations. | ||
| For more details and updates, see: [Instrumentation list and documentation](config.md#instrumentations) | ||
| To disable a instrumentation, comment out or remove its corresponding entry. | ||
|
|
||
| ``` yaml | ||
| instrumentation/development: | ||
zacharycmontoya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| dotnet: | ||
| traces: | ||
| aspnet: # ASP.NET (.NET Framework) MVC/WebApi [Framework only] | ||
|
||
| aspnetcore: # ASP.NET Core [Core only] | ||
| azure: # Azure SDK [Core & Framework] | ||
| elasticsearch: # Elastic.Clients.Elasticsearch [Core & Framework] | ||
| elastictransport: # Elastic.Transport (>=0.4.16) [Core & Framework] | ||
| entityframeworkcore: # Entity Framework Core (>=6.0.12) [Core only] | ||
| graphql: # GraphQL (>=7.5.0) [Core only] | ||
| grpcnetclient: # Grpc.Net.Client (>=2.52.0 & <3.0.0) [Core & Framework] | ||
| httpclient: # System.Net.Http.HttpClient [Core & Framework] | ||
| kafka: # Confluent.Kafka (>=1.4.0 & <3.0.0) [Core & Framework] | ||
| masstransit: # MassTransit (>=8.0.0) [Core only] | ||
| mongodb: # MongoDB.Driver (>=2.7.0 <4.0.0) [Core & Framework] | ||
| mysqlconnector: # MySqlConnector (>=2.0.0) [Core only] | ||
| mysqldata: # MySql.Data (>=8.1.0) [Core only] | ||
| npgsql: # Npgsql (>=6.0.0) [Core only] | ||
| nservicebus: # NServiceBus (>=8.0.0 & <10.0.0) [Core & Framework] | ||
| oraclemda: # Oracle.ManagedDataAccess (>=23.4.0) [Core only] | ||
| rabbitmq: # RabbitMQ.Client (>=6.0.0) [Core & Framework] | ||
| quartz: # Quartz (>=3.4.0, not supported < .NET Framework 4.7.2) | ||
| sqlclient: # Microsoft.Data.SqlClient & System.Data.SqlClient [Core & Framework] | ||
| stackexchangeredis: # StackExchange.Redis (>=2.6.122 & <3.0.0) [Core only] | ||
| wcfclient: # WCF Client [Core & Framework] | ||
| wcfservice: # WCF Service [Framework only] | ||
| metrics: | ||
| aspnet: # ASP.NET metrics [Framework only] | ||
| aspnetcore: # ASP.NET Core metrics [Core only] | ||
| httpclient: # HttpClient metrics [Core & Framework] | ||
| netruntime: # .NET Runtime metrics [Core only] | ||
| nservicebus: # NServiceBus metrics [Core & Framework] | ||
| process: # Process metrics [Core & Framework] | ||
| sqlclient: # SQL Client metrics [Core & Framework] | ||
| logs: | ||
| ilogger: # Microsoft.Extensions.Logging (>=9.0.0) [Core & Framework] | ||
| log4net: # log4net (>=2.0.13 && <4.0.0) [Core & Framework] | ||
| ``` | ||
|
|
||
| ## Instrumentation options | ||
|
|
||
| ``` yaml | ||
| instrumentation/development: | ||
| dotnet: | ||
| traces: | ||
| graphql: | ||
| # Whether the GraphQL instrumentation can pass raw queries through the graphql.document attribute. Queries might contain sensitive information. | ||
| # Default is false | ||
| set_document: false | ||
| oraclemda: | ||
| # Whether the Oracle Client instrumentation can pass SQL statements through the db.statement attribute. Queries might contain sensitive information. If set to false, db.statement is recorded only for executing stored procedures. | ||
| # Default is false | ||
| set_db_statement_for_text: false | ||
| sqlclient: | ||
| # Whether the SQL Client instrumentation can pass SQL statements through the db.statement attribute. Queries might contain sensitive information. If set to false, db.statement is recorded only for executing stored procedures. | ||
| # Not supported on .NET Framework for System.Data.SqlClient. | ||
| # Default is false | ||
| set_db_statement_for_text: false | ||
|
||
| aspnet: | ||
| # A comma-separated list of HTTP header names. ASP.NET instrumentations will capture HTTP request header values for all configured header names. | ||
Kielek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| capture_request_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| # A comma-separated list of HTTP header names. ASP.NET instrumentations will capture HTTP response header values for all configured header names. | ||
| capture_response_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| aspnetcore: | ||
| # A comma-separated list of HTTP header names. ASP.NET Core instrumentations will capture HTTP request header values for all configured header names. | ||
| capture_request_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| # A comma-separated list of HTTP header names. ASP.NET Core instrumentations will capture HTTP response header values for all configured header names. | ||
| capture_response_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| httpclient: | ||
| # A comma-separated list of HTTP header names. HTTP Client instrumentations will capture HTTP request header values for all configured header names. | ||
| capture_request_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| # A comma-separated list of HTTP header names. HTTP Client instrumentations will capture HTTP response header values for all configured header names. | ||
| capture_response_headers: "X-Key,X-Custom-Header,X-Header-Example" | ||
| grpcnetclient: | ||
| # A comma-separated list of gRPC metadata names. Grpc.Net.Client instrumentations will capture gRPC request metadata values for all configured metadata names. | ||
| capture_request_metadata: "X-Key,X-Custom-Header,X-Header-Example" | ||
| # A comma-separated list of gRPC metadata names. Grpc.Net.Client instrumentations will capture gRPC response metadata values for all configured metadata names. | ||
| capture_response_metadata: "X-Key,X-Custom-Header,X-Header-Example" | ||
| logs: | ||
| log4net: | ||
| # Logs bridge is disabled by default | ||
| # More info about log4net bridge can be found at https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/main/docs/log4net-bridge.md | ||
| bridge_enabled: true | ||
| ``` | ||
|
|
||
| ### Configuration based instrumentation | ||
|
|
||
| Documentation for configuration based instrumentation can be found in [nocode-instrumentation.md](nocode-instrumentation.md). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration.Parser; | ||
| using Vendors.YamlDotNet.Serialization; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration; | ||
|
|
||
| [EmptyObjectOnEmptyYaml] | ||
| internal class CaptureHeadersConfiguration | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets a comma-separated list of HTTP header names. | ||
| /// Instrumentations will capture HTTP request header values for all configured header names. | ||
| /// </summary> | ||
| [YamlMember(Alias = "capture_request_headers")] | ||
| public string? CaptureRequestHeaders { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a comma-separated list of HTTP header names. | ||
| /// Instrumentations will capture HTTP response header values for all configured header names. | ||
| /// </summary> | ||
| [YamlMember(Alias = "capture_response_headers")] | ||
| public string? CaptureResponseHeaders { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration.Parser; | ||
| using Vendors.YamlDotNet.Serialization; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration; | ||
|
|
||
| [EmptyObjectOnEmptyYaml] | ||
| internal class CaptureMetadataConfiguration | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets a comma-separated list of gRPC metadata names. | ||
| /// Grpc.Net.Client instrumentations will capture gRPC request metadata values for all configured metadata names. | ||
| /// </summary> | ||
| [YamlMember(Alias = "capture_request_metadata")] | ||
| public string? CaptureRequestMetadata { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a comma-separated list of gRPC metadata names. | ||
| /// Grpc.Net.Client instrumentations will capture gRPC response metadata values for all configured metadata names. | ||
| /// </summary> | ||
| [YamlMember(Alias = "capture_response_metadata")] | ||
| public string? CaptureResponseMetadata { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using Vendors.YamlDotNet.Serialization; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration; | ||
|
|
||
| internal class DotNetInstrumentation | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the configuration for .NET traces instrumentation. | ||
| /// </summary> | ||
| [YamlMember(Alias = "traces")] | ||
| public DotNetTraces? Traces { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the configuration for .NET metrics instrumentation. | ||
| /// </summary> | ||
| [YamlMember(Alias = "metrics")] | ||
| public DotNetMetrics? Metrics { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the configuration for .NET logs instrumentation. | ||
| /// </summary> | ||
| [YamlMember(Alias = "logs")] | ||
| public DotNetLogs? Logs { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using Vendors.YamlDotNet.Serialization; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration; | ||
|
|
||
| internal class DotNetLogs | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the ILogger logs instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "ilogger")] | ||
| public object? ILogger { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the Log4Net logs instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "log4net")] | ||
| public Log4NetBridgeEnabled? Log4Net { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Returns the list of enabled log instrumentations. | ||
| /// </summary> | ||
| public IReadOnlyList<LogInstrumentation> GetEnabledInstrumentations() | ||
| { | ||
| var result = new List<LogInstrumentation>(); | ||
|
|
||
| if (ILogger != null) | ||
| { | ||
| result.Add(LogInstrumentation.ILogger); | ||
| } | ||
|
|
||
| if (Log4Net != null) | ||
| { | ||
| result.Add(LogInstrumentation.Log4Net); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
| } |
zacharycmontoya marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using System.Reflection; | ||
| using Vendors.YamlDotNet.Serialization; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration; | ||
|
|
||
| internal class DotNetMetrics | ||
| { | ||
| #if NETFRAMEWORK | ||
| /// <summary> | ||
| /// Gets or sets the ASP.NET metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "aspnet")] | ||
| public object? AspNet { get; set; } | ||
| #endif | ||
|
|
||
| #if NET | ||
| /// <summary> | ||
| /// Gets or sets the ASP.NET Core metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "aspnetcore")] | ||
| public object? AspNetCore { get; set; } | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the HttpClient metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "httpclient")] | ||
| public object? HttpClient { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the .NET runtime metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "netruntime")] | ||
| public object? NetRuntime { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the NServiceBus metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "nservicebus")] | ||
| public object? NServiceBus { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the process metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "process")] | ||
| public object? Process { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the SqlClient metrics instrumentation configuration. | ||
| /// </summary> | ||
| [YamlMember(Alias = "sqlclient")] | ||
| public object? SqlClient { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Returns the list of enabled metric instrumentations. | ||
| /// </summary> | ||
| public IReadOnlyList<MetricInstrumentation> GetEnabledInstrumentations() | ||
| { | ||
| var enabled = new List<MetricInstrumentation>(); | ||
| var properties = typeof(DotNetMetrics).GetProperties(BindingFlags.Instance | BindingFlags.Public); | ||
|
|
||
| foreach (var prop in properties) | ||
| { | ||
| var value = prop.GetValue(this); | ||
| if (value != null) | ||
| { | ||
| if (Enum.TryParse<MetricInstrumentation>(prop.Name, out var instrumentation)) | ||
| { | ||
| enabled.Add(instrumentation); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return enabled; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.