41#include <condition_variable>
47#include <unordered_map>
96 std::string endpoint =
"http://localhost:4318/v1/logs";
106 std::chrono::milliseconds timeout{5000};
111 bool use_tls =
false;
141 std::size_t max_batch_size = 512;
146 std::chrono::milliseconds flush_interval{5000};
151 std::size_t max_queue_size = 10000;
156 std::size_t max_retries = 3;
161 std::chrono::milliseconds retry_delay{100};
166 std::unordered_map<std::string, std::string>
headers;
174 uint64_t logs_exported{0};
175 uint64_t logs_dropped{0};
176 uint64_t export_success{0};
177 uint64_t export_failures{0};
188 std::atomic<uint64_t> logs_exported{0};
189 std::atomic<uint64_t> logs_dropped{0};
190 std::atomic<uint64_t> export_success{0};
191 std::atomic<uint64_t> export_failures{0};
192 std::atomic<uint64_t> retries{0};
230 std::string
get_name()
const override {
return "otlp"; }
235 bool is_healthy()
const override;
240 export_stats get_stats()
const;
249 void export_thread_func();
252 bool export_batch(
const std::vector<log_entry>& batch);
255 static int to_otlp_severity(common::interfaces::log_level level);
257#ifdef LOGGER_HAS_OTLP
259 bool export_with_otel_sdk(
const std::vector<log_entry>& batch);
262 bool export_with_http(
const std::vector<log_entry>& batch);
265 static std::string escape_json(
const std::string& str);
279 std::atomic<bool> running_{
false};
280 std::atomic<bool> healthy_{
true};
282#ifdef LOGGER_HAS_OTLP
285 std::unique_ptr<otel_impl> otel_impl_;
Abstract base class for all log output writers kcenon.
Abstract base class for all log output writers.
OTLP log exporter for OpenTelemetry integration.
otlp_writer(const otlp_writer &)=delete
std::unique_ptr< std::thread > export_thread_
otlp_writer(otlp_writer &&)=delete
std::string get_name() const override
Get writer name.
protocol_type
Transport protocol for OTLP export.
std::condition_variable queue_cv_
otlp_writer & operator=(const otlp_writer &)=delete
std::queue< log_entry > queue_
otlp_writer & operator=(otlp_writer &&)=delete
DLL export/import macros for logger_system shared library support.
#define LOGGER_SYSTEM_API
OpenTelemetry context structure for trace correlation kcenon.
Tag interface for asynchronous writers.
Represents a single log entry with all associated metadata.
Configuration for OTLP writer.
std::unordered_map< std::string, std::string > resource_attributes
Custom resource attributes.
std::unordered_map< std::string, std::string > headers
HTTP headers for authentication.
std::string service_namespace
Service namespace.
std::string service_name
Service name (required for resource attributes)
std::string service_instance_id
Service instance ID.
std::string service_version
Service version.
Statistics snapshot for OTLP export (copyable)
std::chrono::system_clock::time_point last_error
std::chrono::system_clock::time_point last_export
Internal atomic statistics (non-copyable)
std::chrono::system_clock::time_point last_error
std::chrono::system_clock::time_point last_export
Writer category interfaces and type traits kcenon.