// Convert flags to binary.
Span<char> flagsChars = stackalloc char[2];
HexConverter.ToCharsBuffer((byte)((~ActivityTraceFlagsIsSet) & _w3CIdFlags), flagsChars, 0, HexConverter.Casing.Lower);
- string id = "00-" + _traceId + "-" + _spanId + "-" + flagsChars.ToString();
-
+ string id =
+#if NET6_0_OR_GREATER
+ string.Create(null, stackalloc char[128], $"00-{_traceId}-{_spanId}-{flagsChars}");
+#else
+ "00-" + _traceId + "-" + _spanId + "-" + flagsChars.ToString();
+#endif
Interlocked.CompareExchange(ref _id, id, null);
}
{
Span<char> flagsChars = stackalloc char[2];
HexConverter.ToCharsBuffer((byte)((~ActivityTraceFlagsIsSet) & _parentTraceFlags), flagsChars, 0, HexConverter.Casing.Lower);
- string parentId = "00-" + _traceId + "-" + _parentSpanId + "-" + flagsChars.ToString();
+ string parentId =
+#if NET6_0_OR_GREATER
+ string.Create(null, stackalloc char[128], $"00-{_traceId}-{_parentSpanId}-{flagsChars}");
+#else
+ "00-" + _traceId + "-" + _parentSpanId + "-" + flagsChars.ToString();
+#endif
Interlocked.CompareExchange(ref _parentId, parentId, null);
}
else if (Parent != null)