This repository was archived by the owner on Aug 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +18
-10
lines changed Expand file tree Collapse file tree 5 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ if(HUNTER_ENABLED)
39
39
endif ()
40
40
endif ()
41
41
42
- project (jaegertracing VERSION 0.0.5 )
42
+ project (jaegertracing VERSION 0.0.7 )
43
43
44
44
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
45
45
CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ class Tracer : public opentracing::Tracer,
194
194
const std::shared_ptr<logging::Logger>& logger,
195
195
const std::shared_ptr<metrics::Metrics>& metrics)
196
196
: _serviceName(serviceName)
197
- , _hostIPv4(net::IPAddress::host (AF_INET))
197
+ , _hostIPv4(net::IPAddress::localIP (AF_INET))
198
198
, _sampler(sampler)
199
199
, _reporter(reporter)
200
200
, _metrics(metrics)
@@ -219,9 +219,7 @@ class Tracer : public opentracing::Tracer,
219
219
_logger->error (" Unable to determine this host's IP address" );
220
220
}
221
221
else {
222
- std::ostringstream oss;
223
- oss << _hostIPv4;
224
- _tags.push_back (Tag (kTracerIPTagKey , oss.str ()));
222
+ _tags.push_back (Tag (kTracerIPTagKey , _hostIPv4.host ()));
225
223
}
226
224
227
225
std::random_device device;
Original file line number Diff line number Diff line change @@ -115,6 +115,16 @@ TEST(Tracer, testTracer)
115
115
options.references .emplace_back (opentracing::SpanReferenceType::ChildOfRef,
116
116
&debugCtx);
117
117
118
+ const auto & tags = tracer->tags ();
119
+ auto itr = std::find_if (
120
+ std::begin (tags),
121
+ std::end (tags),
122
+ [](const Tag& tag) { return tag.key () == kTracerIPTagKey ; });
123
+ ASSERT_NE (std::end (tags), itr);
124
+ ASSERT_TRUE (itr->value ().is <std::string>());
125
+ ASSERT_EQ (net::IPAddress::v4 (itr->value ().get <std::string>()).host (),
126
+ net::IPAddress::localIP (AF_INET).host ());
127
+
118
128
std::unique_ptr<Span> span (static_cast <Span*>(
119
129
tracer->StartSpanWithOptions (" test-operation" , options).release ()));
120
130
ASSERT_TRUE (static_cast <bool >(span));
Original file line number Diff line number Diff line change @@ -34,14 +34,14 @@ struct IfAddrDeleter : public std::function<void(ifaddrs*)> {
34
34
35
35
} // anonymous namespace
36
36
37
- IPAddress IPAddress::host (int family)
37
+ IPAddress IPAddress::localIP (int family)
38
38
{
39
- return host ([family](const ifaddrs* ifAddr) {
39
+ return localIP ([family](const ifaddrs* ifAddr) {
40
40
return ifAddr->ifa_addr ->sa_family == family;
41
41
});
42
42
}
43
43
44
- IPAddress IPAddress::host (std::function<bool (const ifaddrs*)> filter)
44
+ IPAddress IPAddress::localIP (std::function<bool (const ifaddrs*)> filter)
45
45
{
46
46
auto * ifAddrRawPtr = static_cast <ifaddrs*>(nullptr );
47
47
getifaddrs (&ifAddrRawPtr);
Original file line number Diff line number Diff line change @@ -64,9 +64,9 @@ class IPAddress {
64
64
return versionFromString (ip, port, AF_INET6);
65
65
}
66
66
67
- static IPAddress host (int family);
67
+ static IPAddress localIP (int family);
68
68
69
- static IPAddress host (std::function<bool (const ifaddrs*)> filter);
69
+ static IPAddress localIP (std::function<bool (const ifaddrs*)> filter);
70
70
71
71
IPAddress ()
72
72
: _addr()
You can’t perform that action at this time.
0 commit comments