Skip to content

Commit 8d138d3

Browse files
authored
Tracer ID: uint64 (#25)
* Set tracer_id explicitly, ignore lightstep.guid * Release 0.16
1 parent 64f6777 commit 8d138d3

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# by homebrew, see the commands to set PKG_CONFIG_PATH in build.sh.
55

66
AC_PREREQ([2.69])
7-
AC_INIT([lightstep-tracer-cpp], [0.15],
7+
AC_INIT([lightstep-tracer-cpp], [0.16],
88
[https://github.com/lightstep/lightstep-tracer-cpp/issues])
99
LT_INIT([disable-shared])
1010
AM_INIT_AUTOMAKE([1.14 foreign subdir-objects])

src/c++11/impl.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ TracerImpl::TracerImpl(const TracerOptions& options_in)
5353
rand_source_(std::random_device()()),
5454
tracer_start_time_(Clock::now()) {
5555

56+
tracer_id_ = GetOneId();
57+
5658
if (options_.tracer_attributes.find(ComponentNameKey) == options_.tracer_attributes.end()) {
5759
options_.tracer_attributes.emplace(std::make_pair(ComponentNameKey, util::program_name()));
5860
}
59-
if (options_.tracer_attributes.find(TracerIDKey) == options_.tracer_attributes.end()) {
60-
options_.tracer_attributes.emplace(std::make_pair(TracerIDKey, uint64ToHex(GetOneId())));
61+
// Note: drop the TracerIDKey, this is copied from tracer_id_.
62+
auto guid_lookup = options_.tracer_attributes.find(TracerIDKey);
63+
if (guid_lookup != options_.tracer_attributes.end()) {
64+
options_.tracer_attributes.erase(guid_lookup);
6165
}
6266

6367
options_.tracer_attributes.emplace(std::make_pair(PlatformNameKey, "c++11"));

src/c++11/lightstep/impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class TracerImpl {
7272
const std::string& component_name() const { return component_name_; }
7373
const std::string& access_token() const { return options_.access_token; }
7474

75+
uint64_t tracer_id() const { return tracer_id_; }
76+
7577
TimeStamp tracer_start_time() const { return tracer_start_time_; }
7678
const Attributes& tracer_attributes() const { return options_.tracer_attributes; }
7779

@@ -106,6 +108,7 @@ class TracerImpl {
106108
uint64_t GetOneId();
107109

108110
TracerOptions options_;
111+
uint64_t tracer_id_;
109112
std::shared_ptr<Recorder> recorder_;
110113

111114
// Protects rand_source_, recorder_.

src/c++11/tracer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ ReportBuilder::ReportBuilder(const TracerImpl &impl)
7474
for (const auto& tt : impl.options().tracer_attributes) {
7575
*tracer->mutable_tags()->Add() = util::make_kv(tt.first, tt.second);
7676

77-
if (tt.first == TracerIDKey) {
78-
tracer->set_tracer_id(util::stringToUint64(tt.second));
79-
}
77+
tracer->set_tracer_id(impl.tracer_id());
8078
}
8179
preamble_.mutable_auth()->set_access_token(impl.access_token());
8280
}

test/c++11/flushproto_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ int main() {
5757
topts.collector_host = "";
5858
topts.collector_port = 9998;
5959
topts.collector_encryption = "";
60+
topts.tracer_attributes["lightstep.guid"] = "invalid";
6061
topts.guid_generator = my_guids;
6162

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

0 commit comments

Comments
 (0)