Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

opentracing-cpp re-redux (virtual inheritance) #7

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AUTHORS
-------


OpenTracing Developers

Dmitrios Kouzis-Loukas : dkouzislouka AT bloomberg DOT net
James Wells : jwells31 AT bloomberg DOT net
Jim Quinn : jquinn47 AT bloomberg DOT net
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required (VERSION 2.8)
set(PROJECT_NAME "opentracing")
project (${PROJECT_NAME})

set(lib_major_version "2")
set(lib_minor_version "0")
set(lib_patch_version "0")
set(opentracing_version "${lib_major_version}.${lib_minor_version}.${lib_patch_version}")
set(opentracing_url "https://github.com/opentracing/opentracing-cpp")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

option(enable_noop "Build noop tracer." OFF)
option(enable_tests "Build unit tests." OFF)

add_subdirectory(opentracing)

if(enable_tests)
enable_testing()
add_subdirectory(thirdparty/googletest/googletest)
add_subdirectory(test)
endif()
50 changes: 46 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@

opentracing-cpp ChangeLog

* initial release
f18e949 (HEAD -> master, jq/cmake-fun) Remove default contructors and handle side effects
29e1285 Remove cmake makefile
a83c752 Merge branch 'master' of https://bbgithub.dev.bloomberg.com/jquinn1/opentracing-cpp
963d016 Cmake, removing unused template functionality, ditching config.h for now
1120bb0 (jq/master) Merge pull request #3 from jquinn1/noop-shift
bde3545 Clean up build system, ability to turn off no-op, integrate tests
ef885ee (jq/noop-shift) Update reqs for tracerimps
88e1e8b Merge branch 'master' of https://bbgithub.dev.bloomberg.com/jquinn1/opentracing-cpp
a8b9017 Moving noop into its own package, updated tests
5e3885a Merge pull request #2 from jquinn1/changes
5ff6015 (jq/changes) Review feedback, removing guards, updated docs
eeb6fa3 typo
05f3bf3 Example compiler problem
b5e5486 Update examples
9f1daca formatting never ends
8f1025e formatting never ends
59e565f formatting
1f77d05 formatting
63ff455 Updating docs
9656c0b Adding iterator behaviors
3b86ccf Adding log/tags/baggage usage
d35931b Update usage
47a9047 Adding constants.h
c8d422c Adding guards, updating documentation and tests
d42770a Updating documentation
419580e Updating tests, adding spanoptions, consistently documented
1ee01dc Minor formatting
94227b4 Adding No-op implementation
b45a540 Adding noop, Baggage/BaggageWide, StringRefWide, and docs
2f37155 Solving the wide baggage problem
06ff151 Some documentation, StringRefWide
70d1545 Remove bad example
3381ca1 Testing everything, at least a little
ded4c0c StringRef, BaggageRef, BaggageIterator drafted
efadeda (origin/master, origin/HEAD) keep gcc specific flags specific to a gcc build (#5)
012743c Update configure.ac
3933120 Update configure.ac
6623183 Update ChangeLog
e1c9ea6 Update AUTHORS
7fecd71 a clarification (#4)
e0ea9eb Converting TextMapReader callback to functor (#2)
8b1efd1 Initial opentracing C++ version
368f2cd Merge pull request #1 from gitter-badger/gitter-badge
574ef91 Add Gitter badge
9ec9136 Update README.md
bfb0b74 Initial commit
19 changes: 0 additions & 19 deletions Makefile.am

This file was deleted.

12 changes: 12 additions & 0 deletions PROPOSED
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Virtual inheritance model

## Pros
* Traditional OO/Simpler (major)
* Decouples Tracer from span/carrier
* Moves physical organization problem into carriers, (still messy, but much better than defining details in tracer)

##Cons
* Spec adjustment, requiring reset/externalize for carrier fallback
* More complicated carrier code (minor)
* more expensive 'no-ops', always hit v-table (minor)
* No longer header only. Tracer singleton interface requires static storage is defined (more annoying, but still minor)
52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,57 @@ C++ implementation of the OpenTracing API http://opentracing.io

[![Join the chat at https://gitter.im/opentracing/opentracing-cpp](https://badges.gitter.im/opentracing/opentracing-cpp.svg)](https://gitter.im/opentracing/opentracing-cpp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)


## Required Reading

In order to understand the C++ platform API, one must first be familiar with the
[OpenTracing project](http://opentracing.io) and
[terminology](http://opentracing.io/spec/) more generally. This is a C++98 API that
is used as a "common denominator". Ît's up to implementors to choose the C++ level
they are going to use for their implementations:
In order to understand the C++ platform API, one must first be familiar with the [OpenTracing project](http://opentracing.io) and
[terminology](http://opentracing.io/spec/) more generally. This is a C++98 API that is used as a "common denominator".
Ît is up to implementors to choose the C++ level they are going to use for their implementations:

![stack of libraries](img/stack-of-libraries.png "Stack of Libraries")

## Compile and install

The default package is a header-only library. It can be installed as such

```
libtoolize # or glibtoolize
./autogen.sh
./configure
sudo make install
mkdir build
cd build
cmake ..
make install
```

To test (requires gtest - see [here for OS X](http://stackoverflow.com/questions/20746232/how-to-properly-setup-googletest-on-os-x-aside-from-xcode), [here for ubuntu](http://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/) and [here for Red Hat](http://stackoverflow.com/questions/13513905/how-to-setup-googletest-as-a-shared-library-on-linux)/for Red Hat note also [this](http://stackoverflow.com/questions/4743233/is-usr-local-lib-searched-for-shared-libraries)):
If you would like to include the NoopTracer, a static library is created in addition to the headers.

```
cd test
mkdir build
cd build
cmake -Denable_noop=ON ..
make install
```

#### Tests

Testing requires the use of `gtest`. The `gtest` library is added as a submodule to this repository.
To build all of the tests, from the root repository:

```
git submodule init
git submodule update
mkdir build
cd build
cmake -Denable_tests=ON ..
make
./test
./bin/unittest
```

If you're using the `NoopTracer`, you would want to add `-Denable_noop=ON` as well.

## API overview for those adding instrumentation

Everyday consumers of this `opentracing` package really only need to worry
about a couple of key abstractions: the `StartSpan` function, the `Span`
interface, and binding a `Tracer` at `main()`-time.
Clients of this `OpenTracing` only need to understand the key abstractions:
* Installing a Tracer
* Using the Global `Tracer` to create `Spans` and `SpanContexts`
* Adding tags, logs, or baggage to `Spans`

See the detailed [usage](./docs/usage.md) documentation for details.
5 changes: 0 additions & 5 deletions autogen.sh

This file was deleted.

29 changes: 0 additions & 29 deletions configure.ac

This file was deleted.

42 changes: 42 additions & 0 deletions opentracing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
include_directories(${CMAKE_SOURCE_DIR})

set(headers
carriers.h
constants.h
spancontext.h
span.h
spanoptions.h
stringref.h
tracer.h)

if(enable_noop)
# Used by pc file
set(opentracing_libs "-L${libdir} -lopentracing")

# Updated set of included files
set(headers ${headers} noop.h)

# Build our opentracing library
add_library(opentracing STATIC noop.cc)

# Add the opentracing install target
install (TARGETS opentracing
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
COMPONENT dev)
endif()

# Install the opentracing headers into /path/to/include/opentracing/
install (FILES ${headers}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/opentracing
COMPONENT dev)

# pkg-config
if("${UNIX}" OR "${CYGWIN}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
@ONLY)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT pkgconfig)
endif()
Empty file removed opentracing/Makefile.am
Empty file.
29 changes: 29 additions & 0 deletions opentracing/carriers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef INCLUDED_OPENTRACING_CARRIERS_H
#define INCLUDED_OPENTRACING_CARRIERS_H

#include <opentracing/span.h>
#include <opentracing/spancontext.h>

namespace opentracing {

class Writer {
public:
virtual int inject(const Span&) = 0;
virtual int inject(const SpanContext&) = 0;

protected:
Writer();
Writer(const Writer&);
};

class Reader {
public:
int extract(SpanContext*) const = 0;

protected:
Reader();
Reader(const Reader&);
};

} // namespace opentracing
#endif // INCLUDED_OPENTRACING_CARRIERS_H
28 changes: 28 additions & 0 deletions opentracing/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef INCLUDED_OPENTRACING_CONSTANTS_H
#define INCLUDED_OPENTRACING_CONSTANTS_H

// ===========
// constants.h
// ===========
// This header provides a set of macros for the "standard" OpenTracing tag and
// log fields. For a description of each value, and how it should be used, see:
// https://github.com/opentracing/specification/blob/master/data_conventions.yaml

#define OPENTRACING_TAG_ERROR "error"
#define OPENTRACING_TAG_COMPONENT "component"
#define OPENTRACING_TAG_SAMPLING_PRIORITY "sampling.priority "

#define OPENTRACING_TAG_HTTP_URL "http.url"
#define OPENTRACING_TAG_HTTP_METHOD "http.method"
#define OPENTRACING_TAG_HTTP_STATUS "http.status"

#define OPENTRACING_TAG_SPAN_KIND "span.kind"
#define OPENTRACING_TAG_PEER_HOSTNAME "peer.hostname"
#define OPENTRACING_TAG_PEER_IPV4 "peer.ipv4"
#define OPENTRACING_TAG_PEER_IPV6 "peer.ipv6"
#define OPENTRACING_TAG_PEER_PORT "peer.port"
#define OPENTRACING_TAG_PEER_SERVICE "peer.service"

#define OPENTRACING_LOG_EVENT "event"

#endif
21 changes: 21 additions & 0 deletions opentracing/globaltracer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <opentracing/globaltracer.h>
#include <opentracing/tracer.h>

namespace opentracing{

void GlobalTracer::install(Tracer *)
{
s_tracer = tracer;
}

void GlobalTracer::uninstall()
{
s_tracer = 0;
}

Tracer* GlobalTracer::instance()
{
return s_Tracer;
}

}
25 changes: 25 additions & 0 deletions opentracing/globaltracer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef INCLUDED_OPENTRACING_GLOBALTRACER_H
#define INCLUDED_OPENTRACING_GLOBALTRACER_H

// Only if the singleton interface is included do we require that opentracing
// produce a .a or .so library. To avoid building a physical lib for a 'flea on
// the elephant', I've moved the singleton GlobalTracer struct. It's only
// built if requested.

namespace opentracing {

class Tracer;

struct GlobalTracer
{
public:
static void install(Tracer*);
static void uninstall();
static Tracer* instance();

private:
static GlobalTracer* s_tracer;
};

} // namespace opentracing
// #INCLUDED_OPENTRACING_GLOBALTRACER_H
13 changes: 13 additions & 0 deletions opentracing/opentracing.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include

Name: @PROJECT_NAME@
Description: C++ interface for the OpenTracing specification
URL: @opentracing_url@
Version: @opentracing_version@
Requires:
Requires.private:
Libs: @opentracing_libs@
Libs.private:
Cflags: -I${includedir}
Loading