Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into metrics-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Aug 27, 2022
2 parents f63605f + 1f37839 commit 360ee03
Show file tree
Hide file tree
Showing 27 changed files with 502 additions and 121 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ jobs:
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.test
cmake_deprecated_metrics_test:
name: CMake test (without otlp-exporter and with deprecated metrics)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: run cmake tests (without otlp-exporter)
run: |
sudo ./ci/setup_thrift.sh
./ci/do_ci.sh cmake.deprecated_metrics.test
cmake_with_async_export_test:
name: CMake test (without otlp-exporter and with async export)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -166,6 +182,28 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.test

bazel_deprecated_metrics_test:
name: Bazel deprecated metrics
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v3
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.deprecated_metrics.test

bazel_test_async:
name: Bazel with async export
runs-on: ubuntu-latest
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@ Increment the:

## [Unreleased]

* [BUILD] Upgrade opentelemetry-proto to v0.19.0 [#1579](https://github.com/open-telemetry/opentelemetry-cpp/pull/1579)

## [1.6.0] 2022-08-15

* [METRICS SDK] Calling Observable Instruments callback during metrics
collection
[#1554](https://github.com/open-telemetry/opentelemetry-cpp/pull/1554)
* [METRICS CI] Add CI jobs for new and deprecated metrics [#1531](https://github.com/open-telemetry/opentelemetry-cpp/pull/1531)
* [METRICS BUILD] Fix metrics asan and tsan CI [#1562](https://github.com/open-telemetry/opentelemetry-cpp/pull/1562)
* [METRICS SDK] remove throw check from metrics with noexcept [#1560](https://github.com/open-telemetry/opentelemetry-cpp/pull/1560)
* [METRICS SDK] fix metrics race condition [#1552](https://github.com/open-telemetry/opentelemetry-cpp/pull/1552)
* [METRICS SDK] Fix metrics context circular reference [#1535](https://github.com/open-telemetry/opentelemetry-cpp/pull/1535)
* [METRICS EXPORTER] Improve scope/instrument names in metrics ostream exporter [#1544](https://github.com/open-telemetry/opentelemetry-cpp/pull/1544)
* [METRICS BUILD] fix IWYU error in instruments.h [#1555](https://github.com/open-telemetry/opentelemetry-cpp/pull/1555)
* [EXPORTER] Prometheus exporter support Gauge Type [#1553](https://github.com/open-telemetry/opentelemetry-cpp/pull/1553)
* [METRICS SDK] Fix default Metric view name [#1515](https://github.com/open-telemetry/opentelemetry-cpp/pull/1515)
* [SDK] Fix infinitely waiting when shutdown with more than one running http
sessions.
[#1549](https://github.com/open-telemetry/opentelemetry-cpp/pull/1549)
* [METRICS SDK] Fix OTLP gRPC Metrics env variables [#1543](https://github.com/open-telemetry/opentelemetry-cpp/pull/1543)
* [METRICS SDK] Metric aggregation temporality controls [#1541](https://github.com/open-telemetry/opentelemetry-cpp/pull/1541)
* [METRICS SDK] Histogram min/max support [#1540](https://github.com/open-telemetry/opentelemetry-cpp/pull/1540)
* [METRICS EXPORTER] ostream exporter should print out resource attributes [#1523](https://github.com/open-telemetry/opentelemetry-cpp/pull/1523)
* [METRICS SDK] Support multiple async callbacks [#1495](https://github.com/open-telemetry/opentelemetry-cpp/pull/1495)
* [BUILD] Fix code scanning alert [#1530](https://github.com/open-telemetry/opentelemetry-cpp/pull/1530)
* [BUILD] Fix several compiling/linking errors [#1539](https://github.com/open-telemetry/opentelemetry-cpp/pull/1539)
* [TRACE SDK] Add SpanData getter for Span Recordable [#1508](https://github.com/open-telemetry/opentelemetry-cpp/pull/1508)
* [LOG SDK] Fix log sdk builder (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524)
* [METRICS SDK] Add configuration options for Aggregation creation [#1513](https://github.com/open-telemetry/opentelemetry-cpp/pull/1513)
* [METRICS TEST] Fix metrics unit test memory leack [#1533](https://github.com/open-telemetry/opentelemetry-cpp/pull/1533)
* [LOG SDK] Add log sdk builders (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524)

## [1.5.0] 2022-07-29
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,32 @@ The C++ [OpenTelemetry](https://opentelemetry.io/) client.

## Project Status

| Signal | Status | Project |
| ------- | ---------------------- | ------------------------------------------------------------------------ |
| Traces | Public Release | N/A |
| Metrics | Alpha [1] | N/A |
| Logs | Experimental [2] | N/A |

* [1]: The metric collection pipeline is available for testing purpose. Not
ready for production. The earlier implementation (based on old
specification) can be included in build by setting
| Signal | Status | Project |
| ------- | ----------------------- | ------------------------------------------------------------------------ |
| Traces | Public Release | N/A |
| Metrics | Release Candidate [1,2] | N/A |
| Logs | Experimental [3] | N/A |

* [1]: The metric implementation is in release candidate phase. There would be
few iterations of new feature additions, and bug fixes before it is
publically available. Few breaking changes in API and SDK are expected.
* [2]: The earlier implementation (based on old
specification) is now deprecated, and would be removed once new implementation
is declared stable. The older implementation can be included in build by setting
`ENABLE_METRICS_PREVIEW` preprocessor macro, and is included under
`*/_metrics/*` directory. This would be eventually removed once the
ongoing implemetation is stable.
* [2]: The current Log Signal Implementation is Experimental, and will change as
`*/_metrics/*` directory.
* [3]: The current Log Signal Implementation is Experimental, and will change as
the current OpenTelemetry Log specification matures. The current
implementation can be included in build by setting `ENABLE_LOGS_PREVIEW`
preprocessor macro.

## OpenTelemetry Specification Compatibility Matrix

| API Version | Core Version | Contrib Version |
| API Version | Core Version | Contrib Version [1] |
| ----------- |--------------|-------------------------|
| 1.0.0 | 1.0.0-rc4 | N/A [1] |
| 1.0.0 | 1.0.0-rc4 | N/A |
| 1.0.0 | 1.0.0 | N/A |
| 1.9.0 | 1.6.0 | N/A |

* [1]: We don't have releases for opentelemetry-cpp contrib repo. This may
change in future.
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "opentelemetry/detail/preprocessor.h"

#define OPENTELEMETRY_ABI_VERSION_NO 1
#define OPENTELEMETRY_VERSION "1.5.0"
#define OPENTELEMETRY_VERSION "1.6.0"
#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)

// clang-format off
Expand Down
6 changes: 3 additions & 3 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def opentelemetry_cpp_deps():
http_archive,
name = "com_github_opentelemetry_proto",
build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD",
sha256 = "134ce87f0a623daac19b9507b92da0d9b82929e3db796bba631e422f6ea8d3b3",
strip_prefix = "opentelemetry-proto-0.18.0",
sha256 = "464bc2b348e674a1a03142e403cbccb01be8655b6de0f8bfe733ea31fcd421be",
strip_prefix = "opentelemetry-proto-0.19.0",
urls = [
"https://github.com/open-telemetry/opentelemetry-proto/archive/v0.18.0.tar.gz",
"https://github.com/open-telemetry/opentelemetry-proto/archive/v0.19.0.tar.gz",
],
)

Expand Down
27 changes: 14 additions & 13 deletions buildscripts/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,20 @@ namespace sdk
{
namespace version
{
const int MAJOR_VERSION = ${major};
const int MINOR_VERSION = ${minor};
const int PATCH_VERSION = ${patch};
const char* PRE_RELEASE = "${pre_release}";
const char* BUILD_METADATA = "${build_metadata}";
const int COUNT_NEW_COMMITS = ${count_new_commits};
const char* BRANCH = "${branch}";
const char* COMMIT_HASH = "${latest_commit_hash}";
const char* SHORT_VERSION = "${short_version}";
const char* FULL_VERSION = "${full_version}";
const char* BUILD_DATE = "$(date -u)";
}
}
const int MAJOR_VERSION = ${major};
const int MINOR_VERSION = ${minor};
const int PATCH_VERSION = ${patch};
const char* PRE_RELEASE = "${pre_release}";
const char* BUILD_METADATA = "${build_metadata}";
const int COUNT_NEW_COMMITS = ${count_new_commits};
const char* BRANCH = "${branch}";
const char* COMMIT_HASH = "${latest_commit_hash}";
const char* SHORT_VERSION = "${short_version}";
const char* FULL_VERSION =
"${full_version}";
const char* BUILD_DATE = "$(date -u)";
} // namespace version
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
END
git add "$(pwd)/sdk/src/version/version.cc"
Expand Down
35 changes: 26 additions & 9 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ mkdir -p "${BUILD_DIR}"
mkdir -p "${PLUGIN_DIR}"

BAZEL_OPTIONS="--copt=-DENABLE_LOGS_PREVIEW --copt=-DENABLE_TEST"
# Previous legacy metrics use virtual drive, which can not be used without RTTI
if [[ "$1" != "bazel.nortti" ]]; then
BAZEL_OPTIONS="$BAZEL_OPTIONS --copt=-DENABLE_METRICS_PREVIEW"
fi

BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors"

BAZEL_OPTIONS_ASYNC="$BAZEL_OPTIONS --copt=-DENABLE_ASYNC_EXPORT"
Expand Down Expand Up @@ -100,19 +97,35 @@ elif [[ "$1" == "cmake.with_async_export.test" ]]; then
-DWITH_ZIPKIN=ON \
-DWITH_JAEGER=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_METRICS_PREVIEW=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.abseil.test" ]]; then
elif [[ "$1" == "cmake.deprecated_metrics.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_PROMETHEUS=ON \
-DWITH_ZIPKIN=OFF \
-DWITH_JAEGER=OFF \
-DWITH_ELASTICSEARCH=OFF \
-DWITH_METRICS_PREVIEW=ON \
-DWITH_LOGS_PREVIEW=OFF \
-DCMAKE_CXX_FLAGS="-Werror" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.abseil.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
Expand All @@ -136,7 +149,7 @@ elif [[ "$1" == "cmake.c++20.stl.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_METRICS_PREVIEW=ON \
-DWITH_METRICS_PREVIEW=OFF \
-DWITH_LOGS_PREVIEW=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
Expand Down Expand Up @@ -242,6 +255,10 @@ elif [[ "$1" == "bazel.test" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS //...
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "bazel.deprecated_metrics.test" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS --copt=-DENABLE_METRICS_PREVIEW //...
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS --copt=-DENABLE_METRICS_PREVIEW //...
exit 0
elif [[ "$1" == "bazel.with_async_export.test" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //...
bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS_ASYNC //...
Expand All @@ -262,8 +279,8 @@ elif [[ "$1" == "bazel.legacy.test" ]]; then
elif [[ "$1" == "bazel.noexcept" ]]; then
# there are some exceptions and error handling code from the Prometheus and Jaeger Clients
# that make this test always fail. ignore Prometheus and Jaeger exporters in the noexcept here.
bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//exporters/jaeger/... -//examples/prometheus/...
bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//exporters/jaeger/... -//examples/prometheus/...
bazel $BAZEL_STARTUP_OPTIONS build --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//exporters/jaeger/... -//examples/prometheus/... -//sdk/test/metrics:attributes_hashmap_test
bazel $BAZEL_STARTUP_OPTIONS test --copt=-fno-exceptions --build_tag_filters=-jaeger $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//exporters/jaeger/... -//examples/prometheus/... -//sdk/test/metrics:attributes_hashmap_test
exit 0
elif [[ "$1" == "bazel.nortti" ]]; then
# there are some exceptions and error handling code from the Prometheus and Jaeger Clients
Expand Down
2 changes: 1 addition & 1 deletion cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)
set(needs_proto_download FALSE)
else()
if("${opentelemetry-proto}" STREQUAL "")
set(opentelemetry-proto "v0.17.0")
set(opentelemetry-proto "v0.19.0")
endif()
include(ExternalProject)
ExternalProject_Add(
Expand Down
2 changes: 1 addition & 1 deletion docs/public/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'OpenTelemetry authors'

# The full version, including alpha/beta/rc tags
release = "1.5.0"
release = "1.6.0"

# Run sphinx on subprojects and copy output
# -----------------------------------------
Expand Down
33 changes: 31 additions & 2 deletions exporters/elasticsearch/src/es_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,52 @@ class ResponseHandler : public http_client::EventHandler
*/
ResponseHandler(bool console_debug = false) : console_debug_{console_debug} {}

std::string BuildResponseLogMessage(http_client::Response &response,
const std::string &body) noexcept
{
std::stringstream ss;
ss << "Status:" << response.GetStatusCode() << "Header:";
response.ForEachHeader([&ss](opentelemetry::nostd::string_view header_name,
opentelemetry::nostd::string_view header_value) {
ss << "\t" << header_name.data() << " : " << header_value.data() << ",";
return true;
});
ss << "Body:" << body;

return ss.str();
}

/**
* Automatically called when the response is received, store the body into a string and notify any
* threads blocked on this result
*/
void OnResponse(http_client::Response &response) noexcept override
{
std::string log_message;

// Lock the private members so they can't be read while being modified
{
std::unique_lock<std::mutex> lk(mutex_);

// Store the body of the request
body_ = std::string(response.GetBody().begin(), response.GetBody().end());

if (response.GetStatusCode() != 200 && response.GetStatusCode() != 202)
{
log_message = BuildResponseLogMessage(response, body_);

OTEL_INTERNAL_LOG_ERROR("ES Log Exporter] Export failed, " << log_message);
}

if (console_debug_)
{
OTEL_INTERNAL_LOG_DEBUG(
"[ES Log Exporter] Got response from Elasticsearch, response body: " << body_);
if (log_message.empty())
{
log_message = BuildResponseLogMessage(response, body_);
}

OTEL_INTERNAL_LOG_DEBUG("[ES Log Exporter] Got response from Elasticsearch, "
<< log_message);
}

// Set the response_received_ flag to true and notify any threads waiting on this result
Expand Down
20 changes: 20 additions & 0 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "opentelemetry/nostd/variant.h"
#include "opentelemetry/trace/span_id.h"

#include "opentelemetry//sdk/trace/sampler.h"
#include "opentelemetry/exporters/etw/etw_provider.h"
#include "opentelemetry/sdk/trace/id_generator.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
Expand Down Expand Up @@ -146,6 +148,24 @@ TelemetryProviderConfiguration &GetConfiguration(T &t)
return t.config_;
}

/**
* @brief Utility function to obtain etw::TracerProvider.id_generator_
*/
template <class T>
sdk::trace::IdGenerator &GetIdGenerator(T &t)
{
return *t.id_generator_;
}

/**
* @brief Utility function to obtain etw::TracerProvider.sampler_
*/
template <class T>
sdk::trace::Sampler &GetSampler(T &t)
{
return *t.sampler_;
}

/**
* @brief Utility template to convert SpanId or TraceId to hex.
* @param id - value of SpanId or TraceId
Expand Down
Loading

0 comments on commit 360ee03

Please sign in to comment.