From 0c8d6338950077a94e3e70d4be1e5ccce110edba Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Mar 2024 15:23:24 -0700 Subject: [PATCH 01/15] Update OtlpExporter README for UseOtlpExporter & OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY additions. --- ...nTelemetryBuilderOtlpExporterExtensions.cs | 2 +- .../README.md | 244 +++++++++++++----- 2 files changed, 183 insertions(+), 63 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs index c0368cd4ae1..d500e5c997d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs @@ -26,7 +26,7 @@ public static class OpenTelemetryBuilderOtlpExporterExtensions /// tracing. /// The exporter registered by this method will be added as the last /// processor in the pipeline established for logging and tracing. - /// This method can only be called once. Subsequent calls will results + /// This method can only be called once. Subsequent calls will result /// in a being thrown. /// This method cannot be called in addition to signal-specific /// AddOtlpExporter methods. If this method is called signal-specific diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index a670487e5f7..7ae8904712e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -112,7 +112,64 @@ runnable example. ## Enable OTLP Exporter for all signals -Content coming soon. +A cross-cutting extension was added in v1.8.0 to simplify registration of the +OTLP exporter for all signals (logs, metrics, and tracing). + +> [!NOTE] +> The cross cutting extension is currently only available when using the + `AddOpenTelemetry` extension in the + [OpenTelemetry.Extensions.Hosting](../OpenTelemetry.Extensions.Hosting/README.md) + package. + +```csharp +appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter(); +``` + +The `UseOtlpExporter` has the following behaviors: + +* Calling `UseOtlpExporter` automatically enables logging, metrics, and tracing. + Calls to `WithLogging`, `WithTracing`, and/or `WithLogging` are NOT required + when using `UseOtlpExporter` however only telemetry which has been enabled + (typically via `AddSource` inside of `WithTracing` or `AddMeter` inside of + `WithMetrics`) will be exported. + +* The exporter registered by `UseOtlpExporter` will be added as the last + processor in the pipeline established for logging and tracing. + +* `UseOtlpExporter` can only be called once. Subsequent calls will result in a + `NotSupportedException` being thrown. + +* `UseOtlpExporter` cannot be called in addition to signal-specific + `AddOtlpExporter` methods. If `UseOtlpExporter` is called signal-specific + `AddOtlpExporter` calls will result in a `NotSupportedException` being thrown. + +### Configuring signals when using UseOtlpExporter + +`UseOtlpExporter` supports the full set of [environment +variables](#environment-variables) listed below including the signal-specific +overrides and users are encouraged to use this mechanism to configure their +exporters. + +> [!NOTE] +> In OpenTelemetry .NET environment variable keys are retrieved using + `IConfiguration` which means they may be set using other mechanisms such as + defined in appSettings.json or specified on the command-line. + +An `UseOtlpExporter` overload is provided which may be used to set the protocol +and base endpoint but no other options are currently exposed: + +```csharp +appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter( + OtlpExportProtocol.HttpProtobuf, + new Uri("http://otlp_exporter_base_address/")); +``` + +> [!NOTE] +> When the protocol is set to `OtlpExportProtocol.HttpProtobuf` a + signal-specific path will be appended automatically to the base endpoint when + constructing exporters. ## Configuration @@ -275,64 +332,121 @@ appBuilder.Services.Configure( ## Environment Variables -The following environment variables can be used to override the default -values of the `OtlpExporterOptions` -(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md)). - -| Environment variable | `OtlpExporterOptions` property | -| ------------------------------| --------------------------------------| -| `OTEL_EXPORTER_OTLP_ENDPOINT` | `Endpoint` | -| `OTEL_EXPORTER_OTLP_HEADERS` | `Headers` | -| `OTEL_EXPORTER_OTLP_TIMEOUT` | `TimeoutMilliseconds` | -| `OTEL_EXPORTER_OTLP_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| - -The following environment variables can be used to override the default values -for `BatchExportProcessorOptions` in case of `OtlpTraceExporter` (following the -[OpenTelemetry -specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor)) - -| Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property | -| ---------------------------------| ------------------------------------------------------------| -| `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | -| `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | -| `OTEL_BSP_MAX_QUEUE_SIZE` | `MaxQueueSize` | -| `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | - -The following environment variables can be used to override the default values -for `BatchExportProcessorOptions` in case of `OtlpLogExporter` (following the -[OpenTelemetry -specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor)) - -| Environment variable | `LogRecordExportProcessorOptions.BatchExportProcessorOptions` property | -| ----------------------------------| ------------------------------------------------------------------------| -| `OTEL_BLRP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | -| `OTEL_BLRP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | -| `OTEL_BLRP_MAX_QUEUE_SIZE` | `MaxQueueSize` | -| `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | - -The following environment variables can be used to override the default values -of the `PeriodicExportingMetricReaderOptions` (following the [OpenTelemetry -specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.12.0/specification/sdk-environment-variables.md#periodic-exporting-metricreader). - -| Environment variable | `PeriodicExportingMetricReaderOptions` property | -| ----------------------------------------------------| ------------------------------------------------| -| `OTEL_METRIC_EXPORT_INTERVAL` | `ExportIntervalMilliseconds` | -| `OTEL_METRIC_EXPORT_TIMEOUT` | `ExportTimeoutMilliseconds` | - -| Environment variable | `MetricReaderOptions` property | -| ----------------------------------------------------| ------------------------------------------------| -| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | `PeriodicExportingMetricReaderOptions` | - -The following environment variables can be used to override the default -values of the attribute limits -(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.25.0/specification/configuration/sdk-environment-variables.md#attribute-limits)). +### Exporter configuration + +The [OpenTelemetry +Specification](https://github.com/open-telemetry/opentelemetry-specification/) +defines environment variables which can be used to configure the [OTLP +exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md) +and its associated processor +([logs](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor) +& +[traces](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor)) +or reader +([metrics](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#periodic-exporting-metricreader)). + +* All signals + + The following environment variables can be used to override the default + values of the `OtlpExporterOptions`: + + | Environment variable | `OtlpExporterOptions` property | + | ------------------------------| --------------------------------------| + | `OTEL_EXPORTER_OTLP_ENDPOINT` | `Endpoint` | + | `OTEL_EXPORTER_OTLP_HEADERS` | `Headers` | + | `OTEL_EXPORTER_OTLP_TIMEOUT` | `TimeoutMilliseconds` | + | `OTEL_EXPORTER_OTLP_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| + +* Logs: + + The following environment variables can be used to override the default values + for the batch processor configured for logging: + + | Environment variable | `LogRecordExportProcessorOptions.BatchExportProcessorOptions` property | + | ----------------------------------| ------------------------------------------------------------------------| + | `OTEL_BLRP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | + | `OTEL_BLRP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | + | `OTEL_BLRP_MAX_QUEUE_SIZE` | `MaxQueueSize` | + | `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | + + The following environment variables can be used to override the default values + of the `OtlpExporterOptions` used for logging when using the [UseOtlpExporter + extension](#enable-otlp-exporter-for-all-signals): + + | Environment variable | `OtlpExporterOptions` property | UseOtlpExporter | AddOtlpExporter | + | --------------------------------------| --------------------------------------|-----------------|-----------------| + | `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` | `Endpoint` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_LOGS_HEADERS` | `Headers` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` | `TimeoutMilliseconds` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| Supported | Not supported | + +* Metrics: + + The following environment variables can be used to override the default value + of the `TemporalityPreference` setting for the reader configured for metrics + when using OTLP exporter: + + | Environment variable | `MetricReaderOptions` property | + | ----------------------------------------------------| ------------------------------------------------| + | `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | `TemporalityPreference` | + + The following environment variables can be used to override the default values + of the periodic exporting metric reader configured for metrics: + + | Environment variable | `PeriodicExportingMetricReaderOptions` property | + | ----------------------------------------------------| ------------------------------------------------| + | `OTEL_METRIC_EXPORT_INTERVAL` | `ExportIntervalMilliseconds` | + | `OTEL_METRIC_EXPORT_TIMEOUT` | `ExportTimeoutMilliseconds` | + + The following environment variables can be used to override the default values + of the `OtlpExporterOptions` used for metrics when using the [UseOtlpExporter + extension](#enable-otlp-exporter-for-all-signals): + + | Environment variable | `OtlpExporterOptions` property | UseOtlpExporter | AddOtlpExporter | + | --------------------------------------| --------------------------------------|-----------------|-----------------| + | `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` | `Endpoint` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_METRICS_HEADERS` | `Headers` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` | `TimeoutMilliseconds` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| Supported | Not supported | + +* Tracing: + + The following environment variables can be used to override the default values + for the batch processor configured for tracing: + + | Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property | + | ---------------------------------| ------------------------------------------------------------| + | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | + | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | + | `OTEL_BSP_MAX_QUEUE_SIZE` | `MaxQueueSize` | + | `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | + + The following environment variables can be used to override the default values + of the `OtlpExporterOptions` used for tracing when using the [UseOtlpExporter + extension](#enable-otlp-exporter-for-all-signals): + + | Environment variable | `OtlpExporterOptions` property | UseOtlpExporter | AddOtlpExporter | + | --------------------------------------| --------------------------------------|-----------------|-----------------| + | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | `Endpoint` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_TRACES_HEADERS` | `Headers` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_TRACES_TIMEOUT` | `TimeoutMilliseconds` | Supported | Not supported | + | `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| Supported | Not supported | + +### Attribute limits + +The [OpenTelemetry +Specification](https://github.com/open-telemetry/opentelemetry-specification/) +defines environment variables which can be used to configure [attribute +limits](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#attribute-limits). + +The following environment variables can be used to configure default attribute +limits: * `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` * `OTEL_ATTRIBUTE_COUNT_LIMIT` -The following environment variables can be used to override the default -values of the span limits -(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.25.0/specification/configuration/sdk-environment-variables.md#span-limits)). +The following environment variables can be used to configure span limits used +for tracing: * `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` * `OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT` @@ -341,21 +455,27 @@ values of the span limits * `OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT` * `OTEL_LINK_ATTRIBUTE_COUNT_LIMIT` -The following environment variables can be used to override the default -values of the log record limits -(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.25.0/specification/configuration/sdk-environment-variables.md#logrecord-limits)). +The following environment variables can be used to configure log record limits +used for logging: * `OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT` * `OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT` -## Environment Variables for Experimental Features +### Experimental Features + +### All signals + +* `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` + + When set to `true`, it enables in-memory retry for transient errors ecountered + sending telemetry. -### Otlp Log Exporter +### Logs * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` -When set to `true`, it enables export of `LogRecord.EventId.Id` as -`logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. + When set to `true`, it enables export of `LogRecord.EventId.Id` as + `logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. ## Configure HttpClient From c4e8ee4f527e656974f2c2006115dcf1f838020b Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Mar 2024 15:30:40 -0700 Subject: [PATCH 02/15] Lint. --- .../README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 7ae8904712e..6cf18b0e650 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -20,7 +20,9 @@ implementation. * [LogRecordExportProcessorOptions](#logrecordexportprocessoroptions) * [MetricReaderOptions](#metricreaderoptions) * [Environment Variables](#environment-variables) - * [Experimental Features](#environment-variables-for-experimental-features) + * [Exporter configuration](#exporter-configuration) + * [Attribute limits](#attribute-limits) + * [Experimental Features](#experimental-features) * [Configure HttpClient](#configure-httpclient) * [Troubleshooting](#troubleshooting) @@ -349,7 +351,7 @@ or reader The following environment variables can be used to override the default values of the `OtlpExporterOptions`: - + | Environment variable | `OtlpExporterOptions` property | | ------------------------------| --------------------------------------| | `OTEL_EXPORTER_OTLP_ENDPOINT` | `Endpoint` | @@ -372,7 +374,7 @@ or reader The following environment variables can be used to override the default values of the `OtlpExporterOptions` used for logging when using the [UseOtlpExporter extension](#enable-otlp-exporter-for-all-signals): - + | Environment variable | `OtlpExporterOptions` property | UseOtlpExporter | AddOtlpExporter | | --------------------------------------| --------------------------------------|-----------------|-----------------| | `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` | `Endpoint` | Supported | Not supported | @@ -385,14 +387,14 @@ or reader The following environment variables can be used to override the default value of the `TemporalityPreference` setting for the reader configured for metrics when using OTLP exporter: - + | Environment variable | `MetricReaderOptions` property | | ----------------------------------------------------| ------------------------------------------------| | `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | `TemporalityPreference` | - + The following environment variables can be used to override the default values of the periodic exporting metric reader configured for metrics: - + | Environment variable | `PeriodicExportingMetricReaderOptions` property | | ----------------------------------------------------| ------------------------------------------------| | `OTEL_METRIC_EXPORT_INTERVAL` | `ExportIntervalMilliseconds` | @@ -413,7 +415,7 @@ or reader The following environment variables can be used to override the default values for the batch processor configured for tracing: - + | Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property | | ---------------------------------| ------------------------------------------------------------| | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | From 48d300d7045c8fdd8ea0c512e10a389e0d6fe6ae Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Mar 2024 17:23:51 -0700 Subject: [PATCH 03/15] Code review. --- .../README.md | 84 +++++++++++++++++-- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 6cf18b0e650..afd240d92ef 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -114,8 +114,9 @@ runnable example. ## Enable OTLP Exporter for all signals -A cross-cutting extension was added in v1.8.0 to simplify registration of the -OTLP exporter for all signals (logs, metrics, and tracing). +Starting with the `1.8.0` version you can use the cross-cutting +`UseOtlpExporter` extension to simplify registration of the OTLP exporter for +all signals (logs, metrics, and traces). > [!NOTE] > The cross cutting extension is currently only available when using the @@ -133,8 +134,79 @@ The `UseOtlpExporter` has the following behaviors: * Calling `UseOtlpExporter` automatically enables logging, metrics, and tracing. Calls to `WithLogging`, `WithTracing`, and/or `WithLogging` are NOT required when using `UseOtlpExporter` however only telemetry which has been enabled - (typically via `AddSource` inside of `WithTracing` or `AddMeter` inside of - `WithMetrics`) will be exported. + will be exported. + + There are different mechanisms available to enable telemetry: + + * Logging + + `ILogger` telemetry is controled by category filters typically set through + configuration. For details see: [Log + Filtering](../../docs/logs/customizing-the-sdk/README.md#log-filtering) and + [Logging in + .NET](https://docs.microsoft.com/dotnet/core/extensions/logging). + + * Metrics + + Metrics telemetry is controlled by calling `MeterProviderBuilder.AddMeter` + to listen to + [Meter](https://learn.microsoft.com/dotnet/api/system.diagnostics.meter)s + emitting metrics. Typically instrumentation packages will make this call + automatically. + + Examples: + + ```csharp + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter() + .WithMetrics(metrics => metrics + .AddMeter(MyMeter.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); + ``` + + ```csharp + appBuilder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics + .AddMeter(MyMeter.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); + + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter(); + ``` + + For details see: [Meter](../../docs/metrics/customizing-the-sdk/README.md#meter). + + * Tracing + + Trace telemetry is controlled by calling `TracerProviderBuilder.AddSource` + to listen to + [ActivitySource](https://learn.microsoft.com/dotnet/api/system.diagnostics.activitysource)s + emitting traces. Typically instrumentation packages will make this call + automatically. + + Examples: + + ```csharp + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter() + .WithTracing(tracing => tracing + .AddSource(MyActivitySource.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); + ``` + + ```csharp + appBuilder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing + .AddSource(MyActivitySource.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); + + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter(); + ``` + + For details see: [Activity Source](../../docs/trace/customizing-the-sdk/README.md#activity-source). * The exporter registered by `UseOtlpExporter` will be added as the last processor in the pipeline established for logging and tracing. @@ -469,8 +541,8 @@ used for logging: * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` - When set to `true`, it enables in-memory retry for transient errors ecountered - sending telemetry. + When set to `true`, it enables in-memory retry for transient errors + encountered sending telemetry. ### Logs From a71bc6147c48b09cbf5680818f851ac77651c633 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Mar 2024 17:37:06 -0700 Subject: [PATCH 04/15] Lint. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index afd240d92ef..b431bcee739 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -140,7 +140,7 @@ The `UseOtlpExporter` has the following behaviors: * Logging - `ILogger` telemetry is controled by category filters typically set through + `ILogger` telemetry is controlled by category filters typically set through configuration. For details see: [Log Filtering](../../docs/logs/customizing-the-sdk/README.md#log-filtering) and [Logging in From 841175ef800592ae5ded7e1dda816d31b8885e52 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Mar 2024 22:42:46 -0700 Subject: [PATCH 05/15] Add metrics config example. --- .../README.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index b431bcee739..65212fd28f8 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -177,6 +177,28 @@ The `UseOtlpExporter` has the following behaviors: For details see: [Meter](../../docs/metrics/customizing-the-sdk/README.md#meter). + When using `Microsoft.Extensions.Hosting` v8.0.0 or greater (a standard part + of ASP.NET Core) `Meter`s and `Instrument`s can also be enabled using + configuration. + + `appSettings.json` metrics configuration example: + + ```json + { + "Metrics": { + "EnabledMetrics": { + "Microsoft.AspNetCore.*": true, + "System.*": true, + "MyCompany.*": true, + } + } + } + ``` + + For details about the built-in metrics exposed by .NET see: [Built-in + metrics in + .NET](https://learn.microsoft.com/dotnet/core/diagnostics/built-in-metrics). + * Tracing Trace telemetry is controlled by calling `TracerProviderBuilder.AddSource` From 31e6f2ffc3d57eacdb0f00e94e388dc7e1527134 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 15 Mar 2024 14:45:36 -0700 Subject: [PATCH 06/15] Code review. --- .../README.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 65212fd28f8..4355b1d589a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -22,7 +22,7 @@ implementation. * [Environment Variables](#environment-variables) * [Exporter configuration](#exporter-configuration) * [Attribute limits](#attribute-limits) - * [Experimental Features](#experimental-features) + * [Experimental features](#experimental-features) * [Configure HttpClient](#configure-httpclient) * [Troubleshooting](#troubleshooting) @@ -132,7 +132,7 @@ appBuilder.Services.AddOpenTelemetry() The `UseOtlpExporter` has the following behaviors: * Calling `UseOtlpExporter` automatically enables logging, metrics, and tracing. - Calls to `WithLogging`, `WithTracing`, and/or `WithLogging` are NOT required + Calls to `WithLogging`, `WithMetrics`, and/or `WithTracing` are NOT required when using `UseOtlpExporter` however only telemetry which has been enabled will be exported. @@ -157,22 +157,22 @@ The `UseOtlpExporter` has the following behaviors: Examples: ```csharp - appBuilder.Services.AddOpenTelemetry() - .UseOtlpExporter() - .WithMetrics(metrics => metrics - .AddMeter(MyMeter.Name) // Listen to custom telemetry - .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry - ); - ``` - - ```csharp - appBuilder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter() + .WithMetrics(metrics => metrics .AddMeter(MyMeter.Name) // Listen to custom telemetry .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry ); + ``` + + ```csharp + appBuilder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics + .AddMeter(MyMeter.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); - appBuilder.Services.AddOpenTelemetry() - .UseOtlpExporter(); + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter(); ``` For details see: [Meter](../../docs/metrics/customizing-the-sdk/README.md#meter). @@ -210,22 +210,22 @@ The `UseOtlpExporter` has the following behaviors: Examples: ```csharp - appBuilder.Services.AddOpenTelemetry() - .UseOtlpExporter() - .WithTracing(tracing => tracing - .AddSource(MyActivitySource.Name) // Listen to custom telemetry - .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry - ); - ``` - - ```csharp - appBuilder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter() + .WithTracing(tracing => tracing .AddSource(MyActivitySource.Name) // Listen to custom telemetry .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry ); + ``` + + ```csharp + appBuilder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing + .AddSource(MyActivitySource.Name) // Listen to custom telemetry + .AddAspNetCoreInstrumentation() // Use instrumentation to listen to telemetry + ); - appBuilder.Services.AddOpenTelemetry() - .UseOtlpExporter(); + appBuilder.Services.AddOpenTelemetry() + .UseOtlpExporter(); ``` For details see: [Activity Source](../../docs/trace/customizing-the-sdk/README.md#activity-source). @@ -557,7 +557,7 @@ used for logging: * `OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT` * `OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT` -### Experimental Features +### Experimental features ### All signals From ba1fac9f76600e82bbd1d55ab2f9501c8411245f Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 15 Mar 2024 15:28:18 -0700 Subject: [PATCH 07/15] Tweaks. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 4355b1d589a..5ac772f83a1 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -131,10 +131,8 @@ appBuilder.Services.AddOpenTelemetry() The `UseOtlpExporter` has the following behaviors: -* Calling `UseOtlpExporter` automatically enables logging, metrics, and tracing. - Calls to `WithLogging`, `WithMetrics`, and/or `WithTracing` are NOT required - when using `UseOtlpExporter` however only telemetry which has been enabled - will be exported. +* Calling `UseOtlpExporter` automatically enables logging, metrics, and tracing + however only telemetry which has been enabled will be exported. There are different mechanisms available to enable telemetry: From d5609a90b52774242495598fcd5caa9a4bc951a7 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Mon, 18 Mar 2024 14:06:42 -0700 Subject: [PATCH 08/15] Code review. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 5ac772f83a1..3c60eecf31c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -557,14 +557,14 @@ used for logging: ### Experimental features -### All signals +#### All signals * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` When set to `true`, it enables in-memory retry for transient errors - encountered sending telemetry. + encountered while sending telemetry. -### Logs +#### Logs * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` From 9a35880f4fe351ef19d490ca0b76407a14ca73ad Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Mon, 18 Mar 2024 14:08:08 -0700 Subject: [PATCH 09/15] Tweak. --- .../README.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 3c60eecf31c..1c3c457496c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -557,19 +557,19 @@ used for logging: ### Experimental features -#### All signals - -* `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` - - When set to `true`, it enables in-memory retry for transient errors - encountered while sending telemetry. +* All signals -#### Logs + * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` + + When set to `true`, it enables in-memory retry for transient errors + encountered while sending telemetry. -* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` +* Logs - When set to `true`, it enables export of `LogRecord.EventId.Id` as - `logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. + * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` + + When set to `true`, it enables export of `LogRecord.EventId.Id` as + `logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. ## Configure HttpClient From 727012a546d511abd0dc9f5e420e36bb52cdc180 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 19 Mar 2024 09:38:51 -0700 Subject: [PATCH 10/15] Code review and tweaks. --- .../README.md | 90 ++++++++++++------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 1c3c457496c..9a438e1002c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -22,8 +22,8 @@ implementation. * [Environment Variables](#environment-variables) * [Exporter configuration](#exporter-configuration) * [Attribute limits](#attribute-limits) - * [Experimental features](#experimental-features) * [Configure HttpClient](#configure-httpclient) +* [Experimental features](#experimental-features) * [Troubleshooting](#troubleshooting) @@ -114,7 +114,7 @@ runnable example. ## Enable OTLP Exporter for all signals -Starting with the `1.8.0` version you can use the cross-cutting +Starting with the `1.8.0-beta.1` version you can use the cross-cutting `UseOtlpExporter` extension to simplify registration of the OTLP exporter for all signals (logs, metrics, and traces). @@ -426,6 +426,14 @@ appBuilder.Services.Configure( ## Environment Variables +The following environment variables can be used to configure the OTLP Exporter +for logs, traces, and metrics. + +> [!NOTE] +> In OpenTelemetry .NET environment variable keys are retrieved using + `IConfiguration` which means they may be set using other mechanisms such as + defined in appSettings.json or specified on the command-line. + ### Exporter configuration The [OpenTelemetry @@ -456,7 +464,7 @@ or reader The following environment variables can be used to override the default values for the batch processor configured for logging: - | Environment variable | `LogRecordExportProcessorOptions.BatchExportProcessorOptions` property | + | Environment variable | `BatchExportLogRecordProcessorOptions` property | | ----------------------------------| ------------------------------------------------------------------------| | `OTEL_BLRP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | | `OTEL_BLRP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | @@ -508,7 +516,7 @@ or reader The following environment variables can be used to override the default values for the batch processor configured for tracing: - | Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property | + | Environment variable | `BatchExportActivityProcessorOptions` property | | ---------------------------------| ------------------------------------------------------------| | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | @@ -555,29 +563,17 @@ used for logging: * `OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT` * `OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT` -### Experimental features - -* All signals - - * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` - - When set to `true`, it enables in-memory retry for transient errors - encountered while sending telemetry. - -* Logs - - * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` - - When set to `true`, it enables export of `LogRecord.EventId.Id` as - `logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. - ## Configure HttpClient The `HttpClientFactory` option is provided on `OtlpExporterOptions` for users -who want to configure the `HttpClient` used by the `OtlpTraceExporter` and/or -`OtlpMetricExporter` when `HttpProtobuf` protocol is used. Simply replace the -function with your own implementation if you want to customize the generated -`HttpClient`: +who want to configure the `HttpClient` used by the `OtlpTraceExporter`, +`OtlpMetricExporter`, and/or `OtlpLogExporter` when `HttpProtobuf` protocol is +used. Simply replace the function with your own implementation if you want to +customize the generated `HttpClient`: + +> [!NOTE] +> The `HttpClient` instance returned by the `HttpClientFactory` function is used + for all export requests. ```csharp services.AddOpenTelemetry() @@ -596,11 +592,11 @@ services.AddOpenTelemetry() > [!NOTE] > `DefaultRequestHeaders` can be used for [HTTP Basic Access -Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication). For -more complex authentication requirements, -[`System.Net.Http.DelegatingHandler`](https://learn.microsoft.com/dotnet/api/system.net.http.delegatinghandler) -can be used to handle token refresh, as explained -[here](https://stackoverflow.com/questions/56204350/how-to-refresh-a-token-using-ihttpclientfactory). + Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication). + For more complex authentication requirements, + [`System.Net.Http.DelegatingHandler`](https://learn.microsoft.com/dotnet/api/system.net.http.delegatinghandler) + can be used to handle token refresh, as explained + [here](https://stackoverflow.com/questions/56204350/how-to-refresh-a-token-using-ihttpclientfactory). For users using [IHttpClientFactory](https://docs.microsoft.com/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests) @@ -615,8 +611,40 @@ services.AddHttpClient( ``` > [!NOTE] -> The single instance returned by `HttpClientFactory` is reused by all export -requests. +> `IHttpClientFactory` is NOT currently supported by `OtlpLogExporter`. + +## Experimental features + +The following features are exposed experimentally in the OTLP Exporter. Features +are exposed experimentally when either the [OpenTelemetry +Specification](https://github.com/open-telemetry/opentelemetry-specification) +has explicitly marked something +[experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/document-status.md) +or when the SIG members are still working through the design for a feature and +want to solicit feedback from the community. + +### Environment variables + +> [!NOTE] +> In OpenTelemetry .NET environment variable keys are retrieved using + `IConfiguration` which means they may be set using other mechanisms such as + defined in appSettings.json or specified on the command-line. + +* All signals + + * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` + + When set to `true`, it enables in-memory retry for transient errors + encountered while sending telemetry. + + Added in `1.8.0-beta.1`. + +* Logs + + * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` + + When set to `true`, it enables export of `LogRecord.EventId.Id` as + `logrecord.event.id` and `LogRecord.EventId.Name` as `logrecord.event.name`. ## Troubleshooting From b5d88d1b79e94d1b722b8518c0d214427c052291 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 19 Mar 2024 09:40:54 -0700 Subject: [PATCH 11/15] Lint. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 9a438e1002c..0e2238709fd 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -633,7 +633,7 @@ want to solicit feedback from the community. * All signals * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` - + When set to `true`, it enables in-memory retry for transient errors encountered while sending telemetry. @@ -642,7 +642,7 @@ want to solicit feedback from the community. * Logs * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` - + When set to `true`, it enables export of `LogRecord.EventId.Id` as `logrecord.event.id` and `LogRecord.EventId.Name` as `logrecord.event.name`. From b21da4b074f4fa6a56dfd3c9fa27c58f28867753 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 19 Mar 2024 15:48:12 -0700 Subject: [PATCH 12/15] Code review. --- .../README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 0e2238709fd..a5207d3d4ae 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -245,19 +245,14 @@ variables](#environment-variables) listed below including the signal-specific overrides and users are encouraged to use this mechanism to configure their exporters. -> [!NOTE] -> In OpenTelemetry .NET environment variable keys are retrieved using - `IConfiguration` which means they may be set using other mechanisms such as - defined in appSettings.json or specified on the command-line. - -An `UseOtlpExporter` overload is provided which may be used to set the protocol -and base endpoint but no other options are currently exposed: +A `UseOtlpExporter` overload is provided which may be used to set the protocol +and base endpoint: ```csharp appBuilder.Services.AddOpenTelemetry() .UseOtlpExporter( OtlpExportProtocol.HttpProtobuf, - new Uri("http://otlp_exporter_base_address/")); + new Uri("http://localhost:4318/")); ``` > [!NOTE] @@ -646,6 +641,8 @@ want to solicit feedback from the community. When set to `true`, it enables export of `LogRecord.EventId.Id` as `logrecord.event.id` and `LogRecord.EventId.Name` as `logrecord.event.name`. + Added in `1.7.0-alpha.1`. + ## Troubleshooting This component uses an From 452c40b0c3ca5abc14a8a53a723f36ae8469b6fa Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 19 Mar 2024 15:50:20 -0700 Subject: [PATCH 13/15] Lint. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index a5207d3d4ae..404381892c2 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -628,7 +628,7 @@ want to solicit feedback from the community. * All signals * `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` - + When set to `true`, it enables in-memory retry for transient errors encountered while sending telemetry. From 2142ecb35fee2b32c88569bb0e1d077af0478760 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 20 Mar 2024 09:06:35 -0700 Subject: [PATCH 14/15] Code review. --- .../.publicApi/Stable/PublicAPI.Unshipped.txt | 2 +- .../OpenTelemetryBuilderOtlpExporterExtensions.cs | 14 +++++++------- .../README.md | 4 ++-- .../UseOtlpExporterExtensionTests.cs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt index b0659b798bb..c6fd8fda6ea 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt @@ -1,3 +1,3 @@ OpenTelemetry.OpenTelemetryBuilderOtlpExporterExtensions static OpenTelemetry.OpenTelemetryBuilderOtlpExporterExtensions.UseOtlpExporter(this OpenTelemetry.IOpenTelemetryBuilder! builder) -> OpenTelemetry.IOpenTelemetryBuilder! -static OpenTelemetry.OpenTelemetryBuilderOtlpExporterExtensions.UseOtlpExporter(this OpenTelemetry.IOpenTelemetryBuilder! builder, OpenTelemetry.Exporter.OtlpExportProtocol protocol, System.Uri! baseEndpoint) -> OpenTelemetry.IOpenTelemetryBuilder! +static OpenTelemetry.OpenTelemetryBuilderOtlpExporterExtensions.UseOtlpExporter(this OpenTelemetry.IOpenTelemetryBuilder! builder, OpenTelemetry.Exporter.OtlpExportProtocol protocol, System.Uri! baseUrl) -> OpenTelemetry.IOpenTelemetryBuilder! diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs index d500e5c997d..80164f0fa5c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Builder/OpenTelemetryBuilderOtlpExporterExtensions.cs @@ -45,25 +45,25 @@ public static IOpenTelemetryBuilder UseOtlpExporter( /// /// . /// . - /// - /// Base endpoint to use. - /// Note: A signal-specific path will be appended to the base endpoint for - /// each signal automatically if the protocol is set to + /// Base URL to use. + /// Note: A signal-specific path will be appended to the base URL for each + /// signal automatically if the protocol is set to . /// public static IOpenTelemetryBuilder UseOtlpExporter( this IOpenTelemetryBuilder builder, OtlpExportProtocol protocol, - Uri baseEndpoint) + Uri baseUrl) { - Guard.ThrowIfNull(baseEndpoint); + Guard.ThrowIfNull(baseUrl); return UseOtlpExporter(builder, name: null, configuration: null, configure: otlpBuilder => { otlpBuilder.ConfigureDefaultExporterOptions(o => { o.Protocol = protocol; - o.Endpoint = baseEndpoint; + o.Endpoint = baseUrl; }); }); } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 404381892c2..4e042f510ff 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -246,7 +246,7 @@ overrides and users are encouraged to use this mechanism to configure their exporters. A `UseOtlpExporter` overload is provided which may be used to set the protocol -and base endpoint: +and base URL: ```csharp appBuilder.Services.AddOpenTelemetry() @@ -257,7 +257,7 @@ appBuilder.Services.AddOpenTelemetry() > [!NOTE] > When the protocol is set to `OtlpExportProtocol.HttpProtobuf` a - signal-specific path will be appended automatically to the base endpoint when + signal-specific path will be appended automatically to the base URL when constructing exporters. ## Configuration diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/UseOtlpExporterExtensionTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/UseOtlpExporterExtensionTests.cs index 025bd3b97ec..8a03a8e47b7 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/UseOtlpExporterExtensionTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/UseOtlpExporterExtensionTests.cs @@ -74,7 +74,7 @@ public void UseOtlpExporterSetEndpointAndProtocolTest(OtlpExportProtocol protoco Assert.False(((OtlpExporterOptions)exporterOptions.TracingOptions).HasData); Assert.Throws( - () => services.AddOpenTelemetry().UseOtlpExporter(OtlpExportProtocol.HttpProtobuf, baseEndpoint: null!)); + () => services.AddOpenTelemetry().UseOtlpExporter(OtlpExportProtocol.HttpProtobuf, baseUrl: null!)); } [Theory] From 8e2e25a39a34011acffe33bd1d5aca44d8f439c4 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 21 Mar 2024 09:19:38 -0700 Subject: [PATCH 15/15] Code review. --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 4e042f510ff..6648f4d1581 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -250,9 +250,7 @@ and base URL: ```csharp appBuilder.Services.AddOpenTelemetry() - .UseOtlpExporter( - OtlpExportProtocol.HttpProtobuf, - new Uri("http://localhost:4318/")); + .UseOtlpExporter(OtlpExportProtocol.HttpProtobuf, new Uri("http://localhost:4318/")); ``` > [!NOTE] @@ -427,7 +425,7 @@ for logs, traces, and metrics. > [!NOTE] > In OpenTelemetry .NET environment variable keys are retrieved using `IConfiguration` which means they may be set using other mechanisms such as - defined in appSettings.json or specified on the command-line. + defined in `appSettings.json` or specified on the command-line. ### Exporter configuration