aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/diag/otlphttp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/diag/otlphttp.h')
-rw-r--r--src/zenserver/diag/otlphttp.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/zenserver/diag/otlphttp.h b/src/zenserver/diag/otlphttp.h
index 2281bdcc0..64b3dbc87 100644
--- a/src/zenserver/diag/otlphttp.h
+++ b/src/zenserver/diag/otlphttp.h
@@ -3,23 +3,25 @@
#pragma once
-#include <spdlog/sinks/sink.h>
+#include <zencore/logging/sink.h>
#include <zencore/zencore.h>
#include <zenhttp/httpclient.h>
#include <zentelemetry/otlpencoder.h>
#include <zentelemetry/otlptrace.h>
+#include <atomic>
+
#if ZEN_WITH_OTEL
namespace zen::logging {
/**
- * OTLP/HTTP sink for spdlog
+ * OTLP/HTTP sink for logging
*
* Sends log messages and traces to an OpenTelemetry collector via OTLP over HTTP
*/
-class OtelHttpProtobufSink : public spdlog::sinks::sink
+class OtelHttpProtobufSink : public Sink
{
public:
// Note that this URI should be the base URI of the OTLP HTTP endpoint, e.g.
@@ -31,12 +33,12 @@ public:
OtelHttpProtobufSink& operator=(const OtelHttpProtobufSink&) = delete;
private:
- virtual void log(const spdlog::details::log_msg& Msg) override;
- virtual void flush() override;
- virtual void set_pattern(const std::string& pattern) override { ZEN_UNUSED(pattern); }
- virtual void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) override { ZEN_UNUSED(sink_formatter); }
+ virtual void Log(const LogMessage& Msg) override;
+ virtual void Flush() override;
+ virtual void SetFormatter(std::unique_ptr<Formatter>) override {}
void RecordSpans(zen::otel::TraceId Trace, std::span<const zen::otel::Span*> Spans);
+ void CheckPostResult(const HttpClient::Response& Result, const char* Endpoint) noexcept;
// This is just a thin wrapper to call back into the sink while participating in
// reference counting from the OTEL trace back-end
@@ -54,11 +56,15 @@ private:
OtelHttpProtobufSink* m_Sink;
};
- HttpClient m_OtelHttp;
- OtlpEncoder m_Encoder;
- Ref<TraceRecorder> m_TraceRecorder;
+ static constexpr uint32_t kMaxReportedFailures = 5;
+
+ RwLock m_Lock;
+ std::atomic<uint32_t> m_ConsecutivePostFailures{0};
+ HttpClient m_OtelHttp;
+ OtlpEncoder m_Encoder;
+ Ref<TraceRecorder> m_TraceRecorder;
};
} // namespace zen::logging
-#endif \ No newline at end of file
+#endif