Skip to content

Commit

Permalink
Basic Jaeger Tracing Added
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Singh <[email protected]>
  • Loading branch information
suab321321 committed Mar 15, 2020
1 parent 053fd8f commit fd36b14
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
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();
}
};

#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);
}
5 changes: 5 additions & 0 deletions src/rgw/rgw_aio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ Aio::OpFunc aio_abstract(Op&& op) {
return [op = std::move(op)] (Aio* aio, AioResult& r) mutable {
constexpr bool read = std::is_same_v<std::decay_t<Op>, librados::ObjectReadOperation>;
auto s = new (&r.user_data) state(aio, r);
jTracer tracer;
if constexpr (read) {
tracer.initTracer("Reading Started");
auto span=tracer.newSpan("Aio Read Operation started");
r.result = r.obj.aio_operate(s->c, &op, &r.data);
} else {
tracer.initTracer("Writing Started");
auto span=tracer.newSpan("Aio Write Operation started");
r.result = r.obj.aio_operate(s->c, &op);
}
if (r.result < 0) {
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_aio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "services/svc_rados.h" // cant forward declare RGWSI_RADOS::Obj

#include "rgw_common.h"
#include "common/jaegerTracer.h"

#include "include/function2.hpp"

Expand Down
6 changes: 6 additions & 0 deletions src/rgw/rgw_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "rgw_frontend.h"
#include "rgw_http_client_curl.h"
#include "rgw_perf_counters.h"

#include "common/jaegerTracer.h"

#ifdef WITH_RADOSGW_AMQP_ENDPOINT
#include "rgw_amqp.h"
#endif
Expand Down Expand Up @@ -679,6 +682,9 @@ extern "C" {

int radosgw_main(int argc, const char** argv)
{
//loading the yaml configuration file for rgw
jTracer tracer;
tracer.loadYamlConfigFile("tracerConfiguration.yaml");
return radosgw_Main(argc, argv);
}

Expand Down

0 comments on commit fd36b14

Please sign in to comment.