Skip to content

Conversation

@jmcomets
Copy link
Contributor

I noticed no field logging was implemented and therefore implemented it using
the same ideas as zipkin-go-opentracing.

@rnburn
Copy link
Owner

rnburn commented Apr 13, 2018

Thanks @jmcomets - I'd be glad to have this functionality added in.

I'll try to review this soon.

log_records.swap(log_records_);
log_records.reserve(options.log_records.size());
std::copy(options.log_records.begin(), options.log_records.end(),
std::back_inserter(log_records));
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure we need to be making copies like this. Could we instead add a static function called something like appendLogAnnotations and then replace this with something like

appendLogAnnotations(log_records_, span_);
appendLogAnnotations(options.log_records, span_);

@rnburn
Copy link
Owner

rnburn commented Apr 13, 2018

annotation.setKey(key);
ValueVisitor value_visitor{annotation, value};
apply_visitor(value_visitor, value);
annotation.setValue(str);
Copy link
Owner

Choose a reason for hiding this comment

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

Can you change this to

annotate.setValue(apply_visitor(value_visitor, value));

or

std::string str = apply_visitor(value_visitor, value);
annotate.setValue(std::move(str));

so that we can potentially avoid the copy with move semantics.

void Log(std::initializer_list<std::pair<string_view, Value>> fields) noexcept override {
std::lock_guard<std::mutex> lock_guard{mutex_};
log_records_.push_back({ SystemClock::now(), { fields.begin(), fields.end() } });
}
Copy link
Owner

Choose a reason for hiding this comment

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

This can potentially throw std::bad_alloc, so you need a try/catch block here like what's done in SetTag.

@rnburn
Copy link
Owner

rnburn commented Apr 20, 2018

@jmcomets I actually had setValue use non-string values at one point, but I changed it to strings because the non-strings broke jaeger's zipkin compatibility mode.

According to openzipkin/zipkin#939 (comment), non-string binary annotations aren't really supported.

@jmcomets
Copy link
Contributor Author

jmcomets commented Apr 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants