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

First pull request #2

Merged
merged 43 commits into from
Nov 8, 2017
Merged

First pull request #2

merged 43 commits into from
Nov 8, 2017

Conversation

isaachier
Copy link
Contributor

Entire C++ client here.

.travis.yml Outdated
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"

branches:
only:
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The matrix is mostly for later so I can use different compilers for testing. Also potentially for Mac building. Right now, even basic build is failing because of broken dependency I've been fixing. Once that is fixed, will introduce more builds.

Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
…ransport

Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
@codecov
Copy link

codecov bot commented Oct 25, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@b8f0e1d). Click here to learn what that means.
The diff coverage is 88.11%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #2   +/-   ##
=========================================
  Coverage          ?   88.04%           
=========================================
  Files             ?       91           
  Lines             ?     2116           
  Branches          ?      185           
=========================================
  Hits              ?     1863           
  Misses            ?      189           
  Partials          ?       64
Impacted Files Coverage Δ
src/jaegertracing/utils/UDPClient.h 73.91% <ø> (ø)
src/jaegertracing/utils/ErrorUtil.h 100% <ø> (ø)
src/jaegertracing/utils/YAML.h 100% <ø> (ø)
src/jaegertracing/utils/RateLimiter.h 86.66% <ø> (ø)
src/jaegertracing/utils/UDPClient.cpp 100% <ø> (ø)
src/jaegertracing/utils/HexParsing.h 82.75% <ø> (ø)
src/jaegertracing/reporters/Reporter.h 100% <100%> (ø)
src/jaegertracing/TraceID.cpp 100% <100%> (ø)
src/jaegertracing/reporters/NullReporter.h 100% <100%> (ø)
src/jaegertracing/metrics/Metrics.cpp 100% <100%> (ø)
... and 81 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8f0e1d...66de9d2. Read the comment docs.

Signed-off-by: Isaac Hier <isaachier@gmail.com>
@isaachier
Copy link
Contributor Author

Finally got the coverage working. Not 100%, but getting there. Let me know what you think.

Signed-off-by: Isaac Hier <ihier@uber.com>
Isaac Hier added 2 commits October 25, 2017 16:02
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
isaachier and others added 2 commits October 26, 2017 07:34
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Isaac Hier and others added 2 commits October 26, 2017 15:54
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Isaac Hier added 2 commits November 1, 2017 11:51
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
@isaachier isaachier force-pushed the master branch 2 times, most recently from b021847 to 383c917 Compare November 2, 2017 23:50
Signed-off-by: Isaac Hier <isaachier@gmail.com>
isaachier and others added 3 commits November 2, 2017 20:20
Signed-off-by: Isaac Hier <isaachier@gmail.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
CMakeLists.txt Outdated
endforeach()
endif()

set(SRC

Choose a reason for hiding this comment

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

does Hunter automatically generate this for us or do we need to append any new file to this list when we create one?


CURRENT_YEAR = datetime.today().year

MIT_LICENSE_BLOB = """Copyright (c) %d, Uber Technologies, Inc

Choose a reason for hiding this comment

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

is this reference to the MIT license still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I think I took this from the Go client. Seems the script there deleted those lines in jaegertracing/jaeger-client-go@cddab85. Will do the same.

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2017, Uber Technologies, Inc

Choose a reason for hiding this comment

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

this file is the only file using MIT license. I think it has to be regenerated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh lol fair point. I think the .in screwed up the pattern. Will change the script to get this file too.

Isaac Hier and others added 4 commits November 6, 2017 13:00
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <isaachier@gmail.com>
@isaachier
Copy link
Contributor Author

@black-adder can you accept?

@black-adder black-adder merged commit dd369e2 into jaegertracing:master Nov 8, 2017
@isaachier
Copy link
Contributor Author

Yay! Thanks!

tudor added a commit to rockset/jaeger-client-cpp that referenced this pull request Sep 15, 2018
`Span::isFinished()` returns true iff the span's duration is zero.
So, if `steady_clock::now()` returns the same value at span creation as
at `Finish()` (unlikely, but possible, especially in virtualized
environments), the following scenario can happen:

- `Span::FinishWithOptions` sets `_duration` to zero
- and then calls `reportSpan`, which calls `RemoteReporter::report`
- which acquires the reporter mutex and
- adds the span to the reporter's `_queue`

Later:
- `RemoteReporter::sweepQueue` acquires the reporter mutex
- `RemoteReporter::sweepQueue` makes a copy of the span
(https://github.com/jaegertracing/jaeger-client-cpp/blob/7e9a135b362c47f7e4d42e0693b05b91a70e6888/src/jaegertracing/reporters/RemoteReporter.cpp#L95)
- The span is serialized in `RemoteReporter::sendSpan`
- The span (the copy made above) needs to be destroyed because the block in `sweepQueue` ends.
- The span's destructor is called, which calls `FinishWithOptions` again
- ... which sees that `_duration` is zero, so `isFinished()` returns
false:
https://github.com/jaegertracing/jaeger-client-cpp/blob/7e9a135b362c47f7e4d42e0693b05b91a70e6888/src/jaegertracing/Span.cpp#L94
- so it tries to call `reportSpan` again
- which tries to acquire the reporter's mutex
- but we're holding the lock in `sweepQueue`, so
- deadlock.

Relevant stack trace:
```
(gdb) bt
(gdb) bt
 #0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
 jaegertracing#1  0x00007fb09c722023 in __GI___pthread_mutex_lock (mutex=0x7fb088b1c1c0) at ../nptl/pthread_mutex_lock.c:78
 jaegertracing#2  0x00007fb08860987b in jaegertracing::reporters::RemoteReporter::report(jaegertracing::Span const&) () from /usr/local/lib/libjaegertracing_plugin.so
 jaegertracing#3  0x00007fb0885b6506 in jaegertracing::Span::FinishWithOptions(opentracing::v2::FinishSpanOptions const&) [clone .localalias.361] () from /usr/local/lib/libjaegertracing_plugin.so
 jaegertracing#4  0x00007fb08860849a in jaegertracing::Span::~Span() [clone .constprop.253] () from /usr/local/lib/libjaegertracing_plugin.so
 jaegertracing#5  0x00007fb08860a8fa in jaegertracing::reporters::RemoteReporter::sweepQueue() () from /usr/local/lib/libjaegertracing_plugin.so
 jaegertracing#6  0x00007fb0886f2f5f in execute_native_thread_routine () from /usr/local/lib/libjaegertracing_plugin.so
 jaegertracing#7  0x00007fb09c71f6db in start_thread (arg=0x7fb087574700) at pthread_create.c:463
 jaegertracing#8  0x00007fb0989ae88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
```

Fixed by enforcing a minimum span duration of 1 `SteadyClock` tick.

Signed-off-by: Tudor Bosman <tudor@rockset.com>
isaachier pushed a commit that referenced this pull request Sep 18, 2018
* Fix deadlock if steady_clock::now() returns the same value twice

`Span::isFinished()` returns true iff the span's duration is zero.
So, if `steady_clock::now()` returns the same value at span creation as
at `Finish()` (unlikely, but possible, especially in virtualized
environments), the following scenario can happen:

- `Span::FinishWithOptions` sets `_duration` to zero
- and then calls `reportSpan`, which calls `RemoteReporter::report`
- which acquires the reporter mutex and
- adds the span to the reporter's `_queue`

Later:
- `RemoteReporter::sweepQueue` acquires the reporter mutex
- `RemoteReporter::sweepQueue` makes a copy of the span
(https://github.com/jaegertracing/jaeger-client-cpp/blob/7e9a135b362c47f7e4d42e0693b05b91a70e6888/src/jaegertracing/reporters/RemoteReporter.cpp#L95)
- The span is serialized in `RemoteReporter::sendSpan`
- The span (the copy made above) needs to be destroyed because the block in `sweepQueue` ends.
- The span's destructor is called, which calls `FinishWithOptions` again
- ... which sees that `_duration` is zero, so `isFinished()` returns
false:
https://github.com/jaegertracing/jaeger-client-cpp/blob/7e9a135b362c47f7e4d42e0693b05b91a70e6888/src/jaegertracing/Span.cpp#L94
- so it tries to call `reportSpan` again
- which tries to acquire the reporter's mutex
- but we're holding the lock in `sweepQueue`, so
- deadlock.

Relevant stack trace:
```
(gdb) bt
(gdb) bt
 #0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
 #1  0x00007fb09c722023 in __GI___pthread_mutex_lock (mutex=0x7fb088b1c1c0) at ../nptl/pthread_mutex_lock.c:78
 #2  0x00007fb08860987b in jaegertracing::reporters::RemoteReporter::report(jaegertracing::Span const&) () from /usr/local/lib/libjaegertracing_plugin.so
 #3  0x00007fb0885b6506 in jaegertracing::Span::FinishWithOptions(opentracing::v2::FinishSpanOptions const&) [clone .localalias.361] () from /usr/local/lib/libjaegertracing_plugin.so
 #4  0x00007fb08860849a in jaegertracing::Span::~Span() [clone .constprop.253] () from /usr/local/lib/libjaegertracing_plugin.so
 #5  0x00007fb08860a8fa in jaegertracing::reporters::RemoteReporter::sweepQueue() () from /usr/local/lib/libjaegertracing_plugin.so
 #6  0x00007fb0886f2f5f in execute_native_thread_routine () from /usr/local/lib/libjaegertracing_plugin.so
 #7  0x00007fb09c71f6db in start_thread (arg=0x7fb087574700) at pthread_create.c:463
 #8  0x00007fb0989ae88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
```

Fixed by enforcing a minimum span duration of 1 `SteadyClock` tick.

Signed-off-by: Tudor Bosman <tudor@rockset.com>

* fix typo

Signed-off-by: Tudor Bosman <tudor@rockset.com>
@DavitSo DavitSo mentioned this pull request Feb 8, 2019
@EasonFeng5870 EasonFeng5870 mentioned this pull request Jul 7, 2020
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.

3 participants