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

Record logs passed with Span::FinishWithOptions #58

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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