Log EventId and Name separately in Console and OTLP Exporter (#2802)
This commit is contained in:
parent
2aa816314c
commit
aad309b944
|
|
@ -36,7 +36,8 @@ namespace OpenTelemetry.Exporter
|
|||
this.WriteLine($"{"LogRecord.TraceId:".PadRight(RightPaddingLength)}{logRecord.TraceId}");
|
||||
this.WriteLine($"{"LogRecord.SpanId:".PadRight(RightPaddingLength)}{logRecord.SpanId}");
|
||||
this.WriteLine($"{"LogRecord.Timestamp:".PadRight(RightPaddingLength)}{logRecord.Timestamp:yyyy-MM-ddTHH:mm:ss.fffffffZ}");
|
||||
this.WriteLine($"{"LogRecord.EventId:".PadRight(RightPaddingLength)}{logRecord.EventId}");
|
||||
this.WriteLine($"{"LogRecord.EventId:".PadRight(RightPaddingLength)}{logRecord.EventId.Id}");
|
||||
this.WriteLine($"{"LogRecord.EventName:".PadRight(RightPaddingLength)}{logRecord.EventId.Name}");
|
||||
this.WriteLine($"{"LogRecord.CategoryName:".PadRight(RightPaddingLength)}{logRecord.CategoryName}");
|
||||
this.WriteLine($"{"LogRecord.LogLevel:".PadRight(RightPaddingLength)}{logRecord.LogLevel}");
|
||||
this.WriteLine($"{"LogRecord.TraceFlags:".PadRight(RightPaddingLength)}{logRecord.TraceFlags}");
|
||||
|
|
|
|||
|
|
@ -85,9 +85,10 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
if (logRecord.EventId != 0)
|
||||
if (logRecord.EventId != default)
|
||||
{
|
||||
otlpLogRecord.Attributes.AddStringAttribute(nameof(logRecord.EventId), logRecord.EventId.ToString());
|
||||
otlpLogRecord.Attributes.AddIntAttribute(nameof(logRecord.EventId.Id), logRecord.EventId.Id);
|
||||
otlpLogRecord.Attributes.AddStringAttribute(nameof(logRecord.EventId.Name), logRecord.EventId.Name);
|
||||
}
|
||||
|
||||
if (logRecord.Exception != null)
|
||||
|
|
@ -124,5 +125,14 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation
|
|||
Value = new OtlpCommon.AnyValue { StringValue = value },
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddIntAttribute(this RepeatedField<OtlpCommon.KeyValue> repeatedField, string key, int value)
|
||||
{
|
||||
repeatedField.Add(new OtlpCommon.KeyValue
|
||||
{
|
||||
Key = key,
|
||||
Value = new OtlpCommon.AnyValue { IntValue = value },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue