#include "common/valgrind.h"
#include "common/version.h"
#include "common/strtol.h"
+#include "common/zipkin_trace.h"
#include "include/color.h"
#include <errno.h>
DEFINE_CEPH_FEATURE(59, 1, FS_BTIME)
DEFINE_CEPH_FEATURE(59, 1, FS_CHANGE_ATTR) // overlap
DEFINE_CEPH_FEATURE(59, 1, MSG_ADDR2) // overlap
+DEFINE_CEPH_FEATURE(60, 1, BLKIN_TRACING) // *do not share this bit*
DEFINE_CEPH_FEATURE(61, 1, RESERVED2) // unused, but slow down!
DEFINE_CEPH_FEATURE(62, 1, RESERVED) // do not use; used as a sentinal
DEFINE_CEPH_FEATURE_DEPRECATED(63, 1, RESERVED_BROKEN, LUMINOUS) // client-facing
+/*
+ * conditionally include blkin in CEPH_FEATURES_ALL/SUPPORTED_DEFAULT
+ */
+#ifdef WITH_BLKIN
+#define CEPH_FEATURES_BLKIN CEPH_FEATURE_BLKIN_TRACING
+#else
+#define CEPH_FEATURES_BLKIN 0
+#endif
+
/*
* Features supported. Should be everything above.
*/
CEPH_FEATURE_SERVER_LUMINOUS | \
CEPH_FEATURE_RESEND_ON_SPLIT | \
CEPH_FEATURE_RADOS_BACKOFF | \
+ CEPH_FEATURES_BLKIN | \
0ULL)
#define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL
}
+WRITE_RAW_ENCODER(blkin_trace_info)
+
+void Message::encode_trace(bufferlist &bl, uint64_t features) const
+{
+#ifdef WITH_BLKIN
+ if (features & CEPH_FEATURE_BLKIN_TRACING)
+ ::encode(*trace.get_info(), bl);
+#endif
+}
+
+void Message::decode_trace(bufferlist::iterator &p, bool create)
+{
+#ifdef WITH_BLKIN
+ if (!connection)
+ return;
+
+ const auto endpoint = connection->get_messenger()->get_trace_endpoint();
+ blkin_trace_info info = {};
+
+ // only decode a trace if both sides of the connection agree
+ if (connection->has_feature(CEPH_FEATURE_BLKIN_TRACING))
+ ::decode(info, p);
+
+ if (info.trace_id) {
+ trace.init(get_type_name(), endpoint, &info, true);
+ trace.event("decoded trace");
+ } else if (create) { // create a trace even if we didn't get one on the wire
+ trace.init(get_type_name(), endpoint);
+ trace.event("created trace");
+ }
+ trace.keyval("tid", get_tid());
+ trace.keyval("entity type", get_source().type_str());
+ trace.keyval("entity num", get_source().num());
+#endif
+}
+
+
// This routine is not used for ordinary messages, but only when encapsulating a message
// for forwarding and routing. It's also used in a backward compatibility test, which only
// effectively tests backward compability for those functions. To avoid backward compatibility
#include "include/types.h"
#include "include/buffer.h"
#include "common/Throttle.h"
+#include "common/zipkin_trace.h"
#include "msg_types.h"
#include "common/RefCountedObj.h"
bi::list_member_hook<> dispatch_q;
public:
+ // zipkin tracing
+ ZTracer::Trace trace;
+ void encode_trace(bufferlist &bl, uint64_t features) const;
+ void decode_trace(bufferlist::iterator &p, bool create = false);
+
class CompletionHook : public Context {
protected:
Message *m;
if (byte_throttler)
byte_throttler->put(payload.length() + middle.length() + data.length());
release_message_throttle();
+ trace.event("message destructed");
/* call completion hooks (if any) */
if (completion_hook)
completion_hook->complete(0);
// vim: ts=8 sw=2 smarttab
#include <random>
+#include <netdb.h>
#include "include/Spinlock.h"
+
#include "include/types.h"
#include "Messenger.h"
return nullptr;
}
+void Messenger::set_endpoint_addr(const entity_addr_t& a,
+ const entity_name_t &name)
+{
+ size_t hostlen;
+ if (a.get_family() == AF_INET)
+ hostlen = sizeof(struct sockaddr_in);
+ else if (a.get_family() == AF_INET6)
+ hostlen = sizeof(struct sockaddr_in6);
+ else
+ hostlen = 0;
+
+ if (hostlen) {
+ char buf[NI_MAXHOST] = { 0 };
+ getnameinfo(a.get_sockaddr(), hostlen, buf, sizeof(buf),
+ NULL, 0, NI_NUMERICHOST);
+
+ trace_endpoint.copy_ip(buf);
+ }
+ trace_endpoint.set_port(a.get_port());
+}
+
/*
* Pre-calculate desired software CRC settings. CRC computation may
* be disabled by default for some transports (e.g., those with strong
private:
list<Dispatcher*> dispatchers;
list <Dispatcher*> fast_dispatchers;
+ ZTracer::Endpoint trace_endpoint;
+
+ void set_endpoint_addr(const entity_addr_t& a,
+ const entity_name_t &name);
protected:
/// the "name" of the local daemon. eg client.99
* or use the create() function.
*/
Messenger(CephContext *cct_, entity_name_t w)
- : my_inst(),
+ : trace_endpoint("0.0.0.0", 0, "Messenger"),
+ my_inst(),
default_send_priority(CEPH_MSG_PRIO_DEFAULT), started(false),
magic(0),
socket_priority(-1),
/**
* set messenger's address
*/
- virtual void set_myaddr(const entity_addr_t& a) { my_inst.addr = a; }
+ virtual void set_myaddr(const entity_addr_t& a) {
+ my_inst.addr = a;
+ set_endpoint_addr(a, my_inst.name);
+ }
public:
+ /**
+ * @return the zipkin trace endpoint
+ */
+ const ZTracer::Endpoint* get_trace_endpoint() const {
+ return &trace_endpoint;
+ }
+
/**
* Retrieve the Messenger's name.
*