Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 128 bits trace Ids #90

Merged
merged 1 commit into from
Jul 19, 2017
Merged

Handle 128 bits trace Ids #90

merged 1 commit into from
Jul 19, 2017

Conversation

fedj
Copy link
Collaborator

@fedj fedj commented Jul 18, 2017

Fixes #86

@fedj
Copy link
Collaborator Author

fedj commented Jul 18, 2017

cc @adriancole

Copy link
Member

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG only small things

var secondRecord = new Record(new SpanState(1, 0, 1, SpanFlags.None), TimeUtils.UtcNow, Annotations.ClientRecv());
var traceId = 1;
var traceIdHigh = 2;
var firstRecord = new Record(new SpanState(traceId, traceIdHigh, 0, 1, SpanFlags.None), TimeUtils.UtcNow, Annotations.ClientRecv());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit I usually try to order traceIdHigh first, as it aligns with the hex encoding of traceIdHigh+traceId

public class T_SpanState
{
private const long traceId = 1;
private const long traceIdHigh = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same nit on ordering, won't repeat again. feel free to go your way and I understand lexicographically this looks right

@@ -78,7 +79,7 @@ public void TraceCreatesCorrectRecordWithTimeSpecified()
[TestCase(SpanFlags.SamplingKnown | SpanFlags.Sampled)]
public void TraceSamplingForced(SpanFlags initialFlags)
{
var spanState = new SpanState(1, 0, 1, initialFlags);
var spanState = new SpanState(1, 2, 0, 1, initialFlags);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does csharp support constructor overloading? if so default traceIdHigh to zero

[Test]
public void Supports128BitsTraceId()
{
var traceId = "00FF0000000000001000000000002111";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a test that makes it obvious that the 00FF.. part is traceIdHigh? Ex by using shorter numbers like traceIdHigh=1, traceId=2 (as the hex is equiv to decimal and easy to see)

{
TraceId = traceId;
TraceIdHigh = traceIdHigh;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default to zero if possible

hashCode = (hashCode * 397) ^ SpanId.GetHashCode();
return hashCode;
}
}

public override string ToString()
{
return string.Format("{0}.{1}<:{2}", TraceId, SpanId, ParentSpanId.HasValue ? ParentSpanId.Value.ToString(CultureInfo.InvariantCulture) : "_");
return string.Format("{0}{1}.{2}<:{3}", TraceIdHigh == 0 ? "" : TraceIdHigh.ToString(), TraceId, SpanId, ParentSpanId.HasValue ? ParentSpanId.Value.ToString(CultureInfo.InvariantCulture) : "_");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

/// <summary>
/// Extracts traceId. Detects if present and then decode the last 16 bytes
/// </summary>
private static long ExtractTraceId(string encodedTraceId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit indent

@fedj fedj force-pushed the 128bits branch 5 times, most recently from 1c12086 to 99884d1 Compare July 19, 2017 08:39
@fedj
Copy link
Collaborator Author

fedj commented Jul 19, 2017

@adriancole Done, I think it's easier to read with your comments. I also introduced a constant to see the absence of traceIdHigh

Copy link
Collaborator

@crntn crntn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I note an inconsistency between SpanState's Equals and GetHashCode that we can fix in another PR.
https://github.com/criteo/zipkin4net/issues/91

@fedj fedj merged commit 48c3841 into master Jul 19, 2017
@fedj fedj deleted the 128bits branch July 19, 2017 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants