public void TestBuildTag(object tagValue, GrpcTagType tagType, object expected) { GrpcTag tag = JaegerGrpcSpanConverter.BuildTag("key", tagValue); Assert.Equal(tagType, tag.VType); Assert.Equal("key", tag.Key); switch (tagType) { case GrpcTagType.Bool: Assert.Equal(expected, tag.VBool); break; case GrpcTagType.Int64: Assert.Equal(expected, tag.VInt64); break; case GrpcTagType.Float64: Assert.Equal(expected, tag.VFloat64); break; case GrpcTagType.Binary: break; case GrpcTagType.String: default: Assert.Equal(expected, tag.VStr); break; } }
public void TestConvertSpan() { var logTimestamp = new DateTimeOffset(2018, 4, 13, 10, 30, 0, TimeSpan.Zero); var fields = new Dictionary <string, object> { { "k", "v" } }; Span span = (Span)_tracer.BuildSpan("operation-name").Start(); span.Log(logTimestamp, fields); span.SetBaggageItem("foo", "bar"); GrpcSpan grpcSpan = JaegerGrpcSpanConverter.ConvertSpan(span); Assert.Equal("operation-name", grpcSpan.OperationName); Assert.Equal(2, grpcSpan.Logs.Count); GrpcLog grpcLog = grpcSpan.Logs[0]; Assert.Equal(logTimestamp, grpcLog.Timestamp.ToDateTimeOffset()); Assert.Single(grpcLog.Fields); GrpcTag grpcTag = grpcLog.Fields[0]; Assert.Equal("k", grpcTag.Key); Assert.Equal("v", grpcTag.VStr); // NOTE: In Java, the order is different (event, value, key) because the HashMap algorithm is different. grpcLog = grpcSpan.Logs[1]; Assert.Equal(3, grpcLog.Fields.Count); grpcTag = grpcLog.Fields[0]; Assert.Equal("event", grpcTag.Key); Assert.Equal("baggage", grpcTag.VStr); grpcTag = grpcLog.Fields[1]; Assert.Equal("key", grpcTag.Key); Assert.Equal("foo", grpcTag.VStr); grpcTag = grpcLog.Fields[2]; Assert.Equal("value", grpcTag.Key); Assert.Equal("bar", grpcTag.VStr); }