@@ -76,16 +76,25 @@ internal static OtlpLogs.LogRecord ToOtlpLog(this LogRecord logRecord)
76
76
otlpLogRecord . Body = new OtlpCommon . AnyValue { StringValue = logRecord . FormattedMessage } ;
77
77
}
78
78
79
+ if ( logRecord . StateValues != null )
80
+ {
81
+ foreach ( var stateValue in logRecord . StateValues )
82
+ {
83
+ var otlpAttribute = stateValue . ToOtlpAttribute ( ) ;
84
+ otlpLogRecord . Attributes . Add ( otlpAttribute ) ;
85
+ }
86
+ }
87
+
79
88
if ( logRecord . EventId != 0 )
80
89
{
81
- otlpLogRecord . Attributes . AddAttribute ( nameof ( logRecord . EventId ) , logRecord . EventId . ToString ( ) ) ;
90
+ otlpLogRecord . Attributes . AddStringAttribute ( nameof ( logRecord . EventId ) , logRecord . EventId . ToString ( ) ) ;
82
91
}
83
92
84
93
if ( logRecord . Exception != null )
85
94
{
86
- otlpLogRecord . Attributes . AddAttribute ( SemanticConventions . AttributeExceptionType , logRecord . Exception . GetType ( ) . Name ) ;
87
- otlpLogRecord . Attributes . AddAttribute ( SemanticConventions . AttributeExceptionMessage , logRecord . Exception . Message ) ;
88
- otlpLogRecord . Attributes . AddAttribute ( SemanticConventions . AttributeExceptionStacktrace , logRecord . Exception . ToInvariantString ( ) ) ;
95
+ otlpLogRecord . Attributes . AddStringAttribute ( SemanticConventions . AttributeExceptionType , logRecord . Exception . GetType ( ) . Name ) ;
96
+ otlpLogRecord . Attributes . AddStringAttribute ( SemanticConventions . AttributeExceptionMessage , logRecord . Exception . Message ) ;
97
+ otlpLogRecord . Attributes . AddStringAttribute ( SemanticConventions . AttributeExceptionStacktrace , logRecord . Exception . ToInvariantString ( ) ) ;
89
98
}
90
99
91
100
if ( logRecord . TraceId != default && logRecord . SpanId != default )
@@ -107,7 +116,7 @@ internal static OtlpLogs.LogRecord ToOtlpLog(this LogRecord logRecord)
107
116
return otlpLogRecord ;
108
117
}
109
118
110
- private static void AddAttribute ( this RepeatedField < OtlpCommon . KeyValue > repeatedField , string key , string value )
119
+ private static void AddStringAttribute ( this RepeatedField < OtlpCommon . KeyValue > repeatedField , string key , string value )
111
120
{
112
121
repeatedField . Add ( new OtlpCommon . KeyValue
113
122
{
0 commit comments