ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
telemetry_sink_backend Class Reference

Boost.Log sink backend that creates telemetry log_records. More...

#include <telemetry_sink_backend.hpp>

Inherits basic_sink_backend< boost::log::sinks::synchronized_feeding >.

Collaboration diagram for telemetry_sink_backend:
Collaboration graph

Public Types

using log_record_handler = std::function< void(domain::log_record)>
 Handler function type for processing log records.
 

Public Member Functions

 telemetry_sink_backend (std::shared_ptr< domain::resource > res, log_record_handler handler)
 Constructs the telemetry sink backend.
 
void consume (const boost::log::record_view &rec)
 Processes a Boost.Log record and converts it to telemetry format.
 

Detailed Description

Boost.Log sink backend that creates telemetry log_records.

This sink extracts trace context from log attributes and constructs OpenTelemetry-compatible log_records for export. It integrates with the existing Boost.Log infrastructure, receiving all log records and converting them to the telemetry domain model.

Usage:

auto resource = domain::resource::from_environment("my-service", "1.0.0");
auto backend = boost::make_shared<telemetry_sink_backend>(
resource,
[](domain::log_record rec) { exporter.export_record(std::move(rec)); }
);
auto sink = boost::make_shared<
boost::log::sinks::asynchronous_sink<telemetry_sink_backend>>(backend);
boost::log::core::get()->add_sink(sink);
A log record with trace correlation.
Definition log_record.hpp:46
static resource from_environment(std::string_view service_name, std::string_view service_version)
Creates a resource by detecting the local environment.
Definition resource.cpp:59

Member Typedef Documentation

◆ log_record_handler

using log_record_handler = std::function<void(domain::log_record)>

Handler function type for processing log records.

The handler is called for each log record after conversion to the telemetry domain model. Implementations may export to file, send to a collector, or perform any other processing.

Constructor & Destructor Documentation

◆ telemetry_sink_backend()

telemetry_sink_backend ( std::shared_ptr< domain::resource res,
log_record_handler  handler 
)
explicit

Constructs the telemetry sink backend.

Parameters
resThe resource describing the entity producing logs. Shared across all log records from this source.
handlerFunction called for each converted log record.

Member Function Documentation

◆ consume()

void consume ( const boost::log::record_view &  rec)

Processes a Boost.Log record and converts it to telemetry format.

This method is called by Boost.Log for each log record that passes the sink's filter. It extracts all relevant attributes, converts the severity level, and creates a domain::log_record with trace correlation if trace_id and span_id attributes are present.

Parameters
recThe Boost.Log record view to process.