Skip to content

Commit 071fa75

Browse files
authored
[Exporter.Geneva] Allow custom string size limit in custom fields (#3360)
1 parent 9a6da16 commit 071fa75

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Support for specifying resource attributes, including
66
`service.name`, `service.instanceId`, and custom attributes.
77
([#3214](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3214))
8+
* Allow custom string size limit in custom fields.
9+
([#3360](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3360))
810

911
## 1.13.0
1012

src/OpenTelemetry.Exporter.Geneva/Internal/MsgPack/MsgPackLogExporter.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ internal ArraySegment<byte> SerializeLogRecord(LogRecord logRecord)
327327
}
328328

329329
cursor = MessagePackSerializer.SerializeUnicodeString(buffer, cursor, entry.Key, this.stringFieldSizeLimitCharCount);
330-
cursor = MessagePackSerializer.Serialize(buffer, cursor, entry.Value);
330+
cursor = this.SerializeValueWithLimitIfString(buffer, cursor, entry.Value);
331331
cntFields += 1;
332332
}
333333
}
@@ -531,6 +531,17 @@ private static void OnProcessScopeForEnvProperties(LogRecordScope scope, MsgPack
531531
}
532532
}
533533

534+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
535+
private int SerializeValueWithLimitIfString(byte[] buffer, int cursor, object? value)
536+
{
537+
if (value is string stringValue)
538+
{
539+
return MessagePackSerializer.SerializeUnicodeString(buffer, cursor, stringValue, this.stringFieldSizeLimitCharCount);
540+
}
541+
542+
return MessagePackSerializer.Serialize(buffer, cursor, value);
543+
}
544+
534545
private sealed class SerializationDataForScopes
535546
{
536547
public readonly byte[] Buffer;

0 commit comments

Comments
 (0)