You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now abseil is very opinionated how logged messages are supposed to leave the application. If you want to integrate well with opentelemetry-cpp one can do something like this:
class open_telemetry_log_sink : public absl::LogSink
{
public:
explicit open_telemetry_log_sink(std::shared_ptr<opentelemetry::logs::Logger> logger)
: _logger(std::move(logger))
{
}
static otel::logs::Severity convert_absl_severity(absl::LogSeverity s)
{
switch (s)
{
case absl::LogSeverity::kInfo:
return otel::logs::Severity::kInfo;
case absl::LogSeverity::kWarning:
return otel::logs::Severity::kWarn;
case absl::LogSeverity::kError:
return otel::logs::Severity::kError;
case absl::LogSeverity::kFatal:
return otel::logs::Severity::kFatal;
}
}
void Send(const absl::LogEntry& entry) override
{
// TODO add further information, like filename, line, timestamp etc
_logger->Log(convert_absl_severity(entry.log_severity()), entry.text_message());
}
std::shared_ptr<opentelemetry::v1::logs::Logger> _logger;
};
// [...]
open_telemetry_log_sink log_sink{ logger };
absl::AddLogSink(&log_sink);
which will expose the log messages to open-telemetry. However, abseil still logs to stdout or stderr, in a format that is not customizable!
I would like to discuss how such an integration could look like, in particular, because gRPC has already an open-telemetry plugin to provide metrics and uses abseil for logging.
Maybe there are already plans? Or there is already a well supported integration and my google skills are just lacking.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Right now abseil is very opinionated how logged messages are supposed to leave the application. If you want to integrate well with opentelemetry-cpp one can do something like this:
which will expose the log messages to open-telemetry. However, abseil still logs to stdout or stderr, in a format that is not customizable!
I would like to discuss how such an integration could look like, in particular, because gRPC has already an open-telemetry plugin to provide metrics and uses abseil for logging.
Maybe there are already plans? Or there is already a well supported integration and my google skills are just lacking.
Beta Was this translation helpful? Give feedback.
All reactions