-
Notifications
You must be signed in to change notification settings - Fork 879
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedGood for taking. Extra help will be provided by maintainersGood for taking. Extra help will be provided by maintainerslogsLogging signal relatedLogging signal related
Description
Bug Report
Currently working on net8.0
<PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.Telemetry" Version="8.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
Symptom
When using redaction and batch otlp protocol, redacted values are not stored.
What is the expected behavior?
Expected: the redacted value
What is the actual behavior?
Actual: no value store (the key is even not sent)
Reproduce
Little hard to reproduce as it needs a sink to send logs to. However, I've found the issue: when using redaction, the redacted values are stored as JustInTimeRedactor (see) to avoid allocations. When using batch exporter, as it might take time to send telemetry and as JustInTimeRedactor is pooled, the value can either not be available or reused by something else.
Additional Context
I've found a kind of workaround which is adding a Processor which "freezes" pooled values.
public class FreezePooledValuesProcessor : BaseProcessor<LogRecord>
{
public override void OnStart(LogRecord data)
{
base.OnStart(data);
}
public override void OnEnd(LogRecord data)
{
if (data.Attributes is not null)
{
data.Attributes = data.Attributes
.Select(kvp => kvp.Value is IResettable resettable ? KeyValuePair.Create<string, object?>(kvp.Key, resettable.ToString()) : kvp)
.ToList();
}
base.OnEnd(data);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedGood for taking. Extra help will be provided by maintainersGood for taking. Extra help will be provided by maintainerslogsLogging signal relatedLogging signal related