Skip to content

Commit

Permalink
Fix log sdk builder (open-telemetry#1486) (open-telemetry#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored and yxue committed Dec 5, 2022
1 parent bc2804b commit 02ed844
Show file tree
Hide file tree
Showing 26 changed files with 724 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ update the semantic convention in instrumentation library is needed.
[#873](https://github.com/open-telemetry/opentelemetry-cpp/pull/873)
>>>>>>> d9ad0afb (Add automatically semantic conventions from the spec (#873) (#1497))
## [1.5.0] 2022-07-29
## [1.5.0] 2022-07-29

```
## [1.5.0] 2022-07-29
```

* [EXPORTER BUILD] Add resources to dep list of prometheus exporter test
[#1527](https://github.com/open-telemetry/opentelemetry-cpp/pull/1527)
Expand Down
12 changes: 12 additions & 0 deletions examples/otlp/grpc_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@

#ifdef ENABLE_LOGS_PREVIEW
# include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h"
<<<<<<< HEAD
# include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h"
# include "opentelemetry/logs/provider.h"
# include "opentelemetry/sdk/logs/logger_provider_factory.h"
# include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h"
=======
# include "opentelemetry/exporters/otlp/otlp_grpc_log_exporter_factory.h"
# include "opentelemetry/logs/provider.h"
# include "opentelemetry/sdk/logs/logger_provider_factory.h"
# include "opentelemetry/sdk/logs/simple_log_processor_factory.h"
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
# include "opentelemetry/sdk/trace/simple_processor_factory.h"
# include "opentelemetry/sdk/trace/tracer_provider_factory.h"
# include "opentelemetry/trace/provider.h"
Expand Down Expand Up @@ -43,8 +50,13 @@ void InitTracer()
void InitLogger()
{
// Create OTLP exporter instance
<<<<<<< HEAD
auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(opts);
auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter));
=======
auto exporter = otlp::OtlpGrpcLogExporterFactory::Create(opts);
auto processor = logs_sdk::SimpleLogProcessorFactory::Create(std::move(exporter));
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
nostd::shared_ptr<logs::LoggerProvider> provider(
logs_sdk::LoggerProviderFactory::Create(std::move(processor)));

Expand Down
13 changes: 13 additions & 0 deletions examples/otlp/http_log_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@

#ifdef ENABLE_LOGS_PREVIEW
# include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h"
<<<<<<< HEAD
# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h"
# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h"
# include "opentelemetry/logs/provider.h"
# include "opentelemetry/sdk/logs/logger_provider_factory.h"
# include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h"
=======
# include "opentelemetry/exporters/otlp/otlp_http_log_exporter_factory.h"
# include "opentelemetry/exporters/otlp/otlp_http_log_exporter_options.h"
# include "opentelemetry/logs/provider.h"
# include "opentelemetry/sdk/logs/logger_provider_factory.h"
# include "opentelemetry/sdk/logs/simple_log_processor_factory.h"
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
# include "opentelemetry/sdk/trace/simple_processor_factory.h"
# include "opentelemetry/sdk/trace/tracer_provider_factory.h"
# include "opentelemetry/trace/provider.h"
Expand Down Expand Up @@ -47,8 +55,13 @@ void InitLogger()
{
logger_opts.console_debug = true;
// Create OTLP exporter instance
<<<<<<< HEAD
auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts);
auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter));
=======
auto exporter = otlp::OtlpHttpLogExporterFactory::Create(logger_opts);
auto processor = logs_sdk::SimpleLogProcessorFactory::Create(std::move(exporter));
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
std::shared_ptr<logs::LoggerProvider> provider =
logs_sdk::LoggerProviderFactory::Create(std::move(processor));

Expand Down
53 changes: 53 additions & 0 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ cc_library(
cc_library(
name = "otlp_grpc_metric_exporter",
srcs = [
<<<<<<< HEAD
"src/otlp_grpc_metric_exporter.cc",
"src/otlp_grpc_metric_exporter_factory.cc",
],
Expand Down Expand Up @@ -237,6 +238,16 @@ cc_library(
"include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h",
=======
"src/otlp_http_log_exporter.cc",
"src/otlp_http_log_exporter_factory.cc",
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_exporter_factory.h",
"include/opentelemetry/exporters/otlp/otlp_http_log_exporter_options.h",
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
Expand Down Expand Up @@ -284,14 +295,24 @@ cc_library(
name = "otlp_grpc_log_exporter",
>>>>>>> 8d1f241d ([Metrics] Add OTLP http metric exporter (#1487))
srcs = [
<<<<<<< HEAD
"src/otlp_grpc_log_record_exporter.cc",
"src/otlp_grpc_log_record_exporter_factory.cc",
=======
"src/otlp_grpc_log_exporter.cc",
"src/otlp_grpc_log_exporter_factory.cc",
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
],
hdrs = [
"include/opentelemetry/exporters/otlp/otlp_environment.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h",
<<<<<<< HEAD
"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_exporter.h",
"include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter_factory.h",
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
"include/opentelemetry/exporters/otlp/protobuf_include_prefix.h",
"include/opentelemetry/exporters/otlp/protobuf_include_suffix.h",
],
Expand Down Expand Up @@ -501,6 +522,22 @@ cc_test(
],
)

cc_test(
name = "otlp_http_log_exporter_factory_test",
srcs = ["test/otlp_http_log_exporter_factory_test.cc"],
tags = [
"otlp",
"otlp_http_log",
"test",
],
deps = [
":otlp_http_log_exporter",
"//api",
"//ext/src/http/client/nosend:http_client_nosend",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "otlp_http_metric_exporter_test",
srcs = ["test/otlp_http_metric_exporter_test.cc"],
Expand Down Expand Up @@ -533,6 +570,22 @@ cc_test(
],
)

cc_test(
name = "otlp_grpc_log_exporter_factory_test",
srcs = ["test/otlp_grpc_log_exporter_factory_test.cc"],
tags = [
"otlp",
"otlp_grpc_log",
"test",
],
deps = [
":otlp_grpc_log_exporter",
"//api",
"//sdk/src/logs",
"@com_google_googletest//:gtest_main",
],
)

otel_cc_benchmark(
name = "otlp_grpc_exporter_benchmark",
srcs = ["test/otlp_grpc_exporter_benchmark.cc"],
Expand Down
39 changes: 39 additions & 0 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ if(WITH_OTLP_GRPC)
list(APPEND OPENTELEMETRY_OTLP_TARGETS opentelemetry_exporter_otlp_grpc)

add_library(
<<<<<<< HEAD
opentelemetry_exporter_otlp_grpc_log
src/otlp_grpc_log_record_exporter.cc
src/otlp_grpc_log_record_exporter_factory.cc)
=======
opentelemetry_exporter_otlp_grpc_log src/otlp_grpc_log_exporter.cc
src/otlp_grpc_log_exporter_factory.cc)
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))

set_target_properties(opentelemetry_exporter_otlp_grpc_log
PROPERTIES EXPORT_NAME otlp_grpc_log_record_exporter)
Expand Down Expand Up @@ -130,8 +135,12 @@ if(WITH_OTLP_HTTP)
if(WITH_LOGS_PREVIEW)
add_library(
opentelemetry_exporter_otlp_http_log
<<<<<<< HEAD
src/otlp_http_log_record_exporter.cc
src/otlp_http_log_record_exporter_factory.cc)
=======
src/otlp_http_log_exporter.cc src/otlp_http_log_exporter_factory.cc)
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))

set_target_properties(opentelemetry_exporter_otlp_http_log
PROPERTIES EXPORT_NAME otlp_http_log_record_exporter)
Expand Down Expand Up @@ -269,6 +278,7 @@ if(BUILD_TESTING)
gtest_add_tests(
TARGET otlp_grpc_log_record_exporter_test
TEST_PREFIX exporter.otlp.
<<<<<<< HEAD
TEST_LIST otlp_grpc_log_record_exporter_test)

add_executable(otlp_grpc_log_record_exporter_factory_test
Expand All @@ -281,6 +291,20 @@ if(BUILD_TESTING)
TARGET otlp_grpc_log_record_exporter_factory_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_log_record_exporter_factory_test)
=======
TEST_LIST otlp_grpc_log_exporter_test)

add_executable(otlp_grpc_log_exporter_factory_test
test/otlp_grpc_log_exporter_factory_test.cc)
target_link_libraries(
otlp_grpc_log_exporter_factory_test ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${GMOCK_LIB}
opentelemetry_exporter_otlp_grpc_log opentelemetry_logs)
gtest_add_tests(
TARGET otlp_grpc_log_exporter_factory_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_log_exporter_factory_test)
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
endif()

add_executable(otlp_grpc_metric_exporter_factory_test
Expand Down Expand Up @@ -330,6 +354,7 @@ if(BUILD_TESTING)
gtest_add_tests(
TARGET otlp_http_log_record_exporter_test
TEST_PREFIX exporter.otlp.
<<<<<<< HEAD
TEST_LIST otlp_http_log_record_exporter_test)

add_executable(otlp_http_log_record_exporter_factory_test
Expand All @@ -342,6 +367,20 @@ if(BUILD_TESTING)
TARGET otlp_http_log_record_exporter_factory_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_http_log_record_exporter_factory_test)
=======
TEST_LIST otlp_http_log_exporter_test)

add_executable(otlp_http_log_exporter_factory_test
test/otlp_http_log_exporter_factory_test.cc)
target_link_libraries(
otlp_http_log_exporter_factory_test ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${GMOCK_LIB}
opentelemetry_exporter_otlp_http_log opentelemetry_logs)
gtest_add_tests(
TARGET otlp_http_log_exporter_factory_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_http_log_exporter_factory_test)
>>>>>>> efd9596f (Fix log sdk builder (#1486) (#1524))
endif()

<<<<<<< HEAD
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h"
# include "opentelemetry/sdk/logs/exporter.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace otlp
{

/**
* Factory class for OtlpGrpcLogExporter.
*/
class OtlpGrpcLogExporterFactory
{
public:
/**
* Create a OtlpGrpcLogExporter.
*/
static std::unique_ptr<opentelemetry::sdk::logs::LogExporter> Create();

/**
* Create a OtlpGrpcLogExporter.
*/
static std::unique_ptr<opentelemetry::sdk::logs::LogExporter> Create(
const OtlpGrpcExporterOptions &options);
};

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE

#endif /* ENABLE_LOGS_PREVIEW */
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/exporters/otlp/otlp_http_log_exporter_options.h"
# include "opentelemetry/sdk/logs/exporter.h"

# include <memory>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace otlp
{

/**
* Factory class for OtlpHttpLogExporter.
*/
class OtlpHttpLogExporterFactory
{
public:
/**
* Create a OtlpHttpLogExporter.
*/
static std::unique_ptr<opentelemetry::sdk::logs::LogExporter> Create();

/**
* Create a OtlpHttpLogExporter.
*/
static std::unique_ptr<opentelemetry::sdk::logs::LogExporter> Create(
const OtlpHttpLogExporterOptions &options);
};

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
#endif
Loading

0 comments on commit 02ed844

Please sign in to comment.