forked from ceph/ceph
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Abhinav Singh <[email protected]>
- Loading branch information
1 parent
053fd8f
commit fd36b14
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters