Permalink
Browse files

Initial opentracing C++ version

  • Loading branch information...
1 parent 368f2cd commit 8b1efd1156e202d615fe3ee23e49188294a1d210 @lookfwd lookfwd committed Jun 1, 2016
Showing with 1,113 additions and 2 deletions.
  1. +6 −0 AUTHORS
  2. +21 −0 COPYING
  3. +4 −0 ChangeLog
  4. +16 −0 Makefile.am
  5. +1 −0 NEWS
  6. +1 −0 README
  7. +34 −2 README.md
  8. +5 −0 autogen.sh
  9. +27 −0 configure.ac
  10. BIN img/stack-of-libraries.png
  11. 0 opentracing/Makefile.am
  12. +111 −0 opentracing/span.cc
  13. +200 −0 opentracing/span.h
  14. +143 −0 opentracing/tracer.cc
  15. +305 −0 opentracing/tracer.h
  16. +27 −0 test/Makefile
  17. +212 −0 test/opentracing.t.cc
View
@@ -0,0 +1,6 @@
+AUTHORS
+-------
+
+
+Felipe Bergo <bergo@seul.org>
+
View
@@ -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.
View
@@ -0,0 +1,4 @@
+
+libdinner ChangeLog
+
+* initial release
View
@@ -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
View
@@ -0,0 +1 @@
+no news
View
@@ -0,0 +1 @@
+See README.md
View
@@ -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.
View
@@ -0,0 +1,5 @@
+#! /bin/sh
+
+aclocal \
+&& automake --add-missing \
+&& autoconf
View
@@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
No changes.
View
@@ -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;
+}
+
+}
Oops, something went wrong.

0 comments on commit 8b1efd1

Please sign in to comment.