Skip to content

Commit

Permalink
Merge branch 'save-finish-span-logs' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ringerc committed Feb 8, 2018
2 parents f66ad60 + c308b55 commit 2badc21
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/jaegertracing/LogRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <type_traits>
#include <vector>

#include <opentracing/span.h>

namespace jaegertracing {

class LogRecord {
Expand All @@ -45,6 +47,12 @@ class LogRecord {
{
}

LogRecord(const opentracing::LogRecord & other)
: _timestamp(other.timestamp),
_fields(other.fields.begin(), other.fields.end())
{
}

const Clock::time_point& timestamp() const { return _timestamp; }

const std::vector<Tag>& fields() const { return _fields; }
Expand Down
4 changes: 4 additions & 0 deletions src/jaegertracing/Span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ void Span::FinishWithOptions(
}
_duration = finishTimeSteady - _startTimeSteady;
tracer = _tracer;

std::copy(finishSpanOptions.log_records.begin(),
finishSpanOptions.log_records.end(),
std::back_inserter(_logs));
}

// Call `reportSpan` even for non-sampled traces.
Expand Down
7 changes: 7 additions & 0 deletions src/jaegertracing/Tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class Tag {
{
}

template <typename ValueArg>
Tag(const std::pair<std::string,ValueArg> & tag_pair)
: _key(tag_pair.first)
, _value(tag_pair.second)
{
}

bool operator==(const Tag& rhs) const
{
return _key == rhs._key && _value == rhs._value;
Expand Down
7 changes: 6 additions & 1 deletion src/jaegertracing/TracerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ TEST(Tracer, testTracer)
ASSERT_EQ("test-baggage-item-value",
span->BaggageItem("test-baggage-item-key"));
span->Log({ { "log-bool", true } });
span->Finish();
opentracing::FinishSpanOptions foptions;
opentracing::LogRecord lr{};
lr.fields = { {"options-log", "yep"} };
foptions.log_records.push_back(std::move(lr));
lr.timestamp = opentracing::SystemClock::now();
span->FinishWithOptions(foptions);
ASSERT_GE(Span::SteadyClock::now(),
span->startTimeSteady() + span->duration());
span->SetOperationName("test-set-operation-after-finish");
Expand Down

0 comments on commit 2badc21

Please sign in to comment.