Skip to content

Commit

Permalink
Merge branch 'main' into attributes-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Nov 19, 2023
2 parents 600c4fd + cb603ad commit 62f8a5c
Show file tree
Hide file tree
Showing 30 changed files with 953 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/project_management_issue_open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
permissions:
issues: write
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
Expand Down
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ Increment the:
[#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385)
* [API] Add a new AddLink() operation to Span
[#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380)
* [SDK] Fix GetLogger with empty library
name[#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398)
* [SDK] Fix GetLogger with empty library name
[#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398)
* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options
[#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388)

Important changes:

Expand Down Expand Up @@ -56,6 +58,14 @@ Important changes:
* These build options are scheduled to be removed by the next release,
building without SSL/TLS will no longer be possible.

* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options
[#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388)
* `OtlpGrpcMetricExporterOptions` used to honor `_TRACES_`
environment variables, instead of `_METRICS_` environment variables.
* The implementation of `OtlpGrpcMetricExporterOptions` is now fixed.
* Please check configuration variables,
to make sure `_METRICS_` variables are set as expected.

Breaking changes:

* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead
Expand All @@ -77,6 +87,20 @@ Breaking changes:
instead of nostd::string_view for name, version and schema to
maintain a single export definition for DLL.

* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options
[#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388)
* `OtlpGrpcLogRecordExporter` incorrectly used `OtlpGrpcExporterOptions`,
which are options for traces and not logs.
* This created a bug: the `OtlpGrpcLogRecordExporter` honors `_TRACES_`
environment variables, instead of `_LOGS_` environment variables.
* `OtlpGrpcLogRecordExporter` is changed to use
`OtlpGrpcLogRecordExporterOptions` instead, fixing the bug.
* User code that initializes the SDK with a GRPC Log exporter,
and uses exporter options, should adjust to replace
`OtlpGrpcExporterOptions` with `OtlpGrpcLogRecordExporterOptions`.
* Please check configuration variables,
to make sure `_LOGS_` variables are set as expected.

## [1.12.0] 2023-10-16

* [BUILD] Support `pkg-config`
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ set(OTELCPP_PROTO_PATH

if(WIN32)
option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON)
else()
if(DEFINED (WITH_ETW))
message(FATAL_ERROR "WITH_ETW is only supported on Windows")
endif()
endif(WIN32)

# Do not convert deprecated message to error
Expand Down Expand Up @@ -628,6 +632,9 @@ endif()
include(CMakePackageConfigHelpers)

if(DEFINED OPENTELEMETRY_BUILD_DLL)
if(NOT WIN32)
message(FATAL_ERROR "Build DLL is only supported on Windows!")
endif()
if(NOT MSVC)
message(WARNING "Build DLL is supposed to work with MSVC!")
endif()
Expand Down
14 changes: 10 additions & 4 deletions examples/otlp/grpc_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h"
#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h"
#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h"
#include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h"
#include "opentelemetry/logs/provider.h"
#include "opentelemetry/sdk/logs/exporter.h"
#include "opentelemetry/sdk/logs/logger_provider_factory.h"
Expand Down Expand Up @@ -37,6 +39,7 @@ namespace trace_sdk = opentelemetry::sdk::trace;
namespace
{
opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts;
opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts;
void InitTracer()
{
// Create OTLP exporter instance
Expand Down Expand Up @@ -65,7 +68,7 @@ void CleanupTracer()
void InitLogger()
{
// Create OTLP exporter instance
auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(opts);
auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(log_opts);
auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter));
nostd::shared_ptr<logs::LoggerProvider> provider(
logs_sdk::LoggerProviderFactory::Create(std::move(processor)));
Expand All @@ -92,11 +95,14 @@ int main(int argc, char *argv[])
{
if (argc > 1)
{
opts.endpoint = argv[1];
opts.endpoint = argv[1];
log_opts.endpoint = argv[1];
if (argc > 2)
{
opts.use_ssl_credentials = true;
opts.ssl_credentials_cacert_path = argv[2];
opts.use_ssl_credentials = true;
log_opts.use_ssl_credentials = true;
opts.ssl_credentials_cacert_path = argv[2];
log_opts.ssl_credentials_cacert_path = argv[2];
}
}
InitLogger();
Expand Down
30 changes: 27 additions & 3 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cc_library(
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_utils.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
Expand All @@ -73,9 +73,11 @@ cc_library(
srcs = [
"src/otlp_grpc_exporter.cc",
"src/otlp_grpc_exporter_factory.cc",
"src/otlp_grpc_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
Expand Down Expand Up @@ -143,6 +145,7 @@ cc_library(
srcs = [
"src/otlp_http_exporter.cc",
"src/otlp_http_exporter_factory.cc",
"src/otlp_http_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
Expand Down Expand Up @@ -170,10 +173,11 @@ cc_library(
srcs = [
"src/otlp_grpc_metric_exporter.cc",
"src/otlp_grpc_metric_exporter_factory.cc",
"src/otlp_grpc_metric_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h",
Expand Down Expand Up @@ -201,6 +205,7 @@ cc_library(
srcs = [
"src/otlp_http_metric_exporter.cc",
"src/otlp_http_metric_exporter_factory.cc",
"src/otlp_http_metric_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
Expand Down Expand Up @@ -228,6 +233,7 @@ cc_library(
srcs = [
"src/otlp_http_log_record_exporter.cc",
"src/otlp_http_log_record_exporter_factory.cc",
"src/otlp_http_log_record_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
Expand Down Expand Up @@ -255,12 +261,14 @@ cc_library(
srcs = [
"src/otlp_grpc_log_record_exporter.cc",
"src/otlp_grpc_log_record_exporter_factory.cc",
"src/otlp_grpc_log_record_exporter_options.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h",
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
Expand Down Expand Up @@ -436,6 +444,22 @@ cc_test(
],
)

cc_test(
name = "otlp_grpc_metric_exporter_test",
srcs = ["test/otlp_grpc_metric_exporter_test.cc"],
tags = [
"otlp",
"otlp_grpc_metric",
"test",
],
deps = [
":otlp_grpc_metric_exporter",
"//api",
"//sdk/src/metrics",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "otlp_grpc_metric_exporter_factory_test",
srcs = ["test/otlp_grpc_metric_exporter_factory_test.cc"],
Expand Down
35 changes: 27 additions & 8 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ if(WITH_OTLP_GRPC)
list(APPEND OPENTELEMETRY_OTLP_TARGETS
opentelemetry_exporter_otlp_grpc_client)

add_library(opentelemetry_exporter_otlp_grpc
src/otlp_grpc_exporter.cc src/otlp_grpc_exporter_factory.cc)
add_library(
opentelemetry_exporter_otlp_grpc
src/otlp_grpc_exporter.cc src/otlp_grpc_exporter_factory.cc
src/otlp_grpc_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_grpc
PROPERTIES EXPORT_NAME otlp_grpc_exporter)
Expand All @@ -73,7 +75,8 @@ if(WITH_OTLP_GRPC)
add_library(
opentelemetry_exporter_otlp_grpc_log
src/otlp_grpc_log_record_exporter.cc
src/otlp_grpc_log_record_exporter_factory.cc)
src/otlp_grpc_log_record_exporter_factory.cc
src/otlp_grpc_log_record_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_grpc_log
PROPERTIES EXPORT_NAME otlp_grpc_log_record_exporter)
Expand All @@ -88,7 +91,8 @@ if(WITH_OTLP_GRPC)

add_library(
opentelemetry_exporter_otlp_grpc_metrics
src/otlp_grpc_metric_exporter.cc src/otlp_grpc_metric_exporter_factory.cc)
src/otlp_grpc_metric_exporter.cc src/otlp_grpc_metric_exporter_factory.cc
src/otlp_grpc_metric_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_grpc_metrics
PROPERTIES EXPORT_NAME otlp_grpc_metrics_exporter)
Expand Down Expand Up @@ -130,8 +134,10 @@ if(WITH_OTLP_HTTP)
list(APPEND OPENTELEMETRY_OTLP_TARGETS
opentelemetry_exporter_otlp_http_client)

add_library(opentelemetry_exporter_otlp_http
src/otlp_http_exporter.cc src/otlp_http_exporter_factory.cc)
add_library(
opentelemetry_exporter_otlp_http
src/otlp_http_exporter.cc src/otlp_http_exporter_factory.cc
src/otlp_http_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_http
PROPERTIES EXPORT_NAME otlp_http_exporter)
Expand All @@ -147,7 +153,8 @@ if(WITH_OTLP_HTTP)
add_library(
opentelemetry_exporter_otlp_http_log
src/otlp_http_log_record_exporter.cc
src/otlp_http_log_record_exporter_factory.cc)
src/otlp_http_log_record_exporter_factory.cc
src/otlp_http_log_record_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_http_log
PROPERTIES EXPORT_NAME otlp_http_log_record_exporter)
Expand All @@ -162,7 +169,8 @@ if(WITH_OTLP_HTTP)

add_library(
opentelemetry_exporter_otlp_http_metric
src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc)
src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc
src/otlp_http_metric_exporter_options.cc)

set_target_properties(opentelemetry_exporter_otlp_http_metric
PROPERTIES EXPORT_NAME otlp_http_metric_exporter)
Expand Down Expand Up @@ -295,6 +303,17 @@ if(BUILD_TESTING)
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_log_record_exporter_factory_test)

add_executable(otlp_grpc_metric_exporter_test
test/otlp_grpc_metric_exporter_test.cc)
target_link_libraries(
otlp_grpc_metric_exporter_test ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${GMOCK_LIB} opentelemetry_exporter_otlp_grpc
opentelemetry_exporter_otlp_grpc_metrics)
gtest_add_tests(
TARGET otlp_grpc_metric_exporter_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_metric_exporter_test)

add_executable(otlp_grpc_metric_exporter_factory_test
test/otlp_grpc_metric_exporter_factory_test.cc)
target_link_libraries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <memory>

#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h"
#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h"

#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h"

Expand All @@ -23,6 +23,8 @@ namespace exporter
namespace otlp
{

struct OtlpGrpcClientOptions;

/**
* The OTLP gRPC client contains utility functions of gRPC.
*/
Expand All @@ -32,13 +34,13 @@ class OtlpGrpcClient
/**
* Create gRPC channel from the exporter options.
*/
static std::shared_ptr<grpc::Channel> MakeChannel(const OtlpGrpcExporterOptions &options);
static std::shared_ptr<grpc::Channel> MakeChannel(const OtlpGrpcClientOptions &options);

/**
* Create gRPC client context to call RPC.
*/
static std::unique_ptr<grpc::ClientContext> MakeClientContext(
const OtlpGrpcExporterOptions &options);
const OtlpGrpcClientOptions &options);

/**
* Create gRPC CompletionQueue to async call RPC.
Expand All @@ -49,19 +51,19 @@ class OtlpGrpcClient
* Create trace service stub to communicate with the OpenTelemetry Collector.
*/
static std::unique_ptr<proto::collector::trace::v1::TraceService::StubInterface>
MakeTraceServiceStub(const OtlpGrpcExporterOptions &options);
MakeTraceServiceStub(const OtlpGrpcClientOptions &options);

/**
* Create metrics service stub to communicate with the OpenTelemetry Collector.
*/
static std::unique_ptr<proto::collector::metrics::v1::MetricsService::StubInterface>
MakeMetricsServiceStub(const OtlpGrpcExporterOptions &options);
MakeMetricsServiceStub(const OtlpGrpcClientOptions &options);

/**
* Create logs service stub to communicate with the OpenTelemetry Collector.
*/
static std::unique_ptr<proto::collector::logs::v1::LogsService::StubInterface>
MakeLogsServiceStub(const OtlpGrpcExporterOptions &options);
MakeLogsServiceStub(const OtlpGrpcClientOptions &options);

static grpc::Status DelegateExport(
proto::collector::trace::v1::TraceService::StubInterface *stub,
Expand Down
Loading

0 comments on commit 62f8a5c

Please sign in to comment.