Skip to content

[Logs API] - Logger Changes #1688

@lalitb

Description

@lalitb

Specs - https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/api.md#logger-operations

  • The API specs defines two interfaces to emit logs and events.
  • As per the specs, the interface to emit the logs is ONLY for the Appenders, and not the end-user/instrumentation library. The specs intentionally leaves the general-purpose logging API for the instrumentation library as unspecified. Which means, we may continue using the existing APIs as it is, and add two new interfaces for emitting events and logs.
  • event_name would be copied to Logs attributes before exporting to the destination, ( as part of SDK implementation)

Something like -

  virtual nostd::unique_ptr<LogRecord> Logger::CreateLogRecord() = 0;

  virtual void Logger::EmitEvent(nostd::string event_name, nostd::unique_ptr<LogRecord> log_record) = 0;
 
  virtual void Logger::EmitLog(nostd::unique_ptr<LogRecord> log_record) = 0;
  • In above code design, LogRecord is thought as analogous to Span, and the setters are defined through the Recordable interface implementation by exporter.

  • The existing Logger::Log() method can be renamed as Logger::EmitLog() to be consistent with the newly introduced Logger::EmitLog(log_record) method. This will ensure there won't be much code changes required by instrumentation library.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions