-
Notifications
You must be signed in to change notification settings - Fork 50
/
main.cpp
43 lines (40 loc) · 1.37 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <lightstep/tracer.h>
#include <cassert>
#include <chrono>
#include <cstdlib> // for std::getenv
#include <iostream>
#include <string>
#include <thread>
static void MakeSpan(opentracing::Tracer& tracer, int span_index) {
std::cout << "Make Span: " << span_index << "\n";
auto span = tracer.StartSpan("span_" + std::to_string(span_index));
assert(span != nullptr);
for (int tag_index = 0; tag_index < 25; ++tag_index) {
span->SetTag("tag_" + std::to_string(tag_index), tag_index);
}
}
int main() {
lightstep::LightStepTracerOptions options;
// See https://docs.lightstep.com/docs/developer-mode for instructions on
// setting up a LightStep developer satellite on localhost:8360.
options.collector_plaintext = true;
options.satellite_endpoints = {{"localhost", 8360}};
options.use_stream_recorder = true;
options.verbose = true;
options.component_name = "Stream";
if (const char* access_token = std::getenv("LIGHTSTEP_ACCESS_TOKEN")) {
options.access_token = access_token;
} else {
std::cerr << "You must set the environmental variable "
"`LIGHTSTEP_ACCESS_TOKEN` to your access token!\n";
return -1;
}
auto tracer = MakeLightStepTracer(std::move(options));
assert(tracer != nullptr);
for (int i = 0; i < 1000; ++i) {
MakeSpan(*tracer, i);
}
std::cout << "Closing tracer\n";
tracer->Close();
return 0;
}