From f857072449782956a8b3a528397c36354dce519f Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Thu, 2 Jun 2022 20:22:21 +0300 Subject: [PATCH] Revert "tracer: set tracing compiled in by default" --- CMakeLists.txt | 2 +- ceph.spec.in | 2 +- cmake/modules/BuildOpentelemetry.cmake | 18 +++++++--------- debian/control | 10 ++++----- debian/rules | 6 +++++- do_freebsd.sh | 1 - install-deps.sh | 17 +++++++++++++-- src/CMakeLists.txt | 23 ++++++-------------- src/common/tracer.cc | 29 +++++++++++++------------- src/common/tracer.h | 8 ++++++- src/crimson/CMakeLists.txt | 6 +++--- src/mon/CMakeLists.txt | 2 +- src/os/CMakeLists.txt | 4 ++-- src/osd/ECBackend.cc | 6 ++++++ src/osd/OSD.cc | 4 +++- src/osd/PrimaryLogPG.cc | 19 +++++++++++++++++ src/osd/ReplicatedBackend.cc | 8 +++++++ src/osd/scheduler/OpSchedulerItem.cc | 1 + src/rgw/CMakeLists.txt | 4 ++-- src/rgw/rgw_main.cc | 2 +- src/rgw/rgw_process.cc | 2 +- src/rgw/rgw_tracer.cc | 4 ++++ src/rgw/rgw_tracer.h | 4 ++++ src/rgw/store/dbstore/CMakeLists.txt | 2 +- win32_build.sh | 2 +- 25 files changed, 120 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 629f0286b1a83..f4d6e14fbbcf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,7 +408,7 @@ if(WITH_BLKIN) include_directories(SYSTEM src/blkin/blkin-lib) endif(WITH_BLKIN) -option(WITH_JAEGER "Enable jaegertracing and it's dependent libraries" ON) +option(WITH_JAEGER "Enable jaegertracing and it's dependent libraries" OFF) if(WITH_JAEGER) set(HAVE_JAEGER TRUE) endif() diff --git a/ceph.spec.in b/ceph.spec.in index 13523b8afde34..664a566e65ce0 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -86,7 +86,7 @@ %endif %endif %bcond_with seastar -%bcond_without jaeger +%bcond_with jaeger %if 0%{?fedora} || 0%{?suse_version} >= 1500 # distros that ship cmd2 and/or colorama %bcond_without cephfs_shell diff --git a/cmake/modules/BuildOpentelemetry.cmake b/cmake/modules/BuildOpentelemetry.cmake index 1bbdf870c17ae..6bd2380627192 100644 --- a/cmake/modules/BuildOpentelemetry.cmake +++ b/cmake/modules/BuildOpentelemetry.cmake @@ -6,14 +6,14 @@ function(target_create _target _lib) endfunction() function(build_opentelemetry) - set(opentelemetry_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src/opentelemetry-cpp") + set(opentelemetry_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/opentelemetry-cpp") set(opentelemetry_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/opentelemetry-cpp") set(opentelemetry_cpp_targets opentelemetry_trace opentelemetry_exporter_jaeger_trace) set(opentelemetry_CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_JAEGER=ON -DBUILD_TESTING=OFF - -DCMAKE_BUILD_TYPE=Release - -DWITH_EXAMPLES=OFF) + -DWITH_EXAMPLES=OFF + -DBoost_INCLUDE_DIR=${CMAKE_BINARY_DIR}/boost/include) set(opentelemetry_libs ${opentelemetry_BINARY_DIR}/sdk/src/trace/libopentelemetry_trace.a @@ -27,6 +27,7 @@ function(build_opentelemetry) ${opentelemetry_SOURCE_DIR}/exporters/jaeger/include/ ${opentelemetry_SOURCE_DIR}/ext/include/ ${opentelemetry_SOURCE_DIR}/sdk/include/) + include_directories(SYSTEM ${opentelemetry_include_dir}) # TODO: add target based propogation set(opentelemetry_deps opentelemetry_trace opentelemetry_resources opentelemetry_common opentelemetry_exporter_jaeger_trace http_client_curl @@ -40,11 +41,8 @@ function(build_opentelemetry) ${opentelemetry_cpp_targets}) endif() - if(WITH_SYSTEM_BOOST) - list(APPEND opentelemetry_CMAKE_ARGS -DBOOST_ROOT=${BOOST_ROOT}) - else() + if(NOT WITH_SYSTEM_BOOST) list(APPEND dependencies Boost) - list(APPEND opentelemetry_CMAKE_ARGS -DBoost_INCLUDE_DIR=${CMAKE_BINARY_DIR}/boost/include) endif() include(ExternalProject) @@ -78,12 +76,12 @@ function(build_opentelemetry) # will do all linking and path setting fake include path for # interface_include_directories since this happens at build time - file(MAKE_DIRECTORY ${opentelemetry_include_dir}) + file(MAKE_DIRECTORY + "${opentelemetry_BINARY_DIR}/opentelemetry-cpp/exporters/jaeger/include") add_library(opentelemetry::libopentelemetry INTERFACE IMPORTED) add_dependencies(opentelemetry::libopentelemetry opentelemetry-cpp) set_target_properties( opentelemetry::libopentelemetry PROPERTIES - INTERFACE_LINK_LIBRARIES "${opentelemetry_deps}" - INTERFACE_INCLUDE_DIRECTORIES "${opentelemetry_include_dir}") + INTERFACE_LINK_LIBRARIES "${opentelemetry_deps}") endfunction() diff --git a/debian/control b/debian/control index 18986abacaa2c..f64664e4319ae 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Maintainer: Ceph Maintainers Uploaders: Ken Dreyer , Alfredo Deza , Build-Depends: automake, - bison, + bison , cmake (>= 3.10.2), cpio, cython3, @@ -16,7 +16,7 @@ Build-Depends: automake, default-jdk, dh-exec, dh-python, - flex, + flex , git, golang, gperf, @@ -37,7 +37,7 @@ Build-Depends: automake, libcap-ng-dev, libcunit1-dev, libcurl4-openssl-dev, - libevent-dev, + libevent-dev , libexpat1-dev, libffi-dev [!amd64] , libfmt-dev (>= 6.1.2), @@ -72,14 +72,14 @@ Build-Depends: automake, librdkafka-dev, luarocks, libthrift-dev (>= 0.13.0), - libyaml-cpp-dev (>= 0.6), + libyaml-cpp-dev (>= 0.6) , libzstd-dev , libxmlsec1 , libxmlsec1-nss , libxmlsec1-openssl , libxmlsec1-dev , ninja-build, - nlohmann-json3-dev, + nlohmann-json3-dev , patch, pkg-config, prometheus , diff --git a/debian/rules b/debian/rules index 96245ae39c810..9f49deabb0e01 100755 --- a/debian/rules +++ b/debian/rules @@ -16,11 +16,15 @@ ifeq (,$(findstring WITH_SEASTAR,$(CEPH_EXTRA_CMAKE_ARGS))) else export CEPH_OSD_BASENAME = crimson-osd endif +ifeq ($(filter pkg.ceph.jaeger,$(DEB_BUILD_PROFILES)),) + extraopts += -DWITH_JAEGER=OFF +else + extraopts += -DWITH_JAEGER=ON +endif ifneq ($(filter pkg.ceph.arrow,$(DEB_BUILD_PROFILES)),) extraopts += -DWITH_SYSTEM_ARROW=ON endif -extraopts += -DWITH_JAEGER=ON extraopts += -DWITH_SYSTEM_UTF8PROC=ON extraopts += -DWITH_OCF=ON -DWITH_LTTNG=ON extraopts += -DWITH_MGR_DASHBOARD_FRONTEND=OFF diff --git a/do_freebsd.sh b/do_freebsd.sh index 442fd633f46e9..097fe19e68f0b 100755 --- a/do_freebsd.sh +++ b/do_freebsd.sh @@ -60,7 +60,6 @@ mkdir ${BUILD_DIR} -D WITH_MGR=YES \ -D WITH_RDMA=OFF \ -D WITH_SPDK=OFF \ - -D WITH_JAEGER=OFF \ 2>&1 | tee cmake.log echo -n "start building: "; date diff --git a/install-deps.sh b/install-deps.sh index 1302d2d3fe6f0..41138d7cc17c5 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -34,12 +34,17 @@ function munge_ceph_spec_in { shift local for_make_check=$1 shift + local with_jaeger=$1 + shift local OUTFILE=$1 sed -e 's/@//g' < ceph.spec.in > $OUTFILE # http://rpm.org/user_doc/conditional_builds.html if $with_seastar; then sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE fi + if $with_jaeger; then + sed -i -e 's/%bcond_with jaeger/%bcond_without jaeger/g' $OUTFILE + fi if $with_zbd; then sed -i -e 's/%bcond_with zbd/%bcond_without zbd/g' $OUTFILE fi @@ -58,6 +63,10 @@ function munge_debian_control { grep -v babeltrace debian/control > $control ;; esac + if $with_jaeger; then + sed -i -e 's/^# Jaeger[[:space:]]//g' $control + sed -i -e 's/^# Crimson libyaml-cpp-dev,/d' $control + fi echo $control } @@ -307,6 +316,7 @@ if [ x$(uname)x = xFreeBSDx ]; then exit else [ $WITH_SEASTAR ] && with_seastar=true || with_seastar=false + [ $WITH_JAEGER ] && with_jaeger=true || with_jaeger=false [ $WITH_ZBD ] && with_zbd=true || with_zbd=false [ $WITH_PMEM ] && with_pmem=true || with_pmem=false [ $WITH_RADOSGW_MOTR ] && with_rgw_motr=true || with_rgw_motr=false @@ -358,6 +368,9 @@ else if $with_seastar; then build_profiles+=",pkg.ceph.crimson" fi + if $with_jaeger; then + build_profiles+=",pkg.ceph.jaeger" + fi in_jenkins && cat <&1 | tee $DIR/yum-builddep.out @@ -444,7 +457,7 @@ EOF echo "Using zypper to install dependencies" zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends" $SUDO $zypp_install systemd-rpm-macros rpm-build || exit 1 - munge_ceph_spec_in $with_seastar false $for_make_check $DIR/ceph.spec + munge_ceph_spec_in $with_seastar false $for_make_check $with_jaeger $DIR/ceph.spec $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1 ;; *) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89c53ea46eb93..61a8616d5a773 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -406,11 +406,9 @@ if(WITH_JAEGER) find_package(thrift 0.13.0 REQUIRED) include(BuildOpentelemetry) build_opentelemetry() - add_library(jaeger_base INTERFACE) - target_link_libraries(jaeger_base INTERFACE opentelemetry::libopentelemetry - thrift::libthrift) - add_dependencies(common-objs jaeger_base) - target_link_libraries(common-objs jaeger_base) + set(jaeger_base opentelemetry::libopentelemetry thrift::libthrift) + add_dependencies(common-objs ${jaeger_base}) + target_link_libraries(common-objs ${jaeger_base}) endif() CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA) @@ -474,7 +472,7 @@ if(WITH_DPDK) endif() if(WITH_JAEGER) - list(APPEND ceph_common_deps jaeger_base) + list(APPEND ceph_common_deps ${jaeger_base}) endif() if(WIN32) @@ -500,10 +498,7 @@ endif() add_library(common STATIC ${ceph_common_objs}) target_link_libraries(common ${ceph_common_deps}) -add_dependencies(common legacy-option-headers) -if(WITH_JAEGER) -add_dependencies(common jaeger_base) -endif() +add_dependencies(common legacy-option-headers ${jaeger_base}) if (WIN32) # Statically building ceph-common on Windows fails. We're temporarily @@ -517,13 +512,7 @@ target_link_libraries(ceph-common ${ceph_common_deps}) if(ENABLE_COVERAGE) target_link_libraries(ceph-common gcov) endif(ENABLE_COVERAGE) - -add_dependencies(ceph-common legacy-option-headers) - -if(WITH_JAEGER) -add_dependencies(ceph-common jaeger_base) -endif() - +add_dependencies(ceph-common legacy-option-headers ${jaeger_base}) # appease dpkg-shlibdeps set_target_properties(ceph-common PROPERTIES SOVERSION 2 diff --git a/src/common/tracer.cc b/src/common/tracer.cc index 1068bf5c2ccf0..c9891726044c8 100644 --- a/src/common/tracer.cc +++ b/src/common/tracer.cc @@ -6,14 +6,11 @@ #include "tracer.h" #ifdef HAVE_JAEGER -#include "opentelemetry/sdk/trace/batch_span_processor.h" -#include "opentelemetry/sdk/trace/tracer_provider.h" -#include "opentelemetry/exporters/jaeger/jaeger_exporter.h" + namespace tracing { const opentelemetry::nostd::shared_ptr Tracer::noop_tracer = opentelemetry::trace::Provider::GetTracerProvider()->GetTracer("no-op", OPENTELEMETRY_SDK_VERSION); -const jspan Tracer::noop_span = noop_tracer->StartSpan("noop"); using bufferlist = ceph::buffer::list; @@ -23,21 +20,26 @@ Tracer::Tracer(opentelemetry::nostd::string_view service_name) { void Tracer::init(opentelemetry::nostd::string_view service_name) { if (!tracer) { - const opentelemetry::exporter::jaeger::JaegerExporterOptions exporter_options; - const opentelemetry::sdk::trace::BatchSpanProcessorOptions processor_options; + const opentelemetry::exporter::jaeger::JaegerExporterOptions opts; + auto jaeger_exporter = std::unique_ptr(new opentelemetry::exporter::jaeger::JaegerExporter(opts)); + auto processor = std::unique_ptr(new opentelemetry::sdk::trace::SimpleSpanProcessor(std::move(jaeger_exporter))); const auto jaeger_resource = opentelemetry::sdk::resource::Resource::Create(std::move(opentelemetry::sdk::resource::ResourceAttributes{{"service.name", service_name}})); - auto jaeger_exporter = std::unique_ptr(new opentelemetry::exporter::jaeger::JaegerExporter(exporter_options)); - auto processor = std::unique_ptr(new opentelemetry::sdk::trace::BatchSpanProcessor(std::move(jaeger_exporter), processor_options)); const auto provider = opentelemetry::nostd::shared_ptr(new opentelemetry::sdk::trace::TracerProvider(std::move(processor), jaeger_resource)); tracer = provider->GetTracer(service_name, OPENTELEMETRY_SDK_VERSION); } } +void Tracer::shutdown() { + if (tracer) { + tracer->CloseWithMicroseconds(1); + } +} + jspan Tracer::start_trace(opentelemetry::nostd::string_view trace_name) { if (is_enabled()) { return tracer->StartSpan(trace_name); } - return noop_span; + return noop_tracer->StartSpan(trace_name); } jspan Tracer::start_trace(opentelemetry::nostd::string_view trace_name, bool trace_is_enabled) { @@ -49,11 +51,10 @@ jspan Tracer::start_trace(opentelemetry::nostd::string_view trace_name, bool tra jspan Tracer::add_span(opentelemetry::nostd::string_view span_name, const jspan& parent_span) { if (is_enabled() && parent_span->IsRecording()) { - opentelemetry::trace::StartSpanOptions span_opts; - span_opts.parent = parent_span->GetContext(); - return tracer->StartSpan(span_name, span_opts); + const auto parent_ctx = parent_span->GetContext(); + return add_span(span_name, parent_ctx); } - return noop_span; + return noop_tracer->StartSpan(span_name); } jspan Tracer::add_span(opentelemetry::nostd::string_view span_name, const jspan_context& parent_ctx) { @@ -62,7 +63,7 @@ jspan Tracer::add_span(opentelemetry::nostd::string_view span_name, const jspan_ span_opts.parent = parent_ctx; return tracer->StartSpan(span_name, span_opts); } - return noop_span; + return noop_tracer->StartSpan(span_name); } bool Tracer::is_enabled() const { diff --git a/src/common/tracer.h b/src/common/tracer.h index 5d77a0dcf159c..bd095f310f618 100644 --- a/src/common/tracer.h +++ b/src/common/tracer.h @@ -7,7 +7,11 @@ #include "include/buffer.h" #ifdef HAVE_JAEGER + #include "opentelemetry/trace/provider.h" +#include "opentelemetry/exporters/jaeger/jaeger_exporter.h" +#include "opentelemetry/sdk/trace/simple_processor.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" using jspan = opentelemetry::nostd::shared_ptr; using jspan_context = opentelemetry::trace::SpanContext; @@ -17,7 +21,6 @@ namespace tracing { class Tracer { private: const static opentelemetry::nostd::shared_ptr noop_tracer; - const static jspan noop_span; opentelemetry::nostd::shared_ptr tracer; public: @@ -25,6 +28,7 @@ class Tracer { Tracer(opentelemetry::nostd::string_view service_name); void init(opentelemetry::nostd::string_view service_name); + void shutdown(); bool is_enabled() const; // creates and returns a new span with `trace_name` @@ -55,6 +59,7 @@ void decode(jspan_context& span_ctx, ceph::buffer::list::const_iterator& bl); #include + class Value { public: template Value(T val) {} @@ -94,6 +99,7 @@ struct Tracer { jspan add_span(std::string_view, const jspan&) { return {}; } jspan add_span(std::string_view span_name, const jspan_context& parent_ctx) { return {}; } void init(std::string_view service_name) {} + void shutdown() {} }; inline void encode(const jspan_context& span, bufferlist& bl, uint64_t f=0) {} inline void decode(jspan_context& span_ctx, ceph::buffer::list::const_iterator& bl) {} diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index e17251564964e..4508491407d91 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -134,9 +134,9 @@ set(crimson_common_deps Boost::random json_spirit) -set(crimson_common_public_deps crimson::cflags) if(WITH_JAEGER) - list(APPEND crimson_common_public_deps jaeger_base) + include_directories(SYSTEM ${CMAKE_BINARY_DIR}/external/include) + list(APPEND crimson_common_deps ${jaeger_base}) endif() if(NOT WITH_SYSTEM_BOOST) @@ -145,7 +145,7 @@ endif() target_link_libraries(crimson-common PUBLIC - ${crimson_common_public_deps} + crimson::cflags PRIVATE crc32 ${crimson_common_deps} diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt index 784b4c3ee0b34..b7232551ccb03 100644 --- a/src/mon/CMakeLists.txt +++ b/src/mon/CMakeLists.txt @@ -42,5 +42,5 @@ target_link_libraries(mon heap_profiler fmt::fmt) if(WITH_JAEGER) - target_link_libraries(mon jaeger_base) + target_link_libraries(mon ${jaeger_base}) endif() diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 9a6de9301054b..204a29fea8ccd 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -93,8 +93,8 @@ if(WITH_LTTNG) endif() if(WITH_JAEGER) - add_dependencies(os jaeger_base) - target_link_libraries(os jaeger_base) + add_dependencies(os ${jaeger_base}) + target_link_libraries(os ${jaeger_base}) endif() target_link_libraries(os kv) diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index 2b350858f230a..06c75049f226a 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -951,6 +951,7 @@ void ECBackend::handle_sub_write( jspan span; if (msg) { msg->mark_event("sub_op_started"); + span = tracing::osd::tracer.add_span(__func__, msg->osd_parent_span); } trace.event("handle_sub_write"); @@ -1552,6 +1553,7 @@ void ECBackend::submit_transaction( jspan span; if (client_op) { op->trace = client_op->pg_trace; + span = tracing::osd::tracer.add_span("ECBackend::submit_transaction", client_op->osd_parent_span); } dout(10) << __func__ << ": op " << *op << " starting" << dendl; start_rmw(op, std::move(t)); @@ -2124,6 +2126,10 @@ bool ECBackend::try_reads_to_commit() 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); + } if (!messages.empty()) { get_parent()->send_message_osd_cluster(messages, get_osdmap_epoch()); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index dc58cb438827d..ef55e440b06c1 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4521,6 +4521,7 @@ int OSD::shutdown() utime_t duration = ceph_clock_now() - start_time_func; dout(0) <<"Slow Shutdown duration:" << duration << " seconds" << dendl; + tracing::osd::tracer.shutdown(); return r; } @@ -7275,6 +7276,7 @@ void OSD::dispatch_session_waiting(const ceph::ref_t& session, OSDMapRe void OSD::ms_fast_dispatch(Message *m) { + auto dispatch_span = tracing::osd::tracer.start_trace(__func__); FUNCTRACE(cct); if (service.is_stopping()) { m->put(); @@ -7330,7 +7332,7 @@ void OSD::ms_fast_dispatch(Message *m) tracepoint(osd, ms_fast_dispatch, reqid.name._type, reqid.name._num, reqid.tid, reqid.inc); } - op->osd_parent_span = tracing::osd::tracer.start_trace("op-request-created"); + 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); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 58a065f96dc79..1b60dfc0793aa 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1796,6 +1796,7 @@ void PrimaryLogPG::do_request( op->pg_trace.event("do request"); } + [[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()); @@ -2168,6 +2169,7 @@ void PrimaryLogPG::do_op(OpRequestRef& op) << " flags " << ceph_osd_flag_string(m->get_flags()) << dendl; + [[maybe_unused]] auto span = tracing::osd::tracer.add_span(__func__, op->osd_parent_span); // missing object? if (is_unreadable_object(head)) { @@ -4186,6 +4188,7 @@ void PrimaryLogPG::execute_ctx(OpContext *ctx) reqid.name._num, reqid.tid, reqid.inc); } + [[maybe_unused]] auto span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span); int result = prepare_transaction(ctx); @@ -5963,6 +5966,10 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) dout(10) << "do_osd_op " << soid << " " << ops << dendl; + 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; @@ -8917,6 +8924,10 @@ void PrimaryLogPG::finish_ctx(OpContext *ctx, int log_op_type, int result) << dendl; utime_t now = ceph_clock_now(); + jspan span; + if (ctx->op) { + span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span); + } // Drop the reference if deduped chunk is modified if (ctx->new_obs.oi.is_dirty() && @@ -11303,6 +11314,10 @@ void PrimaryLogPG::op_applied(const eversion_t &applied_version) void PrimaryLogPG::eval_repop(RepGather *repop) { + jspan span; + if (repop->op) { + span = tracing::osd::tracer.add_span(__func__, repop->op->osd_parent_span); + } dout(10) << "eval_repop " << *repop << (repop->op && repop->op->get_req() ? "" : " (no op)") << dendl; @@ -11358,6 +11373,10 @@ void PrimaryLogPG::issue_repop(RepGather *repop, OpContext *ctx) << " o " << soid << dendl; + jspan span; + if (ctx->op) { + span = tracing::osd::tracer.add_span(__func__, ctx->op->osd_parent_span); + } repop->v = ctx->at_version; diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 22bf4aea0f5f7..50a6c60d7f0f5 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -504,6 +504,10 @@ void ReplicatedBackend::submit_transaction( ceph_assert(insert_res.second); InProgressOp &op = *insert_res.first->second; + 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(), @@ -1058,6 +1062,10 @@ void ReplicatedBackend::do_repop(OpRequestRef op) << " " << m->logbl.length() << dendl; + 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); diff --git a/src/osd/scheduler/OpSchedulerItem.cc b/src/osd/scheduler/OpSchedulerItem.cc index 194e17f301c8e..9f834e9077812 100644 --- a/src/osd/scheduler/OpSchedulerItem.cc +++ b/src/osd/scheduler/OpSchedulerItem.cc @@ -30,6 +30,7 @@ void PGOpItem::run( PGRef& pg, ThreadPool::TPHandle &handle) { + [[maybe_unused]] auto span = tracing::osd::tracer.add_span("PGOpItem::run", op->osd_parent_span); osd->dequeue_op(pg, op, handle); pg->unlock(); } diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 8a6cb7d258c21..3f569deb20bbe 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -251,8 +251,8 @@ if(WITH_LTTNG) endif() if(WITH_JAEGER) - add_dependencies(rgw_common jaeger_base) - target_link_libraries(rgw_common PUBLIC jaeger_base) + add_dependencies(rgw_common ${jaeger_base}) + target_link_libraries(rgw_common PUBLIC ${jaeger_base}) endif() if(WITH_RADOSGW_DBSTORE) diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 1189e3660b6b5..f2fc502a70fb9 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -334,7 +334,7 @@ int radosgw_Main(int argc, const char **argv) derr << "ERROR: unable to initialize rgw tools" << dendl; return -r; } - tracing::rgw::tracer.init("rgw"); + rgw_init_resolver(); rgw::curl::setup_curl(fe_map); rgw_http_client_init(g_ceph_context); diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 5f54fa3544538..a4d44267bfb4e 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -401,7 +401,7 @@ int process_request(rgw::sal::Store* const store, } done: - if (op && s->trace) { + if (op) { s->trace->SetAttribute(tracing::rgw::RETURN, op->get_ret()); if (s->user) { s->trace->SetAttribute(tracing::rgw::USER_ID, s->user->get_id().id); diff --git a/src/rgw/rgw_tracer.cc b/src/rgw/rgw_tracer.cc index 7e12bb2e62dcc..2d6720f591bac 100644 --- a/src/rgw/rgw_tracer.cc +++ b/src/rgw/rgw_tracer.cc @@ -7,7 +7,11 @@ namespace tracing { namespace rgw { +#ifdef HAVE_JAEGER +thread_local tracing::Tracer tracer("rgw"); +#else // !HAVE_JAEGER tracing::Tracer tracer; +#endif } // namespace rgw } // namespace tracing diff --git a/src/rgw/rgw_tracer.h b/src/rgw/rgw_tracer.h index 9cbae8b9c6792..77d4689d257e3 100644 --- a/src/rgw/rgw_tracer.h +++ b/src/rgw/rgw_tracer.h @@ -18,7 +18,11 @@ const auto TYPE = "type"; const auto REQUEST = "request"; const auto MULTIPART = "multipart_upload "; +#ifdef HAVE_JAEGER +extern thread_local tracing::Tracer tracer; +#else extern tracing::Tracer tracer; +#endif } // namespace rgw } // namespace tracing diff --git a/src/rgw/store/dbstore/CMakeLists.txt b/src/rgw/store/dbstore/CMakeLists.txt index 08dbe5f6fe675..18e032b73f54f 100644 --- a/src/rgw/store/dbstore/CMakeLists.txt +++ b/src/rgw/store/dbstore/CMakeLists.txt @@ -21,7 +21,7 @@ target_include_directories(dbstore_lib PUBLIC "${CMAKE_SOURCE_DIR}/src/fmt/inclu target_include_directories(dbstore_lib PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw") set(link_targets spawn) if(WITH_JAEGER) - list(APPEND link_targets jaeger_base) + list(APPEND link_targets ${jaeger_base}) endif() target_link_libraries(dbstore_lib PUBLIC ${link_targets}) diff --git a/win32_build.sh b/win32_build.sh index cace5fda9e80b..d8b5f76f9818d 100755 --- a/win32_build.sh +++ b/win32_build.sh @@ -162,7 +162,7 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \ -D WITH_GSSAPI=OFF -D WITH_XFS=OFF \ -D WITH_FUSE=OFF -D WITH_DOKAN=ON \ -D WITH_BLUESTORE=OFF -D WITH_LEVELDB=OFF \ - -D WITH_LTTNG=OFF -D WITH_BABELTRACE=OFF -D WITH_JAEGER=OFF \ + -D WITH_LTTNG=OFF -D WITH_BABELTRACE=OFF \ -D WITH_SYSTEM_BOOST=ON -D WITH_MGR=OFF -D WITH_KVS=OFF \ -D WITH_LIBCEPHFS=ON -D WITH_KRBD=OFF -D WITH_RADOSGW=OFF \ -D ENABLE_SHARED=$ENABLE_SHARED -D WITH_RBD=ON -D BUILD_GMOCK=ON \ -- 2.39.5