forked from open-telemetry/opentelemetry-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix log sdk builder (open-telemetry#1486)
- Loading branch information
Showing
20 changed files
with
591 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter_factory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter_factory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
66 changes: 66 additions & 0 deletions
66
exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter_options.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifdef ENABLE_LOGS_PREVIEW | ||
|
||
# include "opentelemetry/exporters/otlp/otlp_http_client.h" | ||
|
||
# include "opentelemetry/sdk/logs/exporter.h" | ||
|
||
# include <chrono> | ||
# include <cstddef> | ||
# include <memory> | ||
# include <string> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
|
||
/** | ||
* Struct to hold OTLP exporter options. | ||
*/ | ||
struct OtlpHttpLogExporterOptions | ||
{ | ||
// The endpoint to export to. By default | ||
// @see | ||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md | ||
// @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver | ||
std::string url = GetOtlpDefaultHttpLogEndpoint(); | ||
|
||
// By default, post json data | ||
HttpRequestContentType content_type = HttpRequestContentType::kJson; | ||
|
||
// If convert bytes into hex. By default, we will convert all bytes but id into base64 | ||
// This option is ignored if content_type is not kJson | ||
JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; | ||
|
||
// If using the json name of protobuf field to set the key of json. By default, we will use the | ||
// field name just like proto files. | ||
bool use_json_name = false; | ||
|
||
// Whether to print the status of the exporter in the console | ||
bool console_debug = false; | ||
|
||
// TODO: Enable/disable to verify SSL certificate | ||
std::chrono::system_clock::duration timeout = GetOtlpDefaultLogTimeout(); | ||
|
||
// Additional HTTP headers | ||
OtlpHeaders http_headers = GetOtlpDefaultLogHeaders(); | ||
|
||
# ifdef ENABLE_ASYNC_EXPORT | ||
// Concurrent requests | ||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests | ||
std::size_t max_concurrent_requests = 64; | ||
|
||
// Requests per connections | ||
std::size_t max_requests_per_connection = 8; | ||
# endif | ||
}; | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifdef ENABLE_LOGS_PREVIEW | ||
|
||
// MUST be first (absl) | ||
# include "opentelemetry/exporters/otlp/otlp_grpc_log_exporter.h" | ||
|
||
# include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" | ||
# include "opentelemetry/exporters/otlp/otlp_grpc_log_exporter_factory.h" | ||
# include "opentelemetry/sdk/common/global_log_handler.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
|
||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> OtlpGrpcLogExporterFactory::Create() | ||
{ | ||
OtlpGrpcExporterOptions options; | ||
return Create(options); | ||
} | ||
|
||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> OtlpGrpcLogExporterFactory::Create( | ||
const OtlpGrpcExporterOptions &options) | ||
{ | ||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> exporter(new OtlpGrpcLogExporter(options)); | ||
return exporter; | ||
} | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifdef ENABLE_LOGS_PREVIEW | ||
|
||
# include "opentelemetry/exporters/otlp/otlp_http_log_exporter_factory.h" | ||
# include "opentelemetry/exporters/otlp/otlp_http_log_exporter.h" | ||
# include "opentelemetry/exporters/otlp/otlp_http_log_exporter_options.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace otlp | ||
{ | ||
|
||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> OtlpHttpLogExporterFactory::Create() | ||
{ | ||
OtlpHttpLogExporterOptions options; | ||
return Create(options); | ||
} | ||
|
||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> OtlpHttpLogExporterFactory::Create( | ||
const OtlpHttpLogExporterOptions &options) | ||
{ | ||
std::unique_ptr<opentelemetry::sdk::logs::LogExporter> exporter(new OtlpHttpLogExporter(options)); | ||
return exporter; | ||
} | ||
|
||
} // namespace otlp | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE | ||
|
||
#endif |
Oops, something went wrong.