Skip to content

Commit

Permalink
Merge branch 'esigo-approver' of github.com:lalitb/opentelemetry-cpp …
Browse files Browse the repository at this point in the history
…into esigo-approver
  • Loading branch information
lalitb committed Jan 25, 2022
2 parents cf2efff + a85337b commit 802e12c
Show file tree
Hide file tree
Showing 100 changed files with 2,059 additions and 385 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: OpenTelemetry-cpp benchmarks
on:
push:
branches:
- main

permissions:
contents: write
deployments: write

jobs:
benchmark:
name: Run OpenTelemetry-cpp benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v2
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_benchmark
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: Run benchmark
id: run_benchmarks
run: |
ci/do_ci.sh bazel.benchmark
mkdir -p benchmarks
mv api-benchmark_result.json benchmarks
mv sdk-benchmark_result.json benchmarks
mv exporters-benchmark_result.json benchmarks
- uses: actions/upload-artifact@master
with:
name: benchmark_results
path: benchmarks
store_benchmark:
needs: benchmark
strategy:
matrix:
components: ["api", "sdk", "exporters"]
name: Store benchmark result
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@master
with:
name: benchmark_results
path: benchmarks
- name: Print json files
id: print_json
run: |
cat benchmarks/*
- name: Push benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark
tool: 'googlecpp'
output-file-path: benchmarks/${{ matrix.components }}-benchmark_result.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
gh-pages-branch: gh-pages
benchmark-data-dir-path: benchmarks
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.test

bazel_with_abseil:
name: Bazel with external abseil
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v2
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_test
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
run: ./ci/do_ci.sh bazel.with_abseil

bazel_valgrind:
name: Bazel valgrind
runs-on: ubuntu-latest
Expand Down Expand Up @@ -386,7 +408,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: install docfx
run: choco install docfx -y
run: choco install docfx -y --version=2.58.5
- name: run ./ci/docfx.cmd
shell: cmd
run: ./ci/docfx.cmd
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@
/bazel-*
/plugin
/build

tags
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ Increment the:

## [Unreleased]

* [API/SDK] Logger: Support for Instrumentation library ([#1128](https:/open-telemetry/opentelemetry-cpp/pull/1128))
* [SDK] Add LogLevel to internal_log ([#1147](https:/open-telemetry/opentelemetry-cpp/pull/1147))
* [API/SDK] Logger: Propagating resources through LoggerProvider ([#1154](https:/open-telemetry/opentelemetry-cpp/pull/1154))
* [API]: Allow to use external abseil for bazel targets ([#1172](https:/open-telemetry/opentelemetry-cpp/pull/1172))

## [1.1.1] 2021-12-
## [1.1.1] 2021-12-20

* [SDK] Rename OTEL_CPP_GET_ATTR macro, and define it using fully qualified attr function ([#1140](https:/open-telemetry/opentelemetry-cpp/pull/1140))
* [SDK] Default resource attributes and attributes in OTEL_RESOURCE_ATTRIBUTES are missing when using Otlp*LogExporter ([#1082](https:/open-telemetry/opentelemetry-cpp/pull/1082))
Expand Down
30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ else()
)
endif()

option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)
option(WITH_STL "Whether to use Standard Library for C++ latest features" OFF)
option(WITH_GSL
"Whether to use Guidelines Support Library for C++ latest features" OFF)

option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)

Expand Down Expand Up @@ -137,18 +139,6 @@ if(WITH_STL)
# (absl::variant or std::variant) in variant unit test code is consistent with
# the global project build definitions.
add_definitions(-DHAVE_CPP_STDLIB)
add_definitions(-DHAVE_GSL)

# Guidelines Support Library path. Used if we are not on not get C++20.
#
# TODO: respect WITH_ABSEIL as alternate implementation of std::span
find_package(Microsoft.GSL QUIET)
if(TARGET Microsoft.GSL::GSL)
list(APPEND CORE_RUNTIME_LIBS Microsoft.GSL::GSL)
else()
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)
endif()

# Optimize for speed to reduce the hops
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand All @@ -165,6 +155,20 @@ if(WITH_STL)
endif()
endif()

if(WITH_GSL)
add_definitions(-DHAVE_GSL)

# Guidelines Support Library path. Used if we are not on not get C++20.
#
find_package(Microsoft.GSL QUIET)
if(TARGET Microsoft.GSL::GSL)
list(APPEND CORE_RUNTIME_LIBS Microsoft.GSL::GSL)
else()
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)
endif()
endif()

option(WITH_OTLP "Whether to include the OpenTelemetry Protocol in the SDK" OFF)
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)

Expand Down
23 changes: 23 additions & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

package(default_visibility = ["//visibility:public"])

bool_flag(
name = "with_abseil",
build_setting_default = False,
)

cc_library(
name = "api",
hdrs = glob(["include/**/*.h"]),
defines = select({
":with_external_abseil": ["HAVE_ABSEIL"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
tags = ["api"],
deps = select({
":with_external_abseil": [
"@com_google_absl//absl/base",
"@com_google_absl//absl/types:variant",
],
"//conditions:default": [],
}),
)

config_setting(
name = "with_external_abseil",
flag_values = {":with_abseil": "true"},
)
3 changes: 1 addition & 2 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ endif()

if(WITH_STL)
message("Building with standard library types...")
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB
HAVE_GSL)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB)
else()
message("Building with nostd types...")
endif()
Expand Down
26 changes: 26 additions & 0 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <cstdint>

#include "opentelemetry/version.h"

/// \brief Declare variable as maybe unused
/// usage:
/// OPENTELEMETRY_MAYBE_UNUSED int a;
/// class OPENTELEMETRY_MAYBE_UNUSED a;
/// OPENTELEMETRY_MAYBE_UNUSED int a();
///
#if defined(__cplusplus) && __cplusplus >= 201703L
# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]]
#elif defined(__clang__)
# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused))
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused))
#elif (defined(_MSC_VER) && _MSC_VER >= 1910) && (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]]
#else
# define OPENTELEMETRY_MAYBE_UNUSED
#endif
1 change: 1 addition & 0 deletions api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# ifndef NOMINMAX
# define NOMINMAX
# endif
# define _WINSOCKAPI_ // stops including winsock.h
# include <windows.h>
#elif defined(__i386__) || defined(__x86_64__)
# if defined(__clang__)
Expand Down
40 changes: 11 additions & 29 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class Logger
* @param severity the severity level of the log event.
* @param name the name of the log event.
* @param message the string message of the log (perhaps support std::fmt or fmt-lib format).
* @param resource the resources, stored as a 2D list of key/value pairs, that are associated
* with the log event.
* @param attributes the attributes, stored as a 2D list of key/value pairs, that are associated
* with the log event.
* @param trace_id the trace id associated with the log event.
Expand All @@ -57,13 +55,10 @@ class Logger
/**
* The base Log(...) method that all other Log(...) overloaded methods will eventually call,
* in order to create a log record.
*
* Note this takes in a KeyValueIterable for the resource and attributes fields.
*/
virtual void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
const common::KeyValueIterable &resource,
const common::KeyValueIterable &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
Expand All @@ -74,40 +69,32 @@ class Logger
/**
* The secondary base Log(...) method that all other Log(...) overloaded methods except the one
* above will eventually call, in order to create a log record.
*
* Note this takes in template types for the resource and attributes fields.
*/
template <class T,
class U,
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr,
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
const T &resource,
const U &attributes,
const T &attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept
{
Log(severity, name, body, common::KeyValueIterableView<T>(resource),
common::KeyValueIterableView<U>(attributes), trace_id, span_id, trace_flags, timestamp);
Log(severity, name, body, common::KeyValueIterableView<T>(attributes), trace_id, span_id,
trace_flags, timestamp);
}

void Log(Severity severity,
nostd::string_view name,
nostd::string_view body,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> resource,
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
trace::TraceId trace_id,
trace::SpanId span_id,
trace::TraceFlags trace_flags,
common::SystemTimestamp timestamp) noexcept
{
return this->Log(severity, name, body,
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
resource.begin(), resource.end()},
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
attributes.begin(), attributes.end()},
trace_id, span_id, trace_flags, timestamp);
Expand All @@ -122,7 +109,7 @@ class Logger
*/
void Log(Severity severity, nostd::string_view message) noexcept
{
this->Log(severity, "", message, {}, {}, {}, {}, {}, std::chrono::system_clock::now());
this->Log(severity, "", message, {}, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -133,7 +120,7 @@ class Logger
*/
void Log(Severity severity, nostd::string_view name, nostd::string_view message) noexcept
{
this->Log(severity, name, message, {}, {}, {}, {}, {}, std::chrono::system_clock::now());
this->Log(severity, name, message, {}, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -145,8 +132,7 @@ class Logger
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Log(Severity severity, const T &attributes) noexcept
{
this->Log(severity, "", "", std::map<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
this->Log(severity, "", "", attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -159,8 +145,7 @@ class Logger
nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value> * = nullptr>
void Log(Severity severity, nostd::string_view name, const T &attributes) noexcept
{
this->Log(severity, name, "", std::map<std::string, std::string>{}, attributes, {}, {}, {},
std::chrono::system_clock::now());
this->Log(severity, name, "", attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -172,7 +157,7 @@ class Logger
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(severity, "", "", {}, attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(severity, "", "", attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -186,7 +171,7 @@ class Logger
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
attributes) noexcept
{
this->Log(severity, name, "", {}, attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(severity, name, "", attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/**
Expand All @@ -200,10 +185,7 @@ class Logger
nostd::string_view name,
common::KeyValueIterable &attributes) noexcept
{
this->Log(severity, name, {},
common::KeyValueIterableView<
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>>({}),
attributes, {}, {}, {}, std::chrono::system_clock::now());
this->Log(severity, name, {}, attributes, {}, {}, {}, std::chrono::system_clock::now());
}

/** Trace severity overloads **/
Expand Down
Loading

0 comments on commit 802e12c

Please sign in to comment.