Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into async changes #1321

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
6 changes: 1 addition & 5 deletions .github/.codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ coverage:
informational: true
target: auto
threshold: 10%
patch:
default:
informational: true
target: auto
threshold: 10%
patch: false

parsers:
gcov:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main, async-changes ]

jobs:
cmake_test:
Expand Down Expand Up @@ -375,7 +375,7 @@ jobs:
- name: run tests and generate report
run: ./ci/do_ci.sh code.coverage
- name: upload report
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
with:
file: /home/runner/build/coverage.info

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
close-issue-message: 'Closed as inactive. Feel free to reopen if this is still an issue.'
days-before-issue-stale: 60
days-before-issue-close: 7
exempt-pr-labels: 'do-not-stale'
exempt-issue-labels: 'do-not-stale'
9 changes: 5 additions & 4 deletions examples/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ else()
add_executable(http_server server.cc)

target_link_libraries(
http_client ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace http_client_curl
opentelemetry_exporter_ostream_span ${CURL_LIBRARIES})
http_client ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace
opentelemetry_http_client_curl opentelemetry_exporter_ostream_span
${CURL_LIBRARIES})

target_link_libraries(
http_server ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace http_client_curl
opentelemetry_exporter_ostream_span)
http_server ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace
opentelemetry_http_client_curl opentelemetry_exporter_ostream_span)
endif()
2 changes: 1 addition & 1 deletion exporters/elasticsearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target_include_directories(

target_link_libraries(
opentelemetry_exporter_elasticsearch_logs
PUBLIC opentelemetry_trace opentelemetry_logs http_client_curl)
PUBLIC opentelemetry_trace opentelemetry_logs opentelemetry_http_client_curl)

install(
TARGETS opentelemetry_exporter_elasticsearch_logs
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ target_include_directories(

target_link_libraries(
opentelemetry_exporter_jaeger_trace
PUBLIC opentelemetry_resources http_client_curl
PUBLIC opentelemetry_resources opentelemetry_http_client_curl
PRIVATE thrift::thrift)

if(MSVC)
Expand Down
59 changes: 30 additions & 29 deletions exporters/ostream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,37 @@ cc_library(
],
)

cc_library(
name = "ostream_metric_exporter",
srcs = [
"src/metric_exporter.cc",
],
hdrs = [
"include/opentelemetry/exporters/ostream/metric_exporter.h",
],
strip_include_prefix = "include",
tags = [
"metrics",
"ostream",
],
deps = [
"//sdk/src/metrics",
],
)
# TODO - Uncomment once MetricData interface is finalised
#cc_library(
# name = "ostream_metric_exporter",
# srcs = [
# "src/metric_exporter.cc",
# ],
# hdrs = [
# "include/opentelemetry/exporters/ostream/metric_exporter.h",
# ],
# strip_include_prefix = "include",
# tags = [
# "metrics",
# "ostream",
# ],
# deps = [
# "//sdk/src/metrics",
# ],
#)

cc_test(
name = "ostream_metric_test",
srcs = ["test/ostream_metric_test.cc"],
tags = [
"ostream",
"test",
],
deps = [
":ostream_metric_exporter",
"@com_google_googletest//:gtest_main",
],
)
#cc_test(
# name = "ostream_metric_test",
# srcs = ["test/ostream_metric_test.cc"],
# tags = [
# "ostream",
# "test",
# ],
# deps = [
# ":ostream_metric_exporter",
# "@com_google_googletest//:gtest_main",
# ],
#)

cc_test(
name = "ostream_metrics_test_deprecated",
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(WITH_OTLP_HTTP)
PROPERTIES EXPORT_NAME otlp_http_client)
target_link_libraries(
opentelemetry_exporter_otlp_http_client
PUBLIC opentelemetry_sdk opentelemetry_proto http_client_curl
PUBLIC opentelemetry_sdk opentelemetry_proto opentelemetry_http_client_curl
nlohmann_json::nlohmann_json)
if(nlohmann_json_clone)
add_dependencies(opentelemetry_exporter_otlp_http_client
Expand Down
3 changes: 2 additions & 1 deletion exporters/zipkin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ add_library(opentelemetry_exporter_zipkin_trace src/zipkin_exporter.cc

target_link_libraries(
opentelemetry_exporter_zipkin_trace
PUBLIC opentelemetry_trace http_client_curl nlohmann_json::nlohmann_json)
PUBLIC opentelemetry_trace opentelemetry_http_client_curl
nlohmann_json::nlohmann_json)

install(
TARGETS opentelemetry_exporter_zipkin_trace
Expand Down
19 changes: 10 additions & 9 deletions ext/src/http/client/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
find_package(CURL)
if(CURL_FOUND)
add_library(http_client_curl http_client_factory_curl.cc http_client_curl.cc)
add_library(opentelemetry_http_client_curl http_client_factory_curl.cc
http_client_curl.cc)

set_target_properties(http_client_curl PROPERTIES EXPORT_NAME
http_client_curl)
set_target_properties(opentelemetry_http_client_curl
PROPERTIES EXPORT_NAME http_client_curl)

if(TARGET CURL::libcurl)
target_link_libraries(http_client_curl PUBLIC opentelemetry_ext
CURL::libcurl)
target_link_libraries(opentelemetry_http_client_curl
PUBLIC opentelemetry_ext CURL::libcurl)
else()
target_include_directories(http_client_curl
target_include_directories(opentelemetry_http_client_curl
INTERFACE "${CURL_INCLUDE_DIRS}")
target_link_libraries(http_client_curl PUBLIC opentelemetry_ext
${CURL_LIBRARIES})
target_link_libraries(opentelemetry_http_client_curl
PUBLIC opentelemetry_ext ${CURL_LIBRARIES})
endif()

install(
TARGETS http_client_curl
TARGETS opentelemetry_http_client_curl
EXPORT "${PROJECT_NAME}-target"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
6 changes: 4 additions & 2 deletions ext/test/http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ if(CURL_FOUND)
${CMAKE_THREAD_LIBS_INIT})

if(TARGET CURL::libcurl)
target_link_libraries(${FILENAME} CURL::libcurl http_client_curl)
target_link_libraries(${FILENAME} opentelemetry_http_client_curl
CURL::libcurl)
else()
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(${FILENAME} ${CURL_LIBRARIES} http_client_curl)
target_link_libraries(${FILENAME} ${CURL_LIBRARIES}
opentelemetry_http_client_curl)
endif()
gtest_add_tests(
TARGET ${FILENAME}
Expand Down
6 changes: 3 additions & 3 deletions ext/test/w3c_tracecontext_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ else()
add_executable(w3c_tracecontext_test main.cc)
target_link_libraries(
w3c_tracecontext_test
PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace http_client_curl
opentelemetry_exporter_ostream_span ${CURL_LIBRARIES}
nlohmann_json::nlohmann_json)
PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace
opentelemetry_http_client_curl opentelemetry_exporter_ostream_span
${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
if(nlohmann_json_clone)
add_dependencies(w3c_tracecontext_test nlohmann_json::nlohmann_json)
endif()
Expand Down
40 changes: 29 additions & 11 deletions sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,42 @@ namespace sdk
{
namespace metrics
{
class InstrumentMonotonicityAwareAggregation
{
public:
InstrumentMonotonicityAwareAggregation(bool is_monotonic) : is_monotonic_(is_monotonic) {}
bool IsMonotonic() { return is_monotonic_; }

private:
bool is_monotonic_;
};

class Aggregation
{
public:
virtual void Aggregate(long value, const PointAttributes &attributes = {}) noexcept = 0;

virtual void Aggregate(double value, const PointAttributes &attributes = {}) noexcept = 0;

virtual PointType Collect() noexcept = 0;
/**
* Returns the result of the merge of the two aggregations.
*
* This should always assume that the aggregations do not overlap and merge together for a new
* cumulative report.
*
* @param delta the newly captured (delta) aggregation
* @return the result of the merge of the given aggregation.
*/

virtual std::unique_ptr<Aggregation> Merge(const Aggregation &delta) const noexcept = 0;

/**
* Returns a new delta aggregation by comparing two cumulative measurements.
*
* @param next the newly captured (cumulative) aggregation.
* @return The resulting delta aggregation.
*/
virtual std::unique_ptr<Aggregation> Diff(const Aggregation &next) const noexcept = 0;

/**
* Returns the point data that the aggregation will produce.
*
* @return PointType
*/

virtual PointType ToPoint() const noexcept = 0;

virtual ~Aggregation() = default;
};

} // namespace metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class DefaultAggregation
case InstrumentType::kUpDownCounter:
case InstrumentType::kObservableUpDownCounter:
return (instrument_descriptor.value_type_ == InstrumentValueType::kLong)
? std::move(std::unique_ptr<Aggregation>(new LongSumAggregation(true)))
: std::move(std::unique_ptr<Aggregation>(new DoubleSumAggregation(true)));
? std::move(std::unique_ptr<Aggregation>(new LongSumAggregation()))
: std::move(std::unique_ptr<Aggregation>(new DoubleSumAggregation()));
break;
case InstrumentType::kHistogram:
return (instrument_descriptor.value_type_ == InstrumentValueType::kLong)
Expand Down Expand Up @@ -79,11 +79,11 @@ class DefaultAggregation
case AggregationType::kSum:
if (instrument_descriptor.value_type_ == InstrumentValueType::kLong)
{
return std::unique_ptr<Aggregation>(new LongSumAggregation(true));
return std::unique_ptr<Aggregation>(new LongSumAggregation());
}
else
{
return std::unique_ptr<Aggregation>(new DoubleSumAggregation(true));
return std::unique_ptr<Aggregation>(new DoubleSumAggregation());
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ namespace sdk
namespace metrics
{

/**
* A null Aggregation which denotes no aggregation should occur.
*/

class DropAggregation : public Aggregation
{
public:
Expand All @@ -23,7 +27,21 @@ class DropAggregation : public Aggregation

void Aggregate(double value, const PointAttributes &attributes = {}) noexcept override {}

PointType Collect() noexcept override { return DropPointData(); }
std::unique_ptr<Aggregation> Merge(const Aggregation &delta) const noexcept override
{
return std::unique_ptr<Aggregation>(new DropAggregation());
}

std::unique_ptr<Aggregation> Diff(const Aggregation &next) const noexcept override
{
return std::unique_ptr<Aggregation>(new DropAggregation());
}

PointType ToPoint() const noexcept override
{
static DropPointData point_data;
return point_data;
}
};
} // namespace metrics
} // namespace sdk
Expand Down
Loading