Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Jaeger Tracing Added #1

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fd36b14
Basic Jaeger Tracing Added
suab321321 Mar 15, 2020
b878b91
Basic Jaeger Tracing Added
suab321321 Mar 15, 2020
05e1442
Merge branch 'suab321321_jaegerTracing' of https://github.com/suab321…
suab321321 Mar 15, 2020
eeebe21
"Jaeger Tracing of Bucket List Request"
suab321321 Apr 13, 2020
f10c6f4
Tracer for object Uploading in Container added
suab321321 Apr 28, 2020
1aa2724
Removing Uneccessary code
suab321321 Apr 29, 2020
725a5a4
Error Uploading Object to Container resolved
suab321321 May 4, 2020
a3ba8d7
Converted variables into snake_case and removed non-essential code
suab321321 May 5, 2020
f605172
RGW_OP_GET_OBJ tracer and cleanup
suab321321 May 9, 2020
1ec9c76
RGW_OP_DELETE_OBJ Tracer added
suab321321 May 9, 2020
a98ce02
RGW_OP_DELETE_BUCKET Tracer Added
suab321321 May 11, 2020
1117ba5
S3 and Swift tag added
suab321321 May 12, 2020
d70d0f8
Injecting trace further deep down functions for RGW_LIST_BUCKETS
suab321321 May 14, 2020
b83e969
Added more tracer to into deep functions RGW_LIST_BUCKET
suab321321 May 15, 2020
7f68f4d
Added more traces in depth in RGWPutObj operation
suab321321 May 16, 2020
8c60410
Added more traces to in-depth functions of RGW_PUTObj
suab321321 May 17, 2020
ea7e1e0
More Tracer added in-depth fucntion RGW_DELETE_BUCKET
suab321321 May 17, 2020
2b1bb05
Added more traces in depth of RGWCreateBucket
suab321321 May 19, 2020
3a331ff
Added more in depth traces to RGW_DeleteObj
suab321321 May 19, 2020
a42be55
Tracer Added in req_state and ListBuckets tracing added
suab321321 May 21, 2020
c88c714
Tracer for ListBucket
suab321321 May 22, 2020
7d76769
DeleteContainer
suab321321 May 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@ if(WITH_BLKIN)
include_directories(SYSTEM src/blkin/blkin-lib)
endif(WITH_BLKIN)

option(WITH_JAEGER "Use jaeger to create tracepoints and display it on Jaeger UI" ON)

if(WITH_JAEGER)
#TODO: handle the case if libraries found locally, why be redundant?
#set(Jaeger_DIR "${CMAKE_CURRENT_LIST_DIR}/Jaegertracing/Jaeger-client-cpp")
find_package(OpenTracing REQUIRED)
find_package(Jaeger REQUIRED)
find_package(yaml-cpp REQUIRED)
set(Complete_Jaeger_LIBRARIES ${Jaeger_LIBRARIES} ${OpenTracing_LIBRARIES} ${yaml-cpp_LIBRARIES})
include_directories(SYSTEM ${Jaeger_INCLUDE_DIRS} ${yaml-cpp_INCLUDE_DIRS} ${OpenTracing_INCLUDE_DIRS})
endif(WITH_JAEGER)

option(WITH_BOOST_CONTEXT "Enable boost::asio stackful coroutines" ON)
if(WITH_BOOST_CONTEXT)
set(HAVE_BOOST_CONTEXT ON)
Expand Down
78 changes: 78 additions & 0 deletions cmake/modules/FindJaeger.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#.rst:
# FindJaeger
# ------------
#
# This module finds the `Jaeger` library.
#
# Imported target
# ^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``Jaeger``
# The Jaeger library, if found
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module sets the following
#
# ``Jaeger_FOUND``
# ``TRUE`` if system has Jaeger
# ``Jaeger_INCLUDE_DIRS``
# The Jaeger include directories
# ``Jaeger_LIBRARIES``
# The libraries needed to use Jaeger
# ``Jaeger_VERSION_STRING``
# The Jaeger version
# ``Jaeger_HAS_TRACEF``
# ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST
# ``Jaeger_HAS_TRACELOG``
# ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST

#=============================================================================
# Copyright 2018 Mania Abdi, Inc.
# Copyright 2018 Mania Abdi
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)

find_path(Jaeger_INCLUDE_DIRS NAMES jaegertracing/Tracer.h)
find_library(Jaeger_LIBRARIES NAMES jaegertracing)

if(Jaeger_INCLUDE_DIRS AND Jaeger_LIBRARIES)
# find tracef() and tracelog() support
set(Jaeger_HAS_TRACEF 0)
set(Jaeger_HAS_TRACELOG 0)

set(Jaeger_VERSION_STRING "0.5.0")

if(NOT TARGET Jaeger)
add_library(Jaeger UNKNOWN IMPORTED)
set_target_properties(Jaeger PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Jaeger_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${Jaeger_LIBRARIES}")
endif()

# add libdl to required libraries
set(Jaeger_LIBRARIES ${Jaeger_LIBRARIES} ${CMAKE_DL_LIBS})
endif()

# handle the QUIETLY and REQUIRED arguments and set LTTNGUST_FOUND to
# TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jaeger FOUND_VAR Jaeger_FOUND
REQUIRED_VARS Jaeger_LIBRARIES
Jaeger_INCLUDE_DIRS
VERSION_VAR Jaeger_VERSION_STRING)
mark_as_advanced(Jaeger_LIBRARIES Jaeger_INCLUDE_DIRS)

78 changes: 78 additions & 0 deletions cmake/modules/FindOpenTracing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#.rst:
# FindOpenTracing
# ------------
#
# This module finds the `OpenTracing` library.
#
# Imported target
# ^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``OpenTracing``
# The Opentracing library, if found
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module sets the following
#
# ``OpenTracing_FOUND``
# ``TRUE`` if system has OpenTracing
# ``OpenTracing_INCLUDE_DIRS``
# The OpenTracing include directories
# ``OpenTracing_LIBRARIES``
# The libraries needed to use OpenTracing
# ``OpenTracing_VERSION_STRING``
# The OpenTracing version
# ``OpenTracing_HAS_TRACEF``
# ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST
# ``OpenTracing_HAS_TRACELOG``
# ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST

#=============================================================================
# Copyright 2018 Mania Abdi, Inc.
# Copyright 2018 Mania Abdi
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)

find_path(OpenTracing_INCLUDE_DIRS NAMES opentracing/tracer.h)
find_library(OpenTracing_LIBRARIES NAMES opentracing)

if(OpenTracing_INCLUDE_DIRS AND OpenTracing_LIBRARIES)
# find tracef() and tracelog() support
set(OpenTracing_HAS_TRACEF 0)
set(OpenTracing_HAS_TRACELOG 0)

# will need specifically 1.5.x for successful working with Jaeger
set(OpenTracing_VERSION_STRING "1.5.x")

if(NOT TARGET OpenTracing)
add_library(OpenTracing UNKNOWN IMPORTED)
set_target_properties(OpenTracing PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenTracing_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OpenTracing_LIBRARIES}")
endif()

# add libdl to required libraries
set(OpenTracing_LIBRARIES ${OpenTracing_LIBRARIES} ${CMAKE_DL_LIBS})
endif()

# handle the QUIETLY and REQUIRED arguments and set LTTNGUST_FOUND to
# TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenTracing FOUND_VAR OpenTracing_FOUND
REQUIRED_VARS OpenTracing_LIBRARIES
OpenTracing_INCLUDE_DIRS
VERSION_VAR OpenTracing_VERSION_STRING)
mark_as_advanced(OpenTracing_LIBRARIES OpenTracing_INCLUDE_DIRS)
64 changes: 64 additions & 0 deletions cmake/modules/Findyaml-cpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# This file is open source software, licensed to you under the terms
# of the Apache License, Version 2.0 (the "License"). See the NOTICE file
# distributed with this work for additional information regarding copyright
# ownership. You may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

#
# Copyright (C) 2018 Scylladb, Ltd.
#

find_package (PkgConfig REQUIRED)

pkg_search_module (yaml-cpp_PC
QUIET
yaml-cpp)

find_library (yaml-cpp_LIBRARY
NAMES yaml-cpp
HINTS
${yaml-cpp_PC_LIBDIR}
${yaml-cpp_PC_LIBRARY_DIRS})

find_path (yaml-cpp_INCLUDE_DIR
NAMES yaml-cpp/yaml.h
PATH_SUFFIXES yaml-cpp
HINTS
${yaml-cpp_PC_INCLUDEDIR}
${yaml-cpp_PC_INCLUDE_DIRS})

mark_as_advanced (
yaml-cpp_LIBRARY
yaml-cpp_INCLUDE_DIR)

include (FindPackageHandleStandardArgs)

find_package_handle_standard_args (yaml-cpp
REQUIRED_VARS
yaml-cpp_LIBRARY
yaml-cpp_INCLUDE_DIR
VERSION_VAR yaml-cpp_PC_VERSION)

set (yaml-cpp_LIBRARIES ${yaml-cpp_LIBRARY})
set (yaml-cpp_INCLUDE_DIRS ${yaml-cpp_INCLUDE_DIR})

if (yaml-cpp_FOUND AND NOT (TARGET yaml-cpp::yaml-cpp))
add_library (yaml-cpp::yaml-cpp UNKNOWN IMPORTED)

set_target_properties (yaml-cpp::yaml-cpp
PROPERTIES
IMPORTED_LOCATION ${yaml-cpp_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${yaml-cpp_INCLUDE_DIRS})
endif ()
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ set(ceph_common_deps
${BLKID_LIBRARIES}
${Backtrace_LIBRARIES}
${BLKIN_LIBRARIES}
${Complete_Jaeger_LIBRARIES}
${CRYPTO_LIBS}
${GSSAPI_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
Expand Down
3 changes: 2 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ if(HAVE_ARMV8_CRC)
COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}")
endif()
target_link_libraries(crc32
arch)
arch
${Complete_Jaeger_LIBRARIES})

add_library(common_utf8 STATIC utf8.c)

Expand Down
46 changes: 46 additions & 0 deletions src/common/common_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,52 @@
#define dout_subsys ceph_subsys_

#ifndef WITH_SEASTAR
#ifdef WITH_JAEGER
CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags,Jager_Tracer& tracer,const Span& parent_span)
{
Span span=tracer.child_span("common_init.cc common_preinit()",parent_span);
// set code environment
ANNOTATE_BENIGN_RACE_SIZED(&g_code_env, sizeof(g_code_env), "g_code_env");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these changes part of your code? If not can you clean them up?

g_code_env = code_env;

// Create a configuration object
CephContext *cct = new CephContext(iparams.module_type, code_env, flags);

auto& conf = cct->_conf;
// add config observers here

// Set up our entity name.
conf->name = iparams.name;

// different default keyring locations for osd and mds. this is
// for backward compatibility. moving forward, we want all keyrings
// in these locations. the mon already forces $mon_data/keyring.
if (conf->name.is_mds()) {
conf.set_val_default("keyring", "$mds_data/keyring");
} else if (conf->name.is_osd()) {
conf.set_val_default("keyring", "$osd_data/keyring");
}

if ((flags & CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS)) {
// make this unique despite multiple instances by the same name.
conf.set_val_default("admin_socket",
"$run_dir/$cluster-$name.$pid.$cctid.asok");
}

if (code_env == CODE_ENVIRONMENT_LIBRARY ||
code_env == CODE_ENVIRONMENT_UTILITY_NODOUT) {
conf.set_val_default("log_to_stderr", "false");
conf.set_val_default("err_to_stderr", "false");
conf.set_val_default("log_flush_on_exit", "false");
}

conf.set_val("no_config_file", iparams.no_config_file ? "true" : "false");

return cct;
}
#endif

CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags)
{
Expand Down
3 changes: 3 additions & 0 deletions src/common/common_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "include/common_fwd.h"
#include "common/code_environment.h"
#include "include/tracer.h"

enum common_init_flags_t {
// Set up defaults that make sense for an unprivileged daemon
Expand Down Expand Up @@ -65,6 +66,8 @@ class CephInitParameters;
*/
CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags);
CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags,Jager_Tracer&,const Span&);
#endif // #ifndef WITH_SEASTAR

/* Print out some parse error. */
Expand Down
26 changes: 26 additions & 0 deletions src/common/jaegerTracer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


#ifndef JAEGER_TRACER_
#define JAEGER_TRACER_

#include <memory>
#include<jaegertracing/Tracer.h>
#include <opentracing/tracer.h>

class jTracer
{
private:
static jaegertracing::Config configuration;
public:
jTracer() {}
static void loadYamlConfigFile(const char *);
void initTracer(const char *);
std::unique_ptr<opentracing::Span> newSpan(const char *);
std::unique_ptr<opentracing::Span> childSpan(const char *, const std::unique_ptr<opentracing::Span> &);
std::unique_ptr<opentracing::Span> followUpSpan(const char *, const std::unique_ptr<opentracing::Span> &);
~jTracer(){
opentracing::Tracer::Global()->Close();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

}
};

#endif
34 changes: 34 additions & 0 deletions src/common/jaegerTracing.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#include <yaml-cpp/yaml.h>
#include <iostream>
#include "jaegerTracer.h"

void jTracer::loadYamlConfigFile(const char *filePath)
{
auto yaml = YAML::LoadFile(filePath);
jTracer::configuration = jaegertracing::Config::parse(yaml);
}

void jTracer::initTracer(const char *tracerName)
{
auto tracer = jaegertracing::Tracer::make(
tracerName,
jTracer::configuration,
jaegertracing::logging::consoleLogger());
opentracing::Tracer::InitGlobal(
std::static_pointer_cast<opentracing::Tracer>(tracer));
}
std::unique_ptr<opentracing::Span> newSpan(const char * spanName){
auto Span=opentracing::Tracer::Global()->StartSpan(spanName);
return std::move(Span);
}
std::unique_ptr<opentracing::Span> jTracer::childSpan(const char *spanName, const std::unique_ptr<opentracing::Span> &parentSpan)
{
auto Span = opentracing::Tracer::Global()->StartSpan(spanName, {opentracing::ChildOf(&parentSpan->context())});
return std::move(Span);
}
std::unique_ptr<opentracing::Span> jTracer::followUpSpan(const char *spanName, const std::unique_ptr<opentracing::Span> &parentSpan)
{
auto Span = opentracing::Tracer::Global()->StartSpan(spanName, {opentracing::FollowsFrom(&parentSpan->context())});
return std::move(Span);
}
Loading