Repository navigation
Closed
dotnet/corefx
#37395Labels
Milestone
Description
From "Shrink System.Diagnostics.Activity by 40 bytes" dotnet/corefx#37395
ActivitySpanId and ActivityTraceId can be shrunk to a single pointer size and made immutable meaning in and readonly ref are no longer required and become a disadvantage.
Also change the enums ActivityIdFormat and ActivityTraceFlags to be byte sized.
public partial class Activity
{
- public ref readonly ActivitySpanId ParentSpanId { get { ... } }
+ public ActivitySpanId ParentSpanId { get { ... } }
- public ref readonly ActivitySpanId SpanId { get { ... } }
+ public ActivitySpanId SpanId { get { ... } }
- public ref readonly ActivityTraceId TraceId { get { ... } }
+ public ActivityTraceId TraceId { get { ... } }
- public Activity SetParentId(in ActivityTraceId traceId, in ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags = ActivityTraceFlags.None);
+ public Activity SetParentId(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags = ActivityTraceFlags.None);
}
public readonly partial struct ActivitySpanId : System.IEquatable<System.Diagnostics.ActivitySpanId>
{
- public static bool operator ==(in ActivitySpanId spanId1, in ActivitySpanId spandId2);
+ public static bool operator ==(ActivitySpanId spanId1, ActivitySpanId spandId2);
- public static bool operator !=(in ActivitySpanId spanId1, in ActivitySpanId spandId2);
+ public static bool operator !=(ActivitySpanId spanId1, ActivitySpanId spandId2);
}
public readonly partial struct ActivityTraceId : System.IEquatable<System.Diagnostics.ActivityTraceId>
{
- public static bool operator ==(in ActivityTraceId traceId1, in ActivityTraceId traceId2);
+ public static bool operator ==(ActivityTraceId traceId1, SActivityTraceId traceId2);
- public static bool operator !=(in ActivityTraceId traceId1, in ActivityTraceId traceId2);
+ public static bool operator !=(ActivityTraceId traceId1, ActivityTraceId traceId2);
}
Activity
bartonjs commentedon May 3, 2019
I feel like they were originally proposed as byte-sized, but got expanded back to default/int in API review.
stephentoub commentedon May 3, 2019
Right. There shouldn't be anything preventing them from being stored as a
byteeven if the enum itself hasintas the underlying type... which Vance said is what was either already the case or was going to be the case, i.e. have our cake and eat it, too. If in the future we needed more than whatbytecould handle, we could change the implementation without needing to affect the API.benaadams commentedon May 3, 2019
K, removed that bit
terrajobst commentedon May 28, 2019
Video
@tommcdon / @noahfalk / @sywhang are you OK with this? This change looks good to us.
tommcdon commentedon May 28, 2019
@terrajobst Looks good to me
noahfalk commentedon May 28, 2019
LGTM