Skip to content

Commit 67a2fc4

Browse files
authored
Jmacd/static method grpc names (#24)
* Add lightstep::CollectorServiceFullName() and lightstep::CollectorMethodName() * Bump to 0.15 * Light testing / regression-prevention
1 parent de13d63 commit 67a2fc4

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
EXTRA_DIST = LICENSE lightstep-tracer-common
1+
EXTRA_DIST = LICENSE lightstep-tracer-common/collector.proto
22

33
SUBDIRS = src test

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.14],
7+
AC_INIT([lightstep-tracer-cpp], [0.15],
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/lightstep/options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TracerOptions {
3838
Attributes tracer_attributes;
3939

4040
// Optional: a user-defined guid generator to use.
41+
// TODO remove this in favor of thread-local PRNGs?
4142
std::function<uint64_t()> guid_generator;
4243
};
4344

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ typedef std::function<std::unique_ptr<Recorder>(const TracerImpl&)> RecorderFact
119119

120120
Tracer NewUserDefinedTransportLightStepTracer(const TracerOptions& topts, RecorderFactory rf);
121121

122+
// For use routing ReportRequests via generic gRPC endpoints, use these names:
123+
const std::string& CollectorServiceFullName();
124+
const std::string& CollectorMethodName();
125+
122126
} // namespace lightstep
123127

124128
#endif // __LIGHTSTEP_TRACER_H__

src/c++11/tracer.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace {
1010

1111
std::atomic<ImplPtr*> global_tracer;
1212

13+
// Note: These must be kept up-to-date with the collector endpoint
14+
// gRPC service and method names.
15+
const char collectorServiceFullName[] = "lightstep.collector.CollectorService";
16+
const char collectorMethodName[] = "Report";
17+
1318
} // namespace
1419

1520
BuiltinCarrierFormat BuiltinCarrierFormat::BinaryCarrier{BuiltinCarrierFormat::Binary};
@@ -76,4 +81,14 @@ ReportBuilder::ReportBuilder(const TracerImpl &impl)
7681
preamble_.mutable_auth()->set_access_token(impl.access_token());
7782
}
7883

84+
const std::string& CollectorServiceFullName() {
85+
static std::string name = collectorServiceFullName;
86+
return name;
87+
}
88+
89+
const std::string& CollectorMethodName() {
90+
static std::string name = collectorMethodName;
91+
return name;
92+
}
93+
7994
} // namespace lightstep

test/c++11/flushproto_test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <vector>
22
#include <iostream>
33
#include <mutex>
4+
#include <sstream>
45

56
#include "lightstep/tracer.h"
67
#include "lightstep/impl.h"
@@ -36,8 +37,20 @@ uint64_t my_guids() {
3637
return unsafe++;
3738
}
3839

40+
void check_tracer_names() throw(error) {
41+
// The official value is not exported from gRPC, so hard-code it again:
42+
const char grpc_path[] = "/lightstep.collector.CollectorService/Report";
43+
std::stringstream assembled;
44+
assembled << "/" << lightstep::CollectorServiceFullName() << "/" << lightstep::CollectorMethodName();
45+
if (assembled.str() != grpc_path) {
46+
throw error("Incorrect gRPC service and method names hard-coded");
47+
}
48+
}
49+
3950
int main() {
4051
try {
52+
check_tracer_names();
53+
4154
lightstep::TracerOptions topts;
4255

4356
topts.access_token = "i_am_an_access_token";

0 commit comments

Comments
 (0)