Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f269fc1

Browse files
authoredFeb 25, 2020
Merge c6deced into 9e1b39c
2 parents 9e1b39c + c6deced commit f269fc1

File tree

7 files changed

+50
-24
lines changed

7 files changed

+50
-24
lines changed
 

‎.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ matrix:
6262
env:
6363
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && CMAKE_OPTIONS='-DCMAKE_BUILD_TYPE=Release
6464
-DJAEGERTRACING_PLUGIN=ON -DBUILD_TESTING=ON -DHUNTER_CONFIGURATION_TYPES=Release'"
65-
branches:
66-
only:
67-
- master
6865
before_install:
6966
- eval "${MATRIX_EVAL}"
7067
- mkdir cmake-download && cd cmake-download && curl -O https://cmake.org/files/v3.10/cmake-3.10.0-rc5-Linux-x86_64.sh

‎CMakeLists.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ include(HunterGate)
1515
option(HUNTER_BUILD_SHARED_LIBS "Build Shared Library" ON)
1616

1717
HunterGate(
18-
URL "https://github.com/ruslo/hunter/archive/v0.23.201.tar.gz"
19-
SHA1 "29f10683f10c7b35e1f599d71542af0c2daa6a01"
18+
URL "https://github.com/cpp-pm/hunter/archive/v0.23.249.tar.gz"
19+
SHA1 "d45d77d8bba9da13e9290a180e0477e90accd89b"
20+
LOCAL # load `${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/config.cmake`
2021
)
2122

2223
project(jaegertracing VERSION 0.5.0)
@@ -341,7 +342,7 @@ if(BUILD_TESTING)
341342
src/jaegertracing/utils/UDPSenderTest.cpp
342343
src/jaegertracing/utils/HTTPTransporterTest.cpp)
343344
target_link_libraries(
344-
UnitTest PRIVATE testutils GTest::main ${JAEGERTRACING_LIB})
345+
UnitTest PRIVATE testutils PUBLIC GTest::main ${JAEGERTRACING_LIB})
345346
add_test(NAME UnitTest COMMAND UnitTest)
346347

347348
update_path_for_test(UnitTest)

‎cmake/Hunter/config.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hunter_config(GTest VERSION 1.8.0-hunter-p11)

‎src/jaegertracing/Span.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void Span::SetBaggageItem(opentracing::string_view restrictedKey,
7676
value,
7777
[this](std::vector<Tag>::const_iterator first,
7878
std::vector<Tag>::const_iterator last) {
79-
logFieldsNoLocking(first, last);
79+
logFieldsNoLocking(SystemClock::now(), first, last);
8080
});
8181
_context = _context.withBaggage(baggage);
8282
}

‎src/jaegertracing/Span.h

+38-16
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,27 @@ class Span : public opentracing::Span {
190190
: itr->second;
191191
}
192192

193+
void Log(opentracing::SystemTime timestamp,
194+
std::initializer_list<
195+
std::pair<opentracing::string_view, opentracing::Value>>
196+
fieldPairs) noexcept override
197+
{
198+
doLog(timestamp, fieldPairs);
199+
}
200+
201+
void Log(opentracing::SystemTime timestamp,
202+
const std::vector<
203+
std::pair<opentracing::string_view, opentracing::Value>>&
204+
fieldPairs) noexcept override
205+
{
206+
doLog(timestamp, fieldPairs);
207+
}
208+
193209
void Log(std::initializer_list<
194210
std::pair<opentracing::string_view, opentracing::Value>>
195211
fieldPairs) noexcept override
196212
{
197-
std::lock_guard<std::mutex> lock(_mutex);
198-
if (!_context.isSampled()) {
199-
return;
200-
}
201-
202-
std::vector<Tag> fields;
203-
fields.reserve(fieldPairs.size());
204-
std::transform(
205-
std::begin(fieldPairs),
206-
std::end(fieldPairs),
207-
std::back_inserter(fields),
208-
[](const std::pair<opentracing::string_view, opentracing::Value>&
209-
pair) { return Tag(pair.first, pair.second); });
210-
logFieldsNoLocking(std::begin(fields), std::end(fields));
213+
doLog(SystemClock::now(), fieldPairs);
211214
}
212215

213216
const SpanContext& context() const noexcept override
@@ -228,12 +231,31 @@ class Span : public opentracing::Span {
228231
bool isFinished() const { return _duration != SteadyClock::duration(); }
229232

230233
template <typename FieldIterator>
231-
void logFieldsNoLocking(FieldIterator first, FieldIterator last) noexcept
234+
void logFieldsNoLocking(const std::chrono::system_clock::time_point& timestamp, FieldIterator first, FieldIterator last) noexcept
232235
{
233-
LogRecord log(SystemClock::now(), first, last);
236+
LogRecord log(timestamp, first, last);
234237
_logs.push_back(log);
235238
}
236239

240+
template <typename Container>
241+
void doLog(opentracing::SystemTime timestamp, Container fieldPairs) noexcept
242+
{
243+
std::lock_guard<std::mutex> lock(_mutex);
244+
if (!_context.isSampled()) {
245+
return;
246+
}
247+
248+
std::vector<Tag> fields;
249+
fields.reserve(fieldPairs.size());
250+
std::transform(
251+
std::begin(fieldPairs),
252+
std::end(fieldPairs),
253+
std::back_inserter(fields),
254+
[](const std::pair<opentracing::string_view, opentracing::Value>&
255+
pair) { return Tag(pair.first, pair.second); });
256+
logFieldsNoLocking(timestamp, std::begin(fields), std::end(fields));
257+
}
258+
237259
void setSamplingPriority(const opentracing::Value& value);
238260

239261
std::shared_ptr<const Tracer> _tracer;

‎src/jaegertracing/SpanContext.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class SpanContext : public opentracing::SpanContext {
167167
forEachBaggageItem(f);
168168
}
169169

170-
std::unique_ptr<opentracing::SpanContext> Clone() const noexcept
170+
std::unique_ptr<opentracing::SpanContext> Clone() const noexcept override
171171
{
172172
std::lock_guard<std::mutex> lock(_mutex);
173173
return std::unique_ptr<opentracing::SpanContext>(

‎src/jaegertracing/TracerTest.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class FakeSpanContext : public opentracing::SpanContext {
5858
{
5959
// Do nothing
6060
}
61+
62+
virtual std::unique_ptr<SpanContext> Clone() const noexcept override
63+
{
64+
return std::unique_ptr<FakeSpanContext>(new FakeSpanContext());
65+
}
6166
};
6267

6368
template <typename BaseWriter>

0 commit comments

Comments
 (0)
This repository has been archived.