Skip to content
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

OpenTelemetryLoggerProvider is now unaffected by changes to OpenTelemetryLoggerOptions after the LoggerFactory is built. #3055

Merged
merged 37 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f944a1c
Merge pull request #1 from open-telemetry/main
TimothyMothra Jan 28, 2022
ba726c5
Merge branch 'open-telemetry:main' into main
TimothyMothra Feb 10, 2022
68d1977
Merge branch 'open-telemetry:main' into main
TimothyMothra Feb 15, 2022
9dcb839
poc for fix to InMemoryExporter
TimothyMothra Feb 16, 2022
34d15ec
Revert "poc for fix to InMemoryExporter"
TimothyMothra Feb 22, 2022
436f0dc
Merge branch 'open-telemetry:main' into main
TimothyMothra Feb 22, 2022
1c7390c
Merge branch 'open-telemetry:main' into main
TimothyMothra Mar 4, 2022
9d2453f
Merge branch 'open-telemetry:main' into main
TimothyMothra Mar 14, 2022
752f6fd
includescopes
TimothyMothra Mar 14, 2022
4e9fe78
Merge branch 'open-telemetry:main' into main
TimothyMothra Mar 15, 2022
e3779ad
prevent LoggerOptions from being modified after init.
TimothyMothra Mar 15, 2022
34bb684
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 15, 2022
797f991
REMOVE
TimothyMothra Mar 15, 2022
a5a8d93
Merge branch '2902_fix_options' of https://github.com/TimothyMothra/o…
TimothyMothra Mar 15, 2022
4a29ff1
copy the values out of the Options instance
TimothyMothra Mar 16, 2022
c6f2133
remove
TimothyMothra Mar 16, 2022
9a9b7c0
new test to verify options cannot be changed
TimothyMothra Mar 17, 2022
0362a97
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 17, 2022
b3ab1f9
changelog
TimothyMothra Mar 18, 2022
fe9d508
Merge branch '2902_fix_options' of https://github.com/TimothyMothra/o…
TimothyMothra Mar 18, 2022
5e68aff
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 18, 2022
dbb9645
update changelog
TimothyMothra Mar 18, 2022
73bf126
merge
TimothyMothra Mar 18, 2022
c659f74
Update src/OpenTelemetry/CHANGELOG.md
TimothyMothra Mar 18, 2022
b1b4f7b
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 22, 2022
5e71c7c
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 25, 2022
767beaf
update
TimothyMothra Mar 28, 2022
468e96a
Merge branch '2902_fix_options' of https://github.com/TimothyMothra/o…
TimothyMothra Mar 28, 2022
baea732
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 28, 2022
6cf5620
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 29, 2022
5aef460
addressing pr comments.
TimothyMothra Mar 29, 2022
b45f92b
Merge branch '2902_fix_options' of https://github.com/TimothyMothra/o…
TimothyMothra Mar 29, 2022
99f6b9e
remove CreateLogger from InitializeLoggerFactory
TimothyMothra Mar 29, 2022
8cb96b8
Merge branch 'main' into 2902_fix_options
cijothomas Mar 29, 2022
d7ba0a5
Merge branch 'main' into 2902_fix_options
TimothyMothra Mar 29, 2022
fbf6ac5
Update CHANGELOG.md
TimothyMothra Mar 29, 2022
4b760d1
Merge branch 'main' into 2902_fix_options
cijothomas Mar 29, 2022
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
10 changes: 4 additions & 6 deletions src/OpenTelemetry/Logs/OpenTelemetryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
var processor = this.provider.Processor;
if (processor != null)
{
var options = this.provider.Options;

var record = new LogRecord(
options.IncludeScopes ? this.ScopeProvider : null,
this.provider.IncludeScopes ? this.ScopeProvider : null,
DateTime.UtcNow,
this.categoryName,
logLevel,
eventId,
options.IncludeFormattedMessage ? formatter?.Invoke(state, exception) : null,
options.ParseStateValues ? null : state,
this.provider.IncludeFormattedMessage ? formatter?.Invoke(state, exception) : null,
reyang marked this conversation as resolved.
Show resolved Hide resolved
this.provider.ParseStateValues ? null : state,
exception,
options.ParseStateValues ? this.ParseState(state) : null);
this.provider.ParseStateValues ? this.ParseState(state) : null);

processor.OnEnd(record);

Expand Down
9 changes: 7 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ namespace OpenTelemetry.Logs
[ProviderAlias("OpenTelemetry")]
public class OpenTelemetryLoggerProvider : BaseProvider, ILoggerProvider, ISupportExternalScope
{
internal readonly OpenTelemetryLoggerOptions Options;
internal readonly bool IncludeScopes;
internal readonly bool IncludeFormattedMessage;
internal readonly bool ParseStateValues;
internal BaseProcessor<LogRecord> Processor;
internal Resource Resource;
private readonly Hashtable loggers = new();
Expand All @@ -48,7 +50,10 @@ internal OpenTelemetryLoggerProvider(OpenTelemetryLoggerOptions options)
{
Guard.ThrowIfNull(options);

this.Options = options;
this.IncludeScopes = options.IncludeScopes;
cijothomas marked this conversation as resolved.
Show resolved Hide resolved
this.IncludeFormattedMessage = options.IncludeFormattedMessage;
this.ParseStateValues = options.ParseStateValues;

this.Resource = options.ResourceBuilder.Build();

foreach (var processor in options.Processors)
Expand Down
Loading