Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Fix gRPC sender's parent span reference (#203)
Browse files Browse the repository at this point in the history
* Fix gRPC sender's parent span reference

Signed-off-by: Kraemer, Benjamin <[email protected]>

* Fix unit test

Signed-off-by: Kraemer, Benjamin <[email protected]>
  • Loading branch information
Falco20019 authored Feb 25, 2021
1 parent e3b70cd commit 4d29d27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static GrpcSpan ConvertSpan(Span span)
var duration = (span.FinishTimestampUtc ?? startTime) - startTime;

var references = span.GetReferences();
var oneChildOfParent = references.Count == 1 && string.Equals(References.ChildOf, references[0].Type, StringComparison.Ordinal);

var grpcSpan = new GrpcSpan
{
Expand All @@ -32,7 +31,7 @@ public static GrpcSpan ConvertSpan(Span span)
Flags = (uint)context.Flags,
StartTime = Timestamp.FromDateTime(startTime),
Duration = Duration.FromTimeSpan(duration),
References = { oneChildOfParent ? new List<GrpcReference>() : BuildReferences(references) },
References = { BuildReferences(references) },
Tags = { BuildTags(span.GetTags()) },
Logs = { BuildLogs(span.GetLogs()) }
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Google.Protobuf;
using Jaeger.ApiV2;
using Jaeger.Reporters;
using Jaeger.Samplers;
using Jaeger.Senders.Grpc.Protocols;
using Jaeger.Util;
using OpenTracing;
using Xunit;
using GrpcSpan = Jaeger.ApiV2.Span;
Expand Down Expand Up @@ -125,9 +129,8 @@ public void TestConvertSpanOneReferenceChildOf()

GrpcSpan span = JaegerGrpcSpanConverter.ConvertSpan(child);

// TODO: Check ParentSpanID
//Assert.Equal((long)child.Context.ParentId, span.ParentSpanId);
Assert.Empty(span.References);
Assert.Single(span.References);
Assert.Equal(BuildReference(parent.Context, References.ChildOf), span.References[0]);
}

[Fact]
Expand All @@ -143,8 +146,6 @@ public void TestConvertSpanTwoReferencesChildOf()

GrpcSpan span = JaegerGrpcSpanConverter.ConvertSpan(child);

// TODO: Check ParentSpanID
//Assert.Equal(0, span.ParentSpanId);
Assert.Equal(2, span.References.Count);
Assert.Equal(BuildReference(parent.Context, References.ChildOf), span.References[0]);
Assert.Equal(BuildReference(parent2.Context, References.ChildOf), span.References[1]);
Expand All @@ -163,8 +164,6 @@ public void TestConvertSpanMixedReferences()

GrpcSpan span = JaegerGrpcSpanConverter.ConvertSpan(child);

// TODO: Check ParentSpanID
//Assert.Equal(0, span.ParentSpanId);
Assert.Equal(2, span.References.Count);
Assert.Equal(BuildReference(parent.Context, References.FollowsFrom), span.References[0]);
Assert.Equal(BuildReference(parent2.Context, References.ChildOf), span.References[1]);
Expand Down

0 comments on commit 4d29d27

Please sign in to comment.