public void writeB3SingleFormat_sampled() { ITraceContext context = new SpanState(traceId: 1, parentSpanId: null, spanId: 3, isSampled: true, isDebug: false); var b3Format = B3SingleFormat.WriteB3SingleFormat(context); Assert.AreEqual(TraceId + '-' + SpanId + "-1", b3Format); }
public void parseB3SingleFormat_tooBig() { // overall length is ok, but it is malformed as parent is too long Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId + "-" + SpanId + "-" + TraceId + TraceId)); // overall length is not ok Assert.IsNull( B3SingleFormat.ParseB3SingleFormat(TraceId + TraceId + TraceId + "-" + SpanId + "-" + TraceId)); }
public void parseB3SingleFormat_idsWithDebug() { const string input = TraceId + "-" + SpanId + "-d"; var context = B3SingleFormat.ParseB3SingleFormat(input); var expectedContext = new SpanState(1, null, 3, null, true); Assert.AreEqual(expectedContext, context); }
public void parseB3SingleFormat_parent_unsampled() { const string input = TraceId + "-" + SpanId + "-0-" + ParentId; var context = B3SingleFormat.ParseB3SingleFormat(input); var expectedContext = new SpanState(1, 2, 3, false, false); Assert.AreEqual(expectedContext, context); }
public void parseB3SingleFormat_idsNotYetSampled() { const string input = TraceId + "-" + SpanId; var context = B3SingleFormat.ParseB3SingleFormat(input); var expectedContext = new SpanState(1, null, 3, null, false); Assert.AreEqual(expectedContext, context); }
public void writeB3SingleFormatWithoutParent_debug() { ITraceContext context = new SpanState(traceId: 1, parentSpanId: 2, spanId: 3, isSampled: false, isDebug: true); var b3Format = B3SingleFormat.WriteB3SingleFormatWithoutParentId(context); Assert.AreEqual(TraceId + '-' + SpanId + "-d", b3Format); }
public void writeB3SingleFormat_notYetSampled_128() { ITraceContext context = new SpanState(traceIdHigh: 9, traceId: 1, parentSpanId: null, spanId: 3, isSampled: null, isDebug: false); var b3Format = B3SingleFormat.WriteB3SingleFormat(context); Assert.AreEqual("0000000000000009" + TraceId + "-" + SpanId, b3Format); }
/// <summary> /// B3SingleFormat Trace /// </summary> /// <returns></returns> public string GetTrace() { String parent = null; using (var clientTrace = new ClientTrace(_serviceName, null)) { if (clientTrace.Trace != null) { var b3Format = B3SingleFormat.WriteB3SingleFormat(clientTrace.Trace.CurrentSpan); parent = b3Format; } } return(parent); }
public void parseB3SingleFormat_truncated() { Assert.IsNull(B3SingleFormat.ParseB3SingleFormat("")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat("-")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat("-1")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat("1-")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId.Substring(0, 15))); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId)); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId + "-")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId.Substring(0, 15) + "-" + SpanId)); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId + "-" + SpanId.Substring(0, 15))); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId + "-" + SpanId + "-")); Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(TraceId + "-" + SpanId + "-1-")); Assert.IsNull( B3SingleFormat.ParseB3SingleFormat(TraceId + "-" + SpanId + "-1-" + ParentId.Substring(0, 15))); }
public ITraceContext Extract(C carrier) { return(B3SingleFormat.ParseB3SingleFormat( _getter(carrier, _b3Key) )); }
public void Inject(ITraceContext traceContext, C carrier) { _setter(carrier, _b3Key, B3SingleFormat.WriteB3SingleFormat(traceContext)); }
public void parseB3SingleFormat_malformed_uuid() { const string input = "b970dafd-0d95-40aa-95d8-1d8725aebe40"; Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(input)); }
public void parseB3SingleFormat_malformed() { const string input = "not-a-tumor"; Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(input)); }
public void parseB3SingleFormat_malformed_parentid_notYetSampled() { var input = TraceId + "-" + SpanId + "-" + ParentId.Substring(0, 15) + "?"; Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(input)); }
public void parseB3SingleFormat_malformed_sampled_parentid() { var input = TraceId + "-" + SpanId + "-1-" + ParentId.Substring(0, 15) + "?"; Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(input)); // instead of raising exception }
public void parseB3SingleFormat_malformed_traceId() { var input = TraceId.Substring(0, 15) + "?-" + SpanId; Assert.IsNull(B3SingleFormat.ParseB3SingleFormat(input)); // instead of raising exception }