You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <summary>/// Executes callback for each currently active scope objects in order/// of creation. All callbacks are guaranteed to be called inline from/// this method./// </summary>/// <typeparam name="TState">State.</typeparam>/// <param name="callback">The callback to be executed for every scope object.</param>/// <param name="state">The state object to be passed into the callback.</param>publicvoidForEachScope<TState>(Action<LogRecordScope,TState>callback,TStatestate){
Guard.ThrowIfNull(callback);varforEachScopeState=newScopeForEachState<TState>(callback, state);if(this.BufferedScopes !=null){foreach(object? scope inthis.BufferedScopes){ScopeForEachState<TState>.ForEachScope(scope, forEachScopeState);}}elseif(this.ScopeProvider !=null){this.ScopeProvider.ForEachScope(ScopeForEachState<TState>.ForEachScope, forEachScopeState);}}
"if (this.BufferedScopes != null)" is not null on reuse of the LogRecord and there for will enumerate an empty list.
The text was updated successfully, but these errors were encountered:
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g.
OpenTelemetry 1.0.2
):OpenTelemetry.Api 1.4.0-beta.1
OpenTelemetry.Exporter.Console 1.4.0-beta.1
OpenTelemetry.Extensions.Hosting 1.0.0-rc9.7
Runtime version (e.g.
net462
,net48
,netcoreapp3.1
,net6.0
etc. You canfind this information from the
*.csproj
file):net6.0
Symptom
A call to LogRecord.ForEachScope on a reused LogRecord that had previously called Buffer dose not do anything prior to a call to Buffer on this usage.
This prevents implementation of a filter processor based on a scope value when using a batch exporter.
What is the expected behavior?
LogRecord.ForEachScope will enumerate scopes regardless of of buffered state.
What is the actual behavior?
LogRecord.ForEachScope will only enumerate scopes if the log record has not been reused before scopes are buffered.
Reproduce
https://github.com/mbubnich-bunnings/ForEachScopeProblem
Additional Context
"if (this.BufferedScopes != null)" is not null on reuse of the LogRecord and there for will enumerate an empty list.
The text was updated successfully, but these errors were encountered: