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

An extension of enum opentracing::SpanReferenceType, for a new Span. #206

Merged
merged 14 commits into from
Mar 2, 2020
Merged

An extension of enum opentracing::SpanReferenceType, for a new Span. #206

merged 14 commits into from
Mar 2, 2020

Conversation

Alek86
Copy link
Contributor

@Alek86 Alek86 commented Feb 17, 2020

The PR is the result of this discussion: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/opentracing/92uhSCO-Tu8/D83rq-j4GQAJ

Basically, I need a way to force a traceId from user's code. Didn't see such way, had to write some dirty code in my copy of jaeger-client-cpp code.

Yuri Shkuro suggested to add a new jaeger specific reference type. He called it SELF, I decided to give a more specific name because of limitations (see below).

It is a bit similar to GO implementation (jaegertracing/jaeger-client-go#397) but I had some limitations:

  1. I couldn't copy whole SpanContext, because jaegertracing::Tracer::StartSpanWithOptions implementation was not completely clear to me. So I decided to copy only traceID and spanID
  2. There is an implicit rule in jaegertracing::Tracer::StartSpanWithOptions: if it's a root span, its spanID is the traceID.low(). I'm not sure if it's safe to overrule, so I didn't.

Only to copy traceID and (for non-root spans) spanID, because spanID for root spans == traceID.low()

Signed-off-by: Oleksandr Bukaiev <[email protected]>
@AppVeyorBot
Copy link

Build jaeger-client-cpp 89 completed (commit 017fb2314e by @)

@AppVeyorBot
Copy link

Build jaeger-client-cpp 90 completed (commit 5c2ea4fea8 by @)

@yurishkuro
Copy link
Member

yurishkuro commented Feb 17, 2020

I would prefer to stick with the same name Self and not diverge between different Jaeger clients. There is an open question about the sampling in the Go implementation: jaegertracing/jaeger-client-go#411 (comment). I tend to think that your implementation is actually better, although I can see that both scenarios have merit.

FWIW, it's not a requirement that spanID == traceID.low(), just the typical implementation aimed at saving CPU cycles by not generating yet another random ID.

…lang implementations of Jaeger client

2) SpanId is always taken from the SelfRef context


Signed-off-by: Oleksandr Bukaiev <[email protected]>
…alizer_list) is explicit

Signed-off-by: Oleksandr Bukaiev <[email protected]>
@AppVeyorBot
Copy link

Build jaeger-client-cpp 91 failed (commit be62396d5a by @Alek86)

@AppVeyorBot
Copy link

Build jaeger-client-cpp 92 failed (commit a54cfd8498 by @Alek86)

@AppVeyorBot
Copy link

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Please add a section to README, similar to Go client.

src/jaegertracing/Tracer.cpp Outdated Show resolved Hide resolved
examples/App.cpp Outdated Show resolved Hide resolved
src/jaegertracing/Reference.h Outdated Show resolved Hide resolved
src/jaegertracing/Tracer.h Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

@mdouaihy PTAL

Copy link
Contributor

@mdouaihy mdouaihy left a comment

Choose a reason for hiding this comment

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

I think a Unit Test is missing to illustrate the usage and to make sure that the behavior is the desired one.

src/jaegertracing/Tracer.cpp Show resolved Hide resolved
@AppVeyorBot
Copy link

Build jaeger-client-cpp 97 failed (commit 4228e083e0 by @Alek86)

Signed-off-by: Oleksandr Bukaiev <[email protected]>
@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@yurishkuro yurishkuro merged commit 2bce8db into jaegertracing:master Mar 2, 2020
@Alek86 Alek86 deleted the add-jaeger-specific-spanreferencetype-usetheseids branch March 2, 2020 19:55
lrouquette pushed a commit to lrouquette/jaeger-client-cpp that referenced this pull request Nov 2, 2021
…aegertracing#206)

* An extension of enum opentracing::SpanReferenceType, for a new Span.

Only to copy traceID and (for non-root spans) spanID, because spanID for root spans == traceID.low()

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* 1) Renamed useTheseIDs to SelfRef, for consistency between different lang implementations of Jaeger client
2) SpanId is always taken from the SelfRef context


Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Seems like on some compilers jaegertracing::SpanContext::StrMap(initializer_list) is explicit


Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Temporarily commented out the new unit test case body


Signed-off-by: Oleksandr Bukaiev <[email protected]>

* SelfRef only used for creating root spans and can be passed as the only reference to enforce this rule

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Apparently std::exception ctor with a const char* is not standard


Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Updates in README and code comments as per reviewer's request

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Added a testTracer subtest with no selfref to check the github CI result


Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Removed test changes

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Added 2 unittests - a simple span child and a simple self ref

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Added child span to selfref unittest, small changes in new tests

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Show better log if sef ref is used with other references

Signed-off-by: Oleksandr Bukaiev <[email protected]>

* Change in error log if selfref is used with another ref

Signed-off-by: Oleksandr Bukaiev <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants