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

Implementation of OtlpHttpLogExporter #1030

Merged
merged 19 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Increment the:

## [Unreleased]

* [EXPORTER] Add OTLP/HTTP Log Exporter ([#1030](https://github.com/open-telemetry/opentelemetry-cpp/pull/1030))

## [1.0.1] 2021-10-21

* [EXPORTER] Exports span attributes to ETW ([#1021](https://github.com/open-telemetry/opentelemetry-cpp/pull/1021))
Expand Down
12 changes: 9 additions & 3 deletions api/test/common/spinlock_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static void BM_NaiveSpinLockThrashing(benchmark::State &s)
[](SpinLockMutex &m) {
while (!m.try_lock())
{
// Left this comment to keep the same format on old and new versions of clang-format
}
},
[](SpinLockMutex &m) { m.unlock(); });
Expand Down Expand Up @@ -106,16 +107,21 @@ static void BM_ThreadYieldSpinLockThrashing(benchmark::State &s)
SpinThrash<std::atomic<bool>>(
s, mutex,
[](std::atomic<bool> &l) {
if (!l.exchange(true, std::memory_order_acquire))
if (!l.exchange(true, std::memory_order_acq_rel))
{
return;
}
for (std::size_t i = 0; i < 100; ++i)
for (std::size_t i = 0; i < 128; ++i)
{
if (!l.load(std::memory_order_acquire) && !l.exchange(true, std::memory_order_acquire))
if (!l.load(std::memory_order_acquire) && !l.exchange(true, std::memory_order_acq_rel))
{
return;
}

if (i % 32 == 0)
{
std::this_thread::yield();
}
}
std::this_thread::yield();
},
Expand Down
55 changes: 47 additions & 8 deletions bazel/opentelemetry_proto.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
proto_library(
name = "common_proto",
srcs = [
"opentelemetry/proto/common/v1/common.proto",
"opentelemetry/proto/common/v1/common.proto",
],
)

Expand All @@ -32,10 +32,10 @@ cc_proto_library(
proto_library(
name = "resource_proto",
srcs = [
"opentelemetry/proto/resource/v1/resource.proto",
"opentelemetry/proto/resource/v1/resource.proto",
],
deps = [
":common_proto",
":common_proto",
],
)

Expand All @@ -47,11 +47,11 @@ cc_proto_library(
proto_library(
name = "trace_proto",
srcs = [
"opentelemetry/proto/trace/v1/trace.proto",
"opentelemetry/proto/trace/v1/trace.proto",
],
deps = [
":common_proto",
":resource_proto",
":common_proto",
":resource_proto",
],
)

Expand All @@ -63,10 +63,10 @@ cc_proto_library(
proto_library(
name = "trace_service_proto",
srcs = [
"opentelemetry/proto/collector/trace/v1/trace_service.proto",
"opentelemetry/proto/collector/trace/v1/trace_service.proto",
],
deps = [
":trace_proto",
":trace_proto",
],
)

Expand All @@ -78,7 +78,46 @@ cc_proto_library(
cc_grpc_library(
name = "trace_service_grpc_cc",
srcs = [":trace_service_proto"],
generate_mocks = True,
grpc_only = True,
deps = [":trace_service_proto_cc"],
)

proto_library(
name = "logs_proto",
srcs = [
"opentelemetry/proto/logs/v1/logs.proto",
],
deps = [
":common_proto",
":resource_proto",
],
)

cc_proto_library(
name = "logs_proto_cc",
deps = [":logs_proto"],
)

proto_library(
name = "logs_service_proto",
srcs = [
"opentelemetry/proto/collector/logs/v1/logs_service.proto",
],
deps = [
":logs_proto",
],
)

cc_proto_library(
name = "logs_service_proto_cc",
deps = [":logs_service_proto"],
)

cc_grpc_library(
name = "logs_service_grpc_cc",
srcs = [":logs_service_proto"],
generate_mocks = True,
grpc_only = True,
deps = [":logs_service_proto_cc"],
)
6 changes: 3 additions & 3 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def opentelemetry_cpp_deps():
http_archive,
name = "com_github_opentelemetry_proto",
build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD",
sha256 = "9ec38ab51eedbd7601979b0eda962cf37bc8a4dc35fcef604801e463f01dcc00",
strip_prefix = "opentelemetry-proto-0.9.0",
sha256 = "985367f8905e91018e636cbf0d83ab3f834b665c4f5899a27d10cae9657710e2",
strip_prefix = "opentelemetry-proto-0.11.0",
urls = [
"https://github.com/open-telemetry/opentelemetry-proto/archive/v0.9.0.tar.gz",
"https://github.com/open-telemetry/opentelemetry-proto/archive/v0.11.0.tar.gz",
],
)

Expand Down
6 changes: 6 additions & 0 deletions cmake/opentelemetry-cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
# opentelemetry-cpp::metrics - Imported target of opentelemetry-cpp::metrics
# opentelemetry-cpp::logs - Imported target of opentelemetry-cpp::logs
# opentelemetry-cpp::in_memory_span_exporter - Imported target of opentelemetry-cpp::in_memory_span_exporter
# opentelemetry-cpp::otlp_recordable - Imported target of opentelemetry-cpp::otlp_recordable
# opentelemetry-cpp::otlp_grpc_exporter - Imported target of opentelemetry-cpp::otlp_grpc_exporter
# opentelemetry-cpp::otlp_http_client - Imported target of opentelemetry-cpp::otlp_http_client
# opentelemetry-cpp::otlp_http_exporter - Imported target of opentelemetry-cpp::otlp_http_exporter
# opentelemetry-cpp::otlp_http_log_exporter - Imported target of opentelemetry-cpp::otlp_http_log_exporter
# opentelemetry-cpp::ostream_log_exporter - Imported target of opentelemetry-cpp::ostream_log_exporter
# opentelemetry-cpp::ostream_metrics_exporter - Imported target of opentelemetry-cpp::ostream_metrics_exporter
# opentelemetry-cpp::ostream_span_exporter - Imported target of opentelemetry-cpp::ostream_span_exporter
Expand Down Expand Up @@ -78,8 +81,11 @@ set(_OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS
metrics
logs
in_memory_span_exporter
otlp_recordable
otlp_grpc_exporter
otlp_http_client
otlp_http_exporter
otlp_http_log_exporter
ostream_log_exporter
ostream_metrics_exporter
ostream_span_exporter
Expand Down
68 changes: 62 additions & 6 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ load("//bazel:otel_cc_benchmark.bzl", "otel_cc_benchmark")
cc_library(
name = "otlp_recordable",
srcs = [
"src/otlp_log_recordable.cc",
"src/otlp_recordable.cc",
"src/otlp_recordable_utils.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_log_recordable.h",
"include/opentelemetry/exporters/otlp/otlp_recordable.h",
"include/opentelemetry/exporters/otlp/otlp_recordable_utils.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
strip_include_prefix = "include",
deps = [
"//sdk/src/logs",
"//sdk/src/resource",
"//sdk/src/trace",
"@com_github_opentelemetry_proto//:trace_proto_cc",
"@com_github_opentelemetry_proto//:logs_service_proto_cc",
"@com_github_opentelemetry_proto//:trace_service_proto_cc",
],
)

Expand Down Expand Up @@ -58,13 +64,13 @@ cc_library(
)

cc_library(
name = "otlp_http_exporter",
name = "otlp_http_client",
srcs = [
"src/otlp_http_exporter.cc",
"src/otlp_http_client.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_http_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_http_client.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
Expand All @@ -80,11 +86,51 @@ cc_library(
}),
strip_include_prefix = "include",
deps = [
":otlp_recordable",
"//api",
"//ext/src/http/client/curl:http_client_curl",
"//sdk:headers",
"@com_github_opentelemetry_proto//:common_proto_cc",
"@github_nlohmann_json//:json",
],
)

cc_library(
name = "otlp_http_exporter",
srcs = [
"src/otlp_http_exporter.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_http_exporter.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
strip_include_prefix = "include",
deps = [
":otlp_http_client",
":otlp_recordable",
"//sdk/src/trace",
"@com_github_opentelemetry_proto//:trace_service_proto_cc",
],
)

cc_library(
name = "otlp_http_log_exporter",
srcs = [
"src/otlp_http_log_exporter.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
strip_include_prefix = "include",
deps = [
":otlp_http_client",
":otlp_recordable",
"//sdk/src/trace",
"@com_github_opentelemetry_proto//:trace_service_proto_cc",
"@github_nlohmann_json//:json",
],
)

Expand Down Expand Up @@ -117,6 +163,16 @@ cc_test(
],
)

cc_test(
name = "otlp_http_log_exporter_test",
srcs = ["test/otlp_http_log_exporter_test.cc"],
deps = [
":otlp_http_log_exporter",
"//api",
"@com_google_googletest//:gtest_main",
],
)

otel_cc_benchmark(
name = "otlp_grpc_exporter_benchmark",
srcs = ["test/otlp_grpc_exporter_benchmark.cc"],
Expand Down
Loading