Skip to content

Tracer ID: uint64 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2016
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
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# by homebrew, see the commands to set PKG_CONFIG_PATH in build.sh.

AC_PREREQ([2.69])
AC_INIT([lightstep-tracer-cpp], [0.15],
AC_INIT([lightstep-tracer-cpp], [0.16],
[https://github.com/lightstep/lightstep-tracer-cpp/issues])
LT_INIT([disable-shared])
AM_INIT_AUTOMAKE([1.14 foreign subdir-objects])
Expand Down
8 changes: 6 additions & 2 deletions src/c++11/impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ TracerImpl::TracerImpl(const TracerOptions& options_in)
rand_source_(std::random_device()()),
tracer_start_time_(Clock::now()) {

tracer_id_ = GetOneId();

if (options_.tracer_attributes.find(ComponentNameKey) == options_.tracer_attributes.end()) {
options_.tracer_attributes.emplace(std::make_pair(ComponentNameKey, util::program_name()));
}
if (options_.tracer_attributes.find(TracerIDKey) == options_.tracer_attributes.end()) {
options_.tracer_attributes.emplace(std::make_pair(TracerIDKey, uint64ToHex(GetOneId())));
// Note: drop the TracerIDKey, this is copied from tracer_id_.
auto guid_lookup = options_.tracer_attributes.find(TracerIDKey);
if (guid_lookup != options_.tracer_attributes.end()) {
options_.tracer_attributes.erase(guid_lookup);
}

options_.tracer_attributes.emplace(std::make_pair(PlatformNameKey, "c++11"));
Expand Down
3 changes: 3 additions & 0 deletions src/c++11/lightstep/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class TracerImpl {
const std::string& component_name() const { return component_name_; }
const std::string& access_token() const { return options_.access_token; }

uint64_t tracer_id() const { return tracer_id_; }

TimeStamp tracer_start_time() const { return tracer_start_time_; }
const Attributes& tracer_attributes() const { return options_.tracer_attributes; }

Expand Down Expand Up @@ -106,6 +108,7 @@ class TracerImpl {
uint64_t GetOneId();

TracerOptions options_;
uint64_t tracer_id_;
std::shared_ptr<Recorder> recorder_;

// Protects rand_source_, recorder_.
Expand Down
4 changes: 1 addition & 3 deletions src/c++11/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ ReportBuilder::ReportBuilder(const TracerImpl &impl)
for (const auto& tt : impl.options().tracer_attributes) {
*tracer->mutable_tags()->Add() = util::make_kv(tt.first, tt.second);

if (tt.first == TracerIDKey) {
tracer->set_tracer_id(util::stringToUint64(tt.second));
}
tracer->set_tracer_id(impl.tracer_id());
Copy link

Choose a reason for hiding this comment

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

Not clear to me why this is inside of the loop

}
preamble_.mutable_auth()->set_access_token(impl.access_token());
}
Expand Down
1 change: 1 addition & 0 deletions test/c++11/flushproto_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ int main() {
topts.collector_host = "";
topts.collector_port = 9998;
topts.collector_encryption = "";
topts.tracer_attributes["lightstep.guid"] = "invalid";
topts.guid_generator = my_guids;

lightstep::Tracer::InitGlobal(NewUserDefinedTransportLightStepTracer(topts, [](const lightstep::TracerImpl& impl) {
Expand Down