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

Commit

Permalink
Initial opentracing C++ version
Browse files Browse the repository at this point in the history
  • Loading branch information
lookfwd committed Jun 1, 2016
1 parent 368f2cd commit 8b1efd1
Show file tree
Hide file tree
Showing 17 changed files with 1,113 additions and 2 deletions.
6 changes: 6 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AUTHORS
-------


Felipe Bergo <[email protected]>

21 changes: 21 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 OpenTracing developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

libdinner ChangeLog

* initial release
16 changes: 16 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
AUTOMAKE_OPTIONS = gnu

lib_LTLIBRARIES = libopentracing.la

libopentracing_la_SOURCES = opentracing/span.cc opentracing/tracer.cc

nobase_include_HEADERS = opentracing/span.h opentracing/tracer.h

libopentracing_la_LDFLAGS = -version-info 1:0:0


ACLOCAL_AMFLAGS = -I m4

AM_CXXFLAGS= -Wall -fno-elide-constructors -pedantic-errors -ansi -Wextra -Wall
AM_CXXFLAGS+= -Winit-self -Wold-style-cast -Woverloaded-virtual -Winit-self
AM_CXXFLAGS+= -Wuninitialized -Wmissing-declarations -Werror -std=c++98
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
no news
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See README.md
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# opentracing-cpp
# OpenTracing API for C++
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)

Current status: WIP; see [this PR](https://github.com/lookfwd/opentracing-cpp/pull/1)
## 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:

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

## Compile and install

```
libtoolize # or glibtoolize
./autogen.sh
./configure
sudo 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)):

```
cd test
make
./test
```

## 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.
5 changes: 5 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/sh

aclocal \
&& automake --add-missing \
&& autoconf
27 changes: 27 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
AC_INIT([libdinner], [0.0.1])
#AC_CONFIG_SRCDIR(libdinner.cc)
#AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_INIT_AUTOMAKE([subdir-objects])

AC_CONFIG_MACRO_DIR([m4])

#AC_CONFIG_HEADERS([config.h])

AM_PROG_LIBTOOL

AC_PROG_INSTALL

AC_LANG_C
AC_PROG_CC
AC_PROG_CXX
AC_PROG_MAKE_SET

AC_HEADER_STDC

#AC_CHECK_HEADERS(unistd.h netdb.h netinet/in.h sys/types.h sys/socket.h,,AC_MSG_ERROR([required header file missing]))
#AC_CHECK_FUNCS(gethostbyname socket htons connect shutdown,,AC_MSG_ERROR([required standard library function missing]))

AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
Binary file added img/stack-of-libraries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added opentracing/Makefile.am
Empty file.
111 changes: 111 additions & 0 deletions opentracing/span.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <opentracing/tracer.h>
#include <opentracing/span.h>

namespace opentracing
{

Span::~Span()
{
}

Span * Span::setOperationName(const std::string & operationName)
{
(void)operationName;

return this;
}

Span * Span::setTag(const std::string & key, const std::string & value)
{
(void)key;
(void)value;

return this;
}

Span * Span::log(const LogData & data)
{
(void)data;

return this;
}

Span * Span::log(const std::vector<LogData> & logData)
{
for (std::vector<LogData>::const_iterator i = logData.begin(); i != logData.end(); ++i)
{
log(*i);
}
return this;
}

Span * Span::setBaggageItem(const std::string & restrictedKey, const std::string & value)
{
(void)restrictedKey;
(void)value;

return this;
}

bool Span::getBaggageItem(const std::string & restrictedKey, std::string * targetValue) const
{
(void)restrictedKey;
(void)targetValue;

return false;
}

void Span::finish()
{
finish(0);
}

void Span::finish(const uint64_t & finishTime)
{
(void)finishTime;
}

LogData::LogData(const std::string & event_, const Payload & payload_)
: timestamp(0)
, event(event_)
, payload(payload_)
{
}

LogData::LogData(const uint64_t & timestamp_, const std::string & event_, const Payload & payload_)
: timestamp(timestamp_)
, event(event_)
, payload(payload_)
{
}

bool canonicalizeBaggageKey(std::string & key)
{
if (key.empty())
{
return false;
}

for (std::string::iterator i = key.begin(); i != key.end(); ++i)
{
*i = tolower(*i);
}

for (std::string::iterator i = key.begin(); i != key.end(); ++i)
{
char c(*i);

if ((c>='a' && c<='z') || (c>='0' && c<='9') || (c=='-' && i != key.begin()))
{
// This is ok.
}
else
{
return false;
}
}

return true;
}

}
Loading

2 comments on commit 8b1efd1

@sureshbalakundi
Copy link

Choose a reason for hiding this comment

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

can you give some Normal c++ example ..it will better to understand

@lookfwd
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @sureshbalakundi, the above C++ code is quite normal. I'm not sure what you expect. That said, you can't use opentracing-c++ as it is, right now, for anything useful to you. Join the discussions and you will see if there's any progress.

Please sign in to comment.