File tree Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -231,15 +231,17 @@ void SpanImpl::FinishSpan(SpanFinishOptions opts) {
231
231
auto tags = span.mutable_tags ();
232
232
233
233
if (ref_.valid ()) {
234
- // Note: Converting span_id to a hex string here is necessary
235
- // because the Proto->Thrift conversion does not know to format
236
- // int-valued tags as hex-valued, yet the string value for
237
- // parent_span_guid is interpreted as a hex value downstream.
238
- //
239
- // TODO: The protocol supports encoding relationships directly.
240
- // switch to the native representation after validating the
241
- // feature in the collector.
242
- *tags->Add () = util::make_kv (ParentSpanGUIDKey, uint64ToHex (ref_.referenced ().span_id ()));
234
+ auto refs = span.mutable_references ();
235
+ auto ref = refs->Add ();
236
+ ref->mutable_span_context ()->set_span_id (ref_.referenced ().span_id ());
237
+ switch (ref_.type ()) {
238
+ case FollowsFromRef:
239
+ ref->set_relationship (collector::Reference::FOLLOWS_FROM);
240
+ break ;
241
+ default :
242
+ ref->set_relationship (collector::Reference::CHILD_OF);
243
+ break ;
244
+ }
243
245
}
244
246
245
247
{
Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ class SpanReference : public SpanStartOption {
109
109
// This is a no-op if the referenced context is not valid.
110
110
virtual void Apply (SpanImpl *span) const override ;
111
111
112
+ // Return the relationship type of this reference.
113
+ SpanReferenceType type () const { return type_; }
114
+
112
115
private:
113
116
SpanReferenceType type_;
114
117
SpanContext referenced_;
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ int main() {
34
34
35
35
TracerOptions topts;
36
36
37
- topts.access_token = " DEVELOPMENT_TOKEN_jmacd " ;
37
+ topts.access_token = " 3e5170e56cc4f4b2c94695a13ddf23d1 " ;
38
38
topts.collector_host = " localhost" ;
39
- topts.collector_port = 9998 ;
39
+ topts.collector_port = 9997 ;
40
40
topts.collector_encryption = " " ;
41
41
42
42
BasicRecorderOptions bopts;
@@ -56,13 +56,6 @@ int main() {
56
56
auto cspan = Tracer::Global ().StartSpan (" span/child" , { ChildOf (parent) });
57
57
cspan.Finish ();
58
58
59
- auto child = cspan.context ();
60
-
61
- // if (child.parent_span_id() == 0 ||
62
- // child.parent_span_id() != parent.span_id()) {
63
- // throw error("parent/child span_id mismatch");
64
- // }
65
-
66
59
Tracer::Global ().impl ()->Flush ();
67
60
} catch (std::exception &e) {
68
61
std::cerr << " Exception! " << e.what () << std::endl;
You can’t perform that action at this time.
0 commit comments