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
Processor does not seem to add attribute when exported to Console
Hi,
I have a simple processor which adds a new attributes currentDateTimeInUtc
This attribute is not showing/being added when the exporter is to Console but it is added when it is exported to an OTLP collector. Why?
Here the code:
internal class LogAttributesProcessor : BaseProcessor<LogRecord>
{
private readonly string _name;
public LogAttributesProcessor(string name = "LogAttributesProcessor")
{
_name = name;
}
public override void OnEnd(LogRecord record)
{
var tempDic = record.Attributes.ToDictionary(x => x.Key, y => y.Value);
IDictionary<string, object?> finalDic = new Dictionary<string, object?>();
foreach (var attr in tempDic)
{
---some logic--
}
//Inject UTC DateTime attribute in ISO-8601 format
**finalDic["currentDateTimeInUtc"] = DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture);**
record.Attributes = finalDic.ToList();
}
}
Strange.. I guess the order + buffering + shared state is working against you!
Could you do options.AddProcessor(new LogAttributesProcessor()) before adding the exporters?
Processor does not seem to add attribute when exported to Console
Hi,
I have a simple processor which adds a new attributes currentDateTimeInUtc
This attribute is not showing/being added when the exporter is to Console but it is added when it is exported to an OTLP collector. Why?
Here the code:
And here how it is registered:
Additional context
The text was updated successfully, but these errors were encountered: