BASIC ARCHITECTURE AND TERMINOLOGY
----------------------------------
-* TRACE: A trace shows the data/execution path through a system.
-* SPAN: A single unit of a trace, it is a data structure that stores
- information like operation name, timestamps, ordering in a trace.
-* JAEGER CLIENT: language-specific implementations of the OpenTracing API.
-* JAEGER AGENT: a daemon that listens for spans sent over User Datagram Protocol.
- The agent is meant to be placed on the same host as the instrumented
- application. (acts like a sidecar listener)
-* JAEGER COLLECTOR: Jaeger agent sends the spans to this daemon which then
- stitches the spans together to form a trace(if enabled, also persists a database
- for these traces)
-* JAEGER QUERY AND CONSOLE FRONTEND: UI based frontend to checkout the jaeger
- traces, navigate to http://localhost:16686 (if using default `all-in-one
- docker <https://www.jaegertracing.io/docs/1.22/getting-started/#all-in-one>`_ to access the Jaeger UI.
+refer to the `Ceph Tracing documentation <../../../jaegertracing/#basic-architecture-and-terminology>`_
+
HOW TO GET STARTED USING TRACING?
---------------------------------
$ bin/rados -p test bench 5 write --no-cleanup
.. seealso::
- `using-jaeger-cpp-client-for-distributed-tracing-in-ceph <https://medium.com/@deepikaupadhyay/using-jaeger-cpp-client-for-distributed-tracing-in-ceph-8b1f4906ca2>`_
+ `using-jaeger-cpp-client-for-distributed-tracing-in-ceph <https://medium.com/@deepikaupadhyay/using-jaeger-cpp-client-for-distributed-tracing-in-ceph-8b1f4906ca2>`
\ No newline at end of file
releases/index
security/index
Glossary <glossary>
+ Tracing <jaegertracing/index>
--- /dev/null
+JAEGER- DISTRIBUTED TRACING
+===========================
+
+Jaeger provides ready to use tracing services for distributed
+systems and is becoming the widely used standard because of their simplicity and
+standardization.
+
+
+BASIC ARCHITECTURE AND TERMINOLOGY
+----------------------------------
+
+* TRACE: A trace shows the data/execution path through a system.
+* SPAN: A single unit of a trace, it is a data structure that stores
+ information like operation name, timestamps, ordering in a trace.
+* JAEGER CLIENT: language-specific implementations of the OpenTracing API.
+* JAEGER AGENT: a daemon that listens for spans sent over User Datagram Protocol.
+ The agent is meant to be placed on the same host as the instrumented
+ application. (acts like a sidecar listener)
+* JAEGER COLLECTOR: Jaeger agent sends the spans to this daemon which then
+ stitches the spans together to form a trace(if enabled, also persists a database
+ for these traces)
+* JAEGER QUERY AND CONSOLE FRONTEND: UI based frontend to checkout the jaeger
+ traces, navigate to http://<jaeger frontend host>:16686
+
+
+read more about jaeger tracing:.
+
+ https://medium.com/opentracing/take-opentracing-for-a-hotrod-ride-f6e3141f7941
+
+
+JAEGER DEPLOYMENT
+-----------------
+
+there are couple of ways to deploy jaeger.
+please refer to:
+
+`jaeger deployment <https://www.jaegertracing.io/docs/1.25/deployment/>`_
+
+`jaeger performance tuning <https://www.jaegertracing.io/docs/1.25/performance-tuning/>`_
+
+
+In addition, spans are being sent to local jaeger agent, so the jaeger agent must be running on each host (not in all-in-one mode).
+otherwise, spans of hosts without active jaeger agent will be lost.
+
+HOW TO ENABLE TRACING IN CEPH
+-----------------------------
+
+tracing in Ceph is disabled by default.
+it could be enabled globally, or for each entity seperately (e.g. rgw).
+
+ Enable tracing globally::
+
+ $ ceph config set global jaeger_tracing_enable true
+
+
+ Enable tracing for each entity::
+
+ $ ceph config set <entity> jaeger_tracing_enable true
+
+
+TRACES IN RGW
+-------------
+
+traces of RGW can be found under Service `rgw` in Jaeger Frontend.
+
+every user request is being traced. each trace contains tags for
+`Operation name`, `User id`, `Object name` and `Bucket name`.
+
+there is also `Upload id` tag for Multipart upload operations.
+
+rgw service in Jaeger Frontend:
+
+.. image:: ./rgw_jaeger.png
+ :width: 400
+
+
+osd service in Jaeger Frontend:
+
+.. image:: ./osd_jaeger.png
+ :width: 400
osdc/error_code.cc
librbd/Features.cc
librbd/io/IoOperations.cc
- ${mds_files})
-if(WITH_JAEGER)
- list(APPEND libcommon_files common/tracer.cc)
-endif()
+ ${mds_files}
+ common/tracer.cc)
set_source_files_properties(ceph_ver.c
APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
add_library(common-objs OBJECT ${libcommon_files})
osd/objclass.cc
objclass/class_api.cc
ceph_osd.cc)
-if(WITH_JAEGER)
- list(APPEND ceph_osd_srcs common/tracer.cc)
-endif()
+
add_executable(ceph-osd ${ceph_osd_srcs})
add_dependencies(ceph-osd erasure_code_plugins)
target_link_libraries(ceph-osd osd os global-static common
desc: How long cleaner should sleep before re-checking utilization
default: 5
with_legacy: true
+- name: jaeger_tracing_enable
+ type: bool
+ level: advanced
+ desc: Ceph should use jaeger tracing system
+ default: false
+ services:
+ - rgw
+ - osd
+ with_legacy: true
\ No newline at end of file
services:
- rgw
with_legacy: true
-- name: rgw_jaeger_enable
- type: bool
- level: advanced
- desc: should RGW use jaeger tracing system
- default: false
- services:
- - rgw
- with_legacy: true
- name: rgw_s3_auth_use_keystone
type: bool
level: advanced
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+#include "common/ceph_context.h"
+#include "global/global_context.h"
#include "tracer.h"
-#include <arpa/inet.h>
-#include <yaml-cpp/yaml.h>
-#ifdef __linux__
-#include <linux/types.h>
-#else
-typedef int64_t __s64;
-#endif
-#include "common/debug.h"
+#ifdef HAVE_JAEGER
-#define dout_context g_ceph_context
-#define dout_subsys ceph_subsys_osd
-#undef dout_prefix
-#define dout_prefix *_dout << "jaeger_tracing "
+namespace tracing {
-namespace jaeger_tracing {
+const std::shared_ptr<opentracing::Tracer> Tracer::noop_tracer = opentracing::MakeNoopTracer();
- std::shared_ptr<opentracing::v3::Tracer> tracer = nullptr;
+Tracer::Tracer(opentracing::string_view service_name) {
+ init(service_name);
+}
- void init_tracer(const char* tracer_name) {
- if (!tracer) {
- YAML::Node yaml;
- try{
- yaml = YAML::LoadFile("../src/jaegertracing/config.yml");
- dout(3) << "yaml loaded" << yaml << dendl;
- }
- catch(std::exception &e) {
- dout(3) << "failed to load yaml file using default config" << dendl;
- auto yaml_config = R"cfg(
-disabled: false
-reporter:
- logSpans: false
- queueSize: 100
- bufferFlushInterval: 10
-sampler:
- type: const
- param: 1
-headers:
- jaegerDebugHeader: debug-id
- jaegerBaggageHeader: baggage
- TraceContextHeaderName: trace-id
-baggage_restrictions:
- denyBaggageOnInitializationFailure: false
- refreshInterval: 60
-)cfg";
- yaml = YAML::Load(yaml_config);
- dout(3) << "yaml loaded" << yaml << dendl;
- }
- static auto configuration = jaegertracing::Config::parse(yaml);
- tracer = jaegertracing::Tracer::make( tracer_name, configuration,
- jaegertracing::logging::consoleLogger());
- dout(3) << "tracer_jaeger init successful" << dendl;
- }
- //incase of stale tracer, configure with a new global tracer
- if (opentracing::Tracer::Global() != tracer) {
- opentracing::Tracer::InitGlobal(
- std::static_pointer_cast<opentracing::Tracer>(tracer));
- }
+void Tracer::init(opentracing::string_view service_name) {
+ if (!open_tracer) {
+ using namespace jaeger_configuration;
+ const jaegertracing::Config conf(false, const_sampler, reporter_default_config, headers_config, baggage_config, service_name, std::vector<jaegertracing::Tag>());
+ open_tracer = jaegertracing::Tracer::make(conf);
}
+}
- jspan new_span(const char* span_name) {
- return opentracing::Tracer::Global()->StartSpan(span_name);
- }
-
- jspan child_span(const char* span_name, const jspan& parent_span) {
- //no parent check if parent not found span will still be constructed
- return opentracing::Tracer::Global()->StartSpan(span_name,
- {opentracing::ChildOf(&parent_span->context())});
- }
+void Tracer::shutdown() {
+ open_tracer.reset();
+}
- void finish_span(const jspan& span) {
- if (span) {
- span->Finish();
- }
+jspan Tracer::start_trace(opentracing::string_view trace_name) {
+ if (is_enabled()) {
+ return open_tracer->StartSpan(trace_name);
}
+ return noop_tracer->StartSpan(trace_name);
+}
- void set_span_tag(const jspan& span, const char* key, const char* value) {
- if (span) {
- span->SetTag(key, value);
+jspan Tracer::add_span(opentracing::string_view span_name, jspan& parent_span) {
+ if (is_enabled()) {
+ if (parent_span) {
+ return open_tracer->StartSpan(span_name, { opentracing::ChildOf(&parent_span->context()) });
}
+ return open_tracer->StartSpan(span_name);
}
+ return noop_tracer->StartSpan(span_name);
}
+
+bool Tracer::is_enabled() const {
+ return g_ceph_context->_conf->jaeger_tracing_enable;
+}
+} // namespace tracing
+
+#endif // HAVE_JAEGER
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
-#ifndef TRACER_H_
-#define TRACER_H_
+#ifndef TRACER_H
+#define TRACER_H
+
+#include "acconfig.h"
+
+#ifdef HAVE_JAEGER
#define SIGNED_RIGHT_SHIFT_IS 1
#define ARITHMETIC_RIGHT_SHIFT 1
-
#include <jaegertracing/Tracer.h>
typedef std::unique_ptr<opentracing::Span> jspan;
+namespace tracing {
+
+class Tracer {
+ private:
+ const static std::shared_ptr<opentracing::Tracer> noop_tracer;
+ std::shared_ptr<opentracing::Tracer> open_tracer;
+
+ public:
+ Tracer() = default;
+ Tracer(opentracing::string_view service_name);
+
+ void init(opentracing::string_view service_name);
+ void shutdown();
-namespace jaeger_tracing {
+ bool is_enabled() const;
+ // creates and returns a new span with `trace_name`
+ // this span represents a trace, since it has no parent.
+ jspan start_trace(opentracing::string_view trace_name);
+ // creates and returns a new span with `span_name` which parent span is `parent_span'
+ jspan add_span(opentracing::string_view span_name, jspan& parent_span);
- extern std::shared_ptr<opentracing::v3::Tracer> tracer;
+};
- void init_tracer(const char* tracer_name);
- //create a root jspan
- jspan new_span(const char*);
+} // namespace tracing
- //create a child_span used given parent_span
- jspan child_span(const char*, const jspan&);
+namespace jaeger_configuration {
- //finish tracing of a single jspan
- void finish_span(const jspan&);
+inline const jaegertracing::samplers::Config const_sampler("const", 1, "", 0, jaegertracing::samplers::Config::defaultSamplingRefreshInterval());
+
+inline const jaegertracing::reporters::Config reporter_default_config(jaegertracing::reporters::Config::kDefaultQueueSize, jaegertracing::reporters::Config::defaultBufferFlushInterval(), true, jaegertracing::reporters::Config::kDefaultLocalAgentHostPort, "");
+
+inline const jaegertracing::propagation::HeadersConfig headers_config("", "", "", "");
+
+inline const jaegertracing::baggage::RestrictionsConfig baggage_config(false, "", std::chrono::steady_clock::duration());
- //setting tags in sundefined reference topans
- void set_span_tag(const jspan&, const char*, const char*);
}
-#endif // TRACER_H_
+
+#else // !HAVE_JAEGER
+
+#include <string_view>
+
+class Value {
+ public:
+ template <typename T> Value(T val) {}
+};
+
+struct span_stub {
+ template <typename T>
+ void SetTag(std::string_view key, const T& value) const noexcept {}
+ void Log(std::initializer_list<std::pair<std::string_view, Value>> fields) {}
+};
+
+class jspan {
+ span_stub span;
+ public:
+ span_stub& operator*() { return span; }
+ const span_stub& operator*() const { return span; }
+
+ span_stub* operator->() { return &span; }
+ const span_stub* operator->() const { return &span; }
+
+ operator bool() const { return false; }
+};
+
+namespace tracing {
+
+struct Tracer {
+ bool is_enabled() const { return false; }
+ jspan start_trace(std::string_view) { return {}; }
+ jspan add_span(std::string_view, const jspan&) { return {}; }
+ void init(std::string_view service_name) {}
+ void shutdown() {}
+};
+}
+
+#endif // !HAVE_JAEGER
+
+#endif // TRACER_H
${CMAKE_SOURCE_DIR}/src/common/TrackedOp.cc
${CMAKE_SOURCE_DIR}/src/mgr/OSDPerfMetricTypes.cc
${osd_cyg_functions_src}
- ${osdc_osd_srcs})
+ ${osdc_osd_srcs}
+ osd_tracer.cc)
if(HAS_VTA)
set_source_files_properties(osdcap.cc
PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments)
#include "ECMsgTypes.h"
#include "PrimaryLogPG.h"
+#include "osd_tracer.h"
#define dout_context cct
#define dout_subsys ceph_subsys_osd
ECSubWrite &op,
const ZTracer::Trace &trace)
{
- if (msg)
+ jspan span;
+ if (msg) {
msg->mark_event("sub_op_started");
- trace.event("handle_sub_write");
-#ifdef HAVE_JAEGER
- if (msg && msg->osd_parent_span) {
- auto ec_sub_trans = jaeger_tracing::child_span(__func__, msg->osd_parent_span);
+ span = tracing::osd::tracer.add_span(__func__, msg->osd_parent_span);
}
-#endif
+ trace.event("handle_sub_write");
+
if (!get_parent()->pgb_is_primary())
get_parent()->update_stats(op.stats);
ObjectStore::Transaction localt;
op->tid = tid;
op->reqid = reqid;
op->client_op = client_op;
- if (client_op)
+ jspan span;
+ if (client_op) {
op->trace = client_op->pg_trace;
-
-#ifdef HAVE_JAEGER
- if (client_op && client_op->osd_parent_span) {
- auto ec_sub_trans = jaeger_tracing::child_span("ECBackend::submit_transaction", client_op->osd_parent_span);
+ span = tracing::osd::tracer.add_span("ECBackend::submit_transaction", client_op->osd_parent_span);
}
-#endif
dout(10) << __func__ << ": op " << *op << " starting" << dendl;
start_rmw(op, std::move(t));
}
messages.push_back(std::make_pair(i->osd, r));
}
}
+ jspan span;
+ if (op->client_op) {
+ span = tracing::osd::tracer.add_span("EC sub write", op->client_op->osd_parent_span);
+ }
-#ifdef HAVE_JAEGER
- if (op->client_op && op->client_op->osd_parent_span) {
- auto sub_write_span = jaeger_tracing::child_span("EC sub write", op->client_op->osd_parent_span);
- }
-#endif
if (!messages.empty()) {
get_parent()->send_message_osd_cluster(messages, get_osdmap_epoch());
}
#else
#define tracepoint(...)
#endif
-#ifdef HAVE_JAEGER
-#include "common/tracer.h"
-#endif
+
+#include "osd_tracer.h"
+
#define dout_context cct
#define dout_subsys ceph_subsys_osd
return *_dout << "osd." << whoami << " " << epoch << " ";
}
+
//Initial features in new superblock.
//Features here are also automatically upgraded
CompatSet OSD::get_osd_initial_compat_set() {
std::lock_guard lock(osd_lock);
if (is_stopping())
return 0;
-
+ tracing::osd::tracer.init("osd");
tick_timer.init();
tick_timer_without_osd_lock.init();
service.recovery_request_timer.init();
hb_front_server_messenger->shutdown();
hb_back_server_messenger->shutdown();
+ tracing::osd::tracer.shutdown();
+
return r;
}
void OSD::ms_fast_dispatch(Message *m)
{
-
-#ifdef HAVE_JAEGER
- jaeger_tracing::init_tracer("osd-services-reinit");
- dout(10) << "jaeger tracer after " << opentracing::Tracer::Global() << dendl;
- auto dispatch_span = jaeger_tracing::new_span(__func__);
-#endif
+ auto dispatch_span = tracing::osd::tracer.start_trace(__func__);
FUNCTRACE(cct);
if (service.is_stopping()) {
m->put();
return;
}
-
// peering event?
switch (m->get_type()) {
case CEPH_MSG_PING:
tracepoint(osd, ms_fast_dispatch, reqid.name._type,
reqid.name._num, reqid.tid, reqid.inc);
}
-#ifdef HAVE_JAEGER
- op->set_osd_parent_span(dispatch_span);
- if (op->osd_parent_span) {
- auto op_req_span = jaeger_tracing::child_span("op-request-created", op->osd_parent_span);
- op->set_osd_parent_span(op_req_span);
- }
-#endif
+ op->osd_parent_span = tracing::osd::tracer.add_span("op-request-created", dispatch_span);
+
if (m->trace)
op->osd_trace.init("osd op", &trace_endpoint, &m->trace);
op->osd_trace.event("enqueue op");
op->osd_trace.keyval("priority", priority);
op->osd_trace.keyval("cost", cost);
-#ifdef HAVE_JAEGER
- if (op->osd_parent_span) {
- auto enqueue_span = jaeger_tracing::child_span(__func__, op->osd_parent_span);
- enqueue_span->Log({
- {"priority", priority},
- {"cost", cost},
- {"epoch", epoch},
- {"owner", owner},
- {"type", type}
- });
- }
-#endif
+
+ auto enqueue_span = tracing::osd::tracer.add_span(__func__, op->osd_parent_span);
+ enqueue_span->Log({
+ {"priority", priority},
+ {"cost", cost},
+ {"epoch", epoch},
+ {"owner", owner},
+ {"type", type}
+ });
+
op->mark_queued_for_pg();
logger->tinc(l_osd_op_before_queue_op_lat, latency);
if (type == MSG_OSD_PG_PUSH ||
#include "osd/osd_op_util.h"
#include "osd/osd_types.h"
#include "common/TrackedOp.h"
-#ifdef HAVE_JAEGER
#include "common/tracer.h"
-#endif
-
/**
* The OpRequest takes in a Message* and takes over a single reference
* to it, which it puts() when destroyed.
epoch_t min_epoch = 0; ///< min epoch needed to handle this msg
bool hitset_inserted;
-#ifdef HAVE_JAEGER
- jspan osd_parent_span = nullptr;
- void set_osd_parent_span(jspan& span) {
- if(osd_parent_span){
- jaeger_tracing::finish_span(osd_parent_span);
- }
- osd_parent_span = move(span);
- }
-#else
- void set_osd_parent_span(...) {}
-#endif
+ jspan osd_parent_span;
+
template<class T>
const T* get_req() const { return static_cast<const T*>(request); }
#undef dout_prefix
#define dout_prefix _prefix(_dout, this)
-#ifdef HAVE_JAEGER
-#include "common/tracer.h"
-#endif
+#include "osd_tracer.h"
MEMPOOL_DEFINE_OBJECT_FACTORY(PrimaryLogPG, replicatedpg, osd);
op->pg_trace.init("pg op", &trace_endpoint, &op->osd_trace);
op->pg_trace.event("do request");
}
-#ifdef HAVE_JAEGER
- if (op->osd_parent_span) {
- auto do_req_span = jaeger_tracing::child_span(__func__, op->osd_parent_span);
- }
-#endif
+
+ [[maybe_unused]] auto span = tracing::osd::tracer.add_span(__func__, op->osd_parent_span);
+
// make sure we have a new enough map
auto p = waiting_for_map.find(op->get_source());
if (p != waiting_for_map.end()) {
<< " flags " << ceph_osd_flag_string(m->get_flags())
<< dendl;
-#ifdef HAVE_JAEGER
- if (op->osd_parent_span) {
- auto do_op_span = jaeger_tracing::child_span(__func__, op->osd_parent_span);
- }
-#endif
+ [[maybe_unused]] auto span = tracing::osd::tracer.add_span(__func__, op->osd_parent_span);
+
// missing object?
if (is_unreadable_object(head)) {
if (!is_primary()) {
tracepoint(osd, prepare_tx_enter, reqid.name._type,
reqid.name._num, reqid.tid, reqid.inc);
}
-#ifdef HAVE_JAEGER
- if (ctx->op->osd_parent_span) {
- auto execute_span = jaeger_tracing::child_span(__func__, ctx->op->osd_parent_span);
- }
-#endif
+
+ [[maybe_unused]] auto span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span);
int result = prepare_transaction(ctx);
PGTransaction* t = ctx->op_t.get();
dout(10) << "do_osd_op " << soid << " " << ops << dendl;
-#ifdef HAVE_JAEGER
- if (ctx->op->osd_parent_span) {
- auto do_osd_op_span = jaeger_tracing::child_span(__func__, ctx->op->osd_parent_span);
- }
-#endif
+ jspan span;
+ if (ctx->op) {
+ span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span);
+ }
ctx->current_osd_subop_num = 0;
for (auto p = ops.begin(); p != ops.end(); ++p, ctx->current_osd_subop_num++, ctx->processed_subop_count++) {
OSDOp& osd_op = *p;
<< dendl;
utime_t now = ceph_clock_now();
-#ifdef HAVE_JAEGER
- if (ctx->op->osd_parent_span) {
- auto finish_ctx_span = jaeger_tracing::child_span(__func__, ctx->op->osd_parent_span);
+ jspan span;
+ if (ctx->op) {
+ span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span);
}
-#endif
+
// Drop the reference if deduped chunk is modified
if (ctx->new_obs.oi.is_dirty() &&
(ctx->obs->oi.has_manifest() && ctx->obs->oi.manifest.is_chunked()) &&
void PrimaryLogPG::eval_repop(RepGather *repop)
{
- #ifdef HAVE_JAEGER
- if (repop->op->osd_parent_span) {
- auto eval_span = jaeger_tracing::child_span(__func__, repop->op->osd_parent_span);
+ jspan span;
+ if (repop->op) {
+ span = tracing::osd::tracer.add_span(__func__, repop->op->osd_parent_span);
}
- #endif
dout(10) << "eval_repop " << *repop
<< (repop->op && repop->op->get_req<MOSDOp>() ? "" : " (no op)") << dendl;
dout(7) << "issue_repop rep_tid " << repop->rep_tid
<< " o " << soid
<< dendl;
-#ifdef HAVE_JAEGER
- if (ctx->op->osd_parent_span) {
- auto issue_repop_span = jaeger_tracing::child_span(__func__, ctx->op->osd_parent_span);
+
+ jspan span;
+ if (ctx->op) {
+ span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span);
}
-#endif
repop->v = ctx->at_version;
#include "include/random.h"
#include "include/util.h"
#include "OSD.h"
+#include "osd_tracer.h"
#define dout_context cct
#define dout_subsys ceph_subsys_osd
ceph_assert(insert_res.second);
InProgressOp &op = *insert_res.first->second;
-#ifdef HAVE_JAEGER
- auto rep_sub_trans = jaeger_tracing::child_span("ReplicatedBackend::submit_transaction", orig_op->osd_parent_span);
-#endif
+ jspan span;
+ if (orig_op) {
+ span = tracing::osd::tracer.add_span("ReplicatedBackend::submit_transaction", orig_op->osd_parent_span);
+ }
+
op.waiting_for_commit.insert(
parent->get_acting_recovery_backfill_shards().begin(),
parent->get_acting_recovery_backfill_shards().end());
<< " " << m->logbl.length()
<< dendl;
-#ifdef HAVE_JAEGER
- auto do_repop_span = jaeger_tracing::child_span(__func__, op->osd_parent_span);
-#endif
+ jspan span;
+ if (op) {
+ span = tracing::osd::tracer.add_span(__func__, op->osd_parent_span);
+ }
// sanity checks
ceph_assert(m->map_epoch >= get_info().history.same_interval_since);
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "osd_tracer.h"
+
+namespace tracing {
+namespace osd {
+
+tracing::Tracer tracer;
+
+} // namespace osd
+} // namespace tracing
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#pragma once
+
+#include "common/tracer.h"
+
+namespace tracing {
+namespace osd {
+
+extern tracing::Tracer tracer;
+
+} // namespace osd
+} // namespace tracing
#include "osd/scheduler/OpSchedulerItem.h"
#include "osd/OSD.h"
-#ifdef HAVE_JAEGER
-#include "common/tracer.h"
-#endif
+#include "osd/osd_tracer.h"
+
namespace ceph::osd::scheduler {
PGRef& pg,
ThreadPool::TPHandle &handle)
{
-#ifdef HAVE_JAEGER
- auto PGOpItem_span = jaeger_tracing::child_span("PGOpItem::run", op->osd_parent_span);
-#endif
+ [[maybe_unused]] auto span = tracing::osd::tracer.add_span("PGOpItem::run", op->osd_parent_span);
osd->dequeue_op(pg, op, handle);
pg->unlock();
}
#include "cls/rgw/cls_rgw_types.h"
#include "include/rados/librados.hpp"
#include "rgw_public_access.h"
-#include "rgw_tracer.h"
+#include "common/tracer.h"
namespace ceph {
class Formatter;
#include "common/utf8.h"
#include "common/ceph_json.h"
#include "common/static_ptr.h"
+#include "rgw_tracer.h"
#include "rgw_rados.h"
#include "rgw_zone.h"
#include "rgw_notify_event_type.h"
#include "rgw_sal.h"
#include "rgw_sal_rados.h"
-#include "rgw_tracer.h"
#include "services/svc_zone.h"
#include "services/svc_quota.h"
rgw_placement_rule *pdest_placement = &s->dest_placement;
if (multipart) {
- s->trace->SetTag(tracing::UPLOAD_ID, multipart_upload_id);
+ s->trace->SetTag(tracing::rgw::UPLOAD_ID, multipart_upload_id);
std::unique_ptr<rgw::sal::MultipartUpload> upload;
upload = store->get_multipart_upload(s->bucket.get(), s->object->get_name(),
multipart_upload_id);
if (op_ret == 0) {
upload_id = upload->get_upload_id();
}
- s->trace->SetTag(tracing::UPLOAD_ID, upload_id);
+ s->trace->SetTag(tracing::rgw::UPLOAD_ID, upload_id);
}
upload = store->get_multipart_upload(s->bucket.get(), s->object->get_name(), upload_id);
- s->trace->SetTag(tracing::UPLOAD_ID, upload_id);
+ s->trace->SetTag(tracing::rgw::UPLOAD_ID, upload_id);
RGWCompressionInfo cs_info;
bool compressed = false;
#include "rgw_perf_counters.h"
#include "rgw_lua.h"
#include "rgw_lua_request.h"
-
+#include "rgw_tracer.h"
#include "services/svc_zone_utils.h"
#define dout_subsys ceph_subsys_rgw
ldpp_dout(op, 2) << "verifying op permissions" << dendl;
{
- auto span = rgw_tracer.start_span("verify_permission", s->trace);
+ auto span = tracing::rgw::tracer.add_span("verify_permission", s->trace);
std::swap(span, s->trace);
ret = op->verify_permission(y);
std::swap(span, s->trace);
ldpp_dout(op, 2) << "executing" << dendl;
{
- auto span = rgw_tracer.start_span("execute", s->trace);
+ auto span = tracing::rgw::tracer.add_span("execute", s->trace);
std::swap(span, s->trace);
op->execute(y);
std::swap(span, s->trace);
}
const auto trace_name = std::string(op->name()) + " " + s->trans_id;
- s->trace = rgw_tracer.start_trace(trace_name);
- s->trace->SetTag(tracing::OP, op->name());
- s->trace->SetTag(tracing::TYPE, tracing::REQUEST);
+ s->trace = tracing::rgw::tracer.start_trace(trace_name);
+ s->trace->SetTag(tracing::rgw::OP, op->name());
+ s->trace->SetTag(tracing::rgw::TYPE, tracing::rgw::REQUEST);
ret = rgw_process_authenticated(handler, op, req, s, yield);
if (ret < 0) {
done:
if (op) {
- s->trace->SetTag(tracing::RETURN, op->get_ret());
+ s->trace->SetTag(tracing::rgw::RETURN, op->get_ret());
if (s->user) {
- s->trace->SetTag(tracing::USER_ID, s->user->get_id().id);
+ s->trace->SetTag(tracing::rgw::USER_ID, s->user->get_id().id);
}
if (s->bucket) {
- s->trace->SetTag(tracing::BUCKET_NAME, s->bucket->get_name());
+ s->trace->SetTag(tracing::rgw::BUCKET_NAME, s->bucket->get_name());
}
if (s->object) {
- s->trace->SetTag(tracing::OBJECT_NAME, s->object->get_name());
+ s->trace->SetTag(tracing::rgw::OBJECT_NAME, s->object->get_name());
}
std::string script;
auto rc = rgw::lua::read_script(s, store, s->bucket_tenant, s->yield, rgw::lua::context::postRequest, script);
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab ft=cpp
-#include "common/ceph_context.h"
-#include "global/global_context.h"
-#include "rgw_tracer.h"
-
-#ifdef HAVE_JAEGER
+// vim: ts=8 sw=2 smarttab
-thread_local tracing::Tracer rgw_tracer(jaeger_configuration::jaeger_default_config);
+#include <string>
+#include "rgw_tracer.h"
namespace tracing {
+namespace rgw {
-const std::shared_ptr<opentracing::Tracer> Tracer::noop_tracer = opentracing::MakeNoopTracer();
-
-Tracer::Tracer(jaegertracing::Config& conf):open_tracer(jaegertracing::Tracer::make(conf)) {}
-
-std::unique_ptr<opentracing::Span> Tracer::start_trace(opentracing::string_view trace_name) {
- if(is_enabled()) {
- return open_tracer->StartSpan(trace_name);
- }
- return noop_tracer->StartSpan(trace_name);
-}
-
-std::unique_ptr<opentracing::Span> Tracer::start_span(opentracing::string_view span_name, std::unique_ptr<opentracing::Span>& parent_span) {
- if(is_enabled()) {
- return open_tracer->StartSpan(span_name, { opentracing::ChildOf(&parent_span->context()) });
- }
- return noop_tracer->StartSpan(span_name);
-}
-
-bool Tracer::is_enabled() const {
- return g_ceph_context->_conf->rgw_jaeger_enable;
-}
-} // namespace tracing
-
-namespace jaeger_configuration {
-
-jaegertracing::samplers::Config const_sampler("const", 1, "", 0, jaegertracing::samplers::Config::defaultSamplingRefreshInterval());
-
-jaegertracing::reporters::Config reporter_default_config(jaegertracing::reporters::Config::kDefaultQueueSize, jaegertracing::reporters::Config::defaultBufferFlushInterval(), true, jaegertracing::reporters::Config::kDefaultLocalAgentHostPort, "");
-
-jaegertracing::propagation::HeadersConfig headers_config("","","","");
-
-jaegertracing::baggage::RestrictionsConfig baggage_config(false, "", std::chrono::steady_clock::duration());
-
-jaegertracing::Config jaeger_default_config(false, const_sampler, reporter_default_config, headers_config, baggage_config, "rgw", std::vector<jaegertracing::Tag>());
-
-}
-
+#ifdef HAVE_JAEGER
+thread_local tracing::Tracer tracer("rgw");
#else // !HAVE_JAEGER
-
-tracing::Tracer rgw_tracer;
-
+tracing::Tracer tracer;
#endif
-
\ No newline at end of file
+
+} // namespace rgw
+} // namespace tracing
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab ft=cpp
-
-#ifndef RGW_TRACER_H
-#define RGW_TRACER_H
-
-#ifdef HAVE_JAEGER
-
-#define SIGNED_RIGHT_SHIFT_IS 1
-#define ARITHMETIC_RIGHT_SHIFT 1
-#include <jaegertracing/Tracer.h>
-
-typedef std::unique_ptr<opentracing::Span> jspan;
-
-#else // !HAVE_JAEGER
-
-struct span_stub {
- template <typename T>
- void SetTag(std::string_view key, const T& value) const noexcept {}
- void Log(std::initializer_list<std::pair<std::string_view, std::string_view>> fields) {}
-};
-
-class jspan {
- span_stub span;
- public:
- span_stub& operator*() { return span; }
- const span_stub& operator*() const { return span; }
-
- span_stub* operator->() { return &span; }
- const span_stub* operator->() const { return &span; }
-};
-
-#endif // !HAVE_JAEGER
+// vim: ts=8 sw=2 smarttab
+#pragma once
+#include "common/tracer.h"
namespace tracing {
+namespace rgw {
const auto OP = "op";
const auto BUCKET_NAME = "bucket_name";
const auto REQUEST = "request";
#ifdef HAVE_JAEGER
-
-class Tracer {
-private:
- const static std::shared_ptr<opentracing::Tracer> noop_tracer;
- std::shared_ptr<opentracing::Tracer> open_tracer;
-
-public:
- Tracer(jaegertracing::Config& conf);
- bool is_enabled() const;
- // creates and returns a new span with `trace_name`
- // this span represents a trace, since it has no parent.
- jspan start_trace(opentracing::string_view trace_name);
- // creates and returns a new span with `trace_name` which parent span is `parent_span'
- jspan start_span(opentracing::string_view span_name, jspan& parent_span);
-};
-
-#else // !HAVE_JAEGER
-
-struct Tracer {
- bool is_enabled() const { return false; }
- jspan start_trace(std::string_view) { return {}; }
- jspan start_span(std::string_view, const jspan&) { return {}; }
-};
-
+extern thread_local tracing::Tracer tracer;
+#else
+extern tracing::Tracer tracer;
#endif
+} // namespace rgw
} // namespace tracing
-
-#ifdef HAVE_JAEGER
-
-extern thread_local tracing::Tracer rgw_tracer;
-
-namespace jaeger_configuration {
-
-extern jaegertracing::Config jaeger_default_config;
-
-}
-
-#else // !HAVE_JAEGER
-
-extern tracing::Tracer rgw_tracer;
-
-#endif
-
-#endif // RGW_TRACER_H
-
\ No newline at end of file