-
Notifications
You must be signed in to change notification settings - Fork 765
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
Move LoggerProvider and friends (OTEL1000) to a stable API #5648
Merged
CodeBlanch
merged 18 commits into
open-telemetry:main
from
CodeBlanch:expose-logger-provider
Jun 5, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dc3e25a
Move OTEL1000 to a stable API.
CodeBlanch 07501bf
Use WithLogging in example app.
CodeBlanch 0022ab5
Fixes.
CodeBlanch d7286d4
Add support for detecting experimental features in tests, benchmarks,…
CodeBlanch 98461e4
Merge branch 'main' into expose-logger-provider
CodeBlanch bd1756b
Build fix.
CodeBlanch 43776a2
Merge remote-tracking branch 'upstream/main' into expose-logger-provider
CodeBlanch 3a12f33
CHANGELOG updates for new APIs.
CodeBlanch 33ec1e4
Updated CHANGELOGs for obsoletions.
CodeBlanch 95ba778
Merge remote-tracking branch 'upstream/main' into expose-logger-provider
CodeBlanch 0693b10
Moved ILoggingBuilder.UseOpenTelemetry back to experimental and remov…
CodeBlanch 1824b68
Lint.
CodeBlanch 6009a0b
Fixes.
CodeBlanch f945034
Fixes.
CodeBlanch c85f7ca
Cleanup.
CodeBlanch 5990c12
Cleanup.
CodeBlanch c8e3fa2
CHANGELOG updates.
CodeBlanch 6611356
Merge branch 'main' into expose-logger-provider
CodeBlanch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
|
@@ -24,20 +24,21 @@ | |
// Note: Switch between Explicit/Exponential by setting HistogramAggregation in appsettings.json | ||
var histogramAggregation = appBuilder.Configuration.GetValue("HistogramAggregation", defaultValue: "explicit")!.ToLowerInvariant(); | ||
|
||
// Build a resource configuration action to set service information. | ||
Action<ResourceBuilder> configureResource = r => r.AddService( | ||
serviceName: appBuilder.Configuration.GetValue("ServiceName", defaultValue: "otel-test")!, | ||
serviceVersion: typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown", | ||
serviceInstanceId: Environment.MachineName); | ||
|
||
// Create a service to expose ActivitySource, and Metric Instruments | ||
// for manual instrumentation | ||
appBuilder.Services.AddSingleton<Instrumentation>(); | ||
|
||
// Configure OpenTelemetry tracing & metrics with auto-start using the | ||
// Clear default logging providers used by WebApplication host. | ||
appBuilder.Logging.ClearProviders(); | ||
|
||
// Configure OpenTelemetry logging, metrics, & tracing with auto-start using the | ||
// AddOpenTelemetry extension from OpenTelemetry.Extensions.Hosting. | ||
appBuilder.Services.AddOpenTelemetry() | ||
.ConfigureResource(configureResource) | ||
.ConfigureResource(r => r | ||
.AddService( | ||
serviceName: appBuilder.Configuration.GetValue("ServiceName", defaultValue: "otel-test")!, | ||
serviceVersion: typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown", | ||
serviceInstanceId: Environment.MachineName)) | ||
.WithTracing(builder => | ||
{ | ||
// Tracing | ||
|
@@ -121,34 +122,25 @@ | |
builder.AddConsoleExporter(); | ||
break; | ||
} | ||
}); | ||
|
||
// Clear default logging providers used by WebApplication host. | ||
appBuilder.Logging.ClearProviders(); | ||
|
||
// Configure OpenTelemetry Logging. | ||
appBuilder.Logging.AddOpenTelemetry(options => | ||
{ | ||
// Note: See appsettings.json Logging:OpenTelemetry section for configuration. | ||
|
||
var resourceBuilder = ResourceBuilder.CreateDefault(); | ||
configureResource(resourceBuilder); | ||
options.SetResourceBuilder(resourceBuilder); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ seeing common Resource across all 3! And also ❤️ fixing the awkwardness of calling methods like |
||
|
||
switch (logExporter) | ||
}) | ||
.WithLogging(builder => | ||
{ | ||
case "otlp": | ||
options.AddOtlpExporter(otlpOptions => | ||
{ | ||
// Use IConfiguration directly for Otlp exporter endpoint option. | ||
otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!); | ||
}); | ||
break; | ||
default: | ||
options.AddConsoleExporter(); | ||
break; | ||
} | ||
}); | ||
// Note: See appsettings.json Logging:OpenTelemetry section for configuration. | ||
|
||
switch (logExporter) | ||
{ | ||
case "otlp": | ||
builder.AddOtlpExporter(otlpOptions => | ||
{ | ||
// Use IConfiguration directly for Otlp exporter endpoint option. | ||
otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!); | ||
}); | ||
break; | ||
default: | ||
builder.AddConsoleExporter(); | ||
break; | ||
} | ||
}); | ||
|
||
appBuilder.Services.AddControllers(); | ||
|
||
|
9 changes: 0 additions & 9 deletions
9
...enTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/PublicAPI.Unshipped.txt
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,9 +0,0 @@ | ||
OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions | ||
OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProvider!, T!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func<System.IServiceProvider!, T!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, T! instrumentation) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection!>! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! | ||
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,9 @@ | ||
OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions | ||
OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProvider!, T!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func<System.IServiceProvider!, T!>! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, T! instrumentation) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection!>! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! | ||
static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<System.IServiceProvider!, OpenTelemetry.Logs.LoggerProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a note here to warn users that this approach only works if their exporter also supports this model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might get confusing. I think either a) we leave it as is or b) we show the old style. Let me know which you prefer! I'm hoping the gap is short-lived and we can get these extensions added soon after 1.9.0 is out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay to keep this as-is, assuming the gap is short-lived.