-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We initially used UseOtlpExporter as a convenient way to enable OTLP export by default globally for all signals. However, this plays poorly with the AddOtlpExporter methods, which throw if called by consumer code. This change avoids that risk. It also introduces a LoggingProviderBuilder extension to register our defaults, which our main builder calls. We still support disabling our default registration of the OTLP exporter via an environment variable, which the auto instrumentation plugin then passes when configuring the providers. This PR also fixes a small typo in the docs. Closes #177
- Loading branch information
1 parent
4a96eda
commit 107db01
Showing
7 changed files
with
73 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100", | ||
"rollForward": "latestMajor", | ||
"version": "8.0.404", | ||
"rollForward": "latestFeature", | ||
"allowPrerelease": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Elastic.OpenTelemetry/Extensions/LoggingProviderBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using OpenTelemetry.Logs; | ||
using OpenTelemetry.Trace; | ||
using static Elastic.OpenTelemetry.Configuration.Signals; | ||
|
||
namespace Elastic.OpenTelemetry.Extensions; | ||
|
||
/// <summary> | ||
/// Elastic extensions for <see cref="LoggerProviderBuilder"/>. | ||
/// </summary> | ||
public static class LoggingProviderBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Use Elastic Distribution of OpenTelemetry .NET defaults for <see cref="LoggerProviderBuilder"/>. | ||
/// </summary> | ||
public static LoggerProviderBuilder UseElasticDefaults(this LoggerProviderBuilder builder, bool skipOtlp = false, ILogger? logger = null) | ||
{ | ||
logger ??= NullLogger.Instance; | ||
|
||
if (!skipOtlp) | ||
builder.AddOtlpExporter(); | ||
|
||
logger.LogConfiguredSignalProvider(nameof(Logs), nameof(LoggerProviderBuilder)); | ||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters