Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Increment the:

## [Unreleased]

* [CONFIGURATION] Implement EventToSpanEventBridge log record processor for
declarative configuration
[#4309](https://github.com/open-telemetry/opentelemetry-cpp/pull/4309)

* [CODE HEALTH] Move SDK trace and metrics test helpers into anonymous
namespaces
[#4303](https://github.com/open-telemetry/opentelemetry-cpp/pull/4303)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/drop_aggregation_configuration.h"
#include "opentelemetry/sdk/configuration/event_to_span_event_bridge_log_record_processor_configuration.h"
#include "opentelemetry/sdk/configuration/exemplar_filter.h"
#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h"
#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h"
Expand Down Expand Up @@ -167,6 +168,10 @@ class ConfigurationParser
std::unique_ptr<SimpleLogRecordProcessorConfiguration> ParseSimpleLogRecordProcessorConfiguration(
const std::unique_ptr<DocumentNode> &node) const;

std::unique_ptr<EventToSpanEventBridgeLogRecordProcessorConfiguration>
ParseEventToSpanEventBridgeLogRecordProcessorConfiguration(
const std::unique_ptr<DocumentNode> &node) const;

std::unique_ptr<ExtensionLogRecordProcessorConfiguration>
ParseExtensionLogRecordProcessorConfiguration(const std::string &name,
std::unique_ptr<DocumentNode> node) const;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/sdk/configuration/log_record_processor_configuration.h"
#include "opentelemetry/sdk/configuration/log_record_processor_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

// YAML-SCHEMA: schema/logger_provider.json
// YAML-NODE: ExperimentalEventToSpanEventBridgeLogRecordProcessor
class EventToSpanEventBridgeLogRecordProcessorConfiguration : public LogRecordProcessorConfiguration
{
public:
void Accept(LogRecordProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitEventToSpanEventBridge(this);
}
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace configuration

class BatchLogRecordProcessorConfiguration;
class SimpleLogRecordProcessorConfiguration;
class EventToSpanEventBridgeLogRecordProcessorConfiguration;
class ExtensionLogRecordProcessorConfiguration;

class LogRecordProcessorConfigurationVisitor
Expand All @@ -27,8 +28,10 @@ class LogRecordProcessorConfigurationVisitor
const LogRecordProcessorConfigurationVisitor &other) = default;
virtual ~LogRecordProcessorConfigurationVisitor() = default;

virtual void VisitBatch(const BatchLogRecordProcessorConfiguration *model) = 0;
virtual void VisitSimple(const SimpleLogRecordProcessorConfiguration *model) = 0;
virtual void VisitBatch(const BatchLogRecordProcessorConfiguration *model) = 0;
virtual void VisitSimple(const SimpleLogRecordProcessorConfiguration *model) = 0;
virtual void VisitEventToSpanEventBridge(
const EventToSpanEventBridgeLogRecordProcessorConfiguration *model) = 0;
virtual void VisitExtension(const ExtensionLogRecordProcessorConfiguration *model) = 0;
};

Expand Down
5 changes: 5 additions & 0 deletions sdk/include/opentelemetry/sdk/configuration/sdk_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ class SdkBuilder
std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor> CreateSimpleLogRecordProcessor(
const opentelemetry::sdk::configuration::SimpleLogRecordProcessorConfiguration *model) const;

std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor>
CreateEventToSpanEventBridgeLogRecordProcessor(
const opentelemetry::sdk::configuration::EventToSpanEventBridgeLogRecordProcessorConfiguration
*model) const;

std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor> CreateExtensionLogRecordProcessor(
const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model)
const;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <chrono>
#include <memory>

#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/sdk/logs/recordable.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace logs
{

/**
* A log record processor that bridges log records representing events (i.e. log records with a
* non-empty event name) onto the current active span as span events.
*
* A log record is bridged to a span event if and only if:
* - the log record has a non-empty event name,
* - the log record carries a valid trace id and span id,
* - the current active span (from the ambient context at the time OnEmit is called) is
* recording, and
* - the current active span's trace id and span id match those on the log record.
*
* This processor does not export log records and does not stop the log record from continuing
* through the rest of the configured processing pipeline.
*/
class EventToSpanEventBridgeProcessor : public LogRecordProcessor
{
public:
EventToSpanEventBridgeProcessor() = default;
EventToSpanEventBridgeProcessor(const EventToSpanEventBridgeProcessor &) = delete;
EventToSpanEventBridgeProcessor(EventToSpanEventBridgeProcessor &&) = delete;
EventToSpanEventBridgeProcessor &operator=(const EventToSpanEventBridgeProcessor &) = delete;
EventToSpanEventBridgeProcessor &operator=(EventToSpanEventBridgeProcessor &&) = delete;
~EventToSpanEventBridgeProcessor() override = default;

std::unique_ptr<Recordable> MakeRecordable() noexcept override;

void OnEmit(std::unique_ptr<Recordable> &&record) noexcept override;

bool ForceFlush(
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override;

bool Shutdown(
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override;

bool HasEnabledFilter() const noexcept override { return false; }
};

} // namespace logs
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>

#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace logs
{

/**
* Factory class for EventToSpanEventBridgeProcessor.
*/
class OPENTELEMETRY_EXPORT EventToSpanEventBridgeProcessorFactory
{
public:
/**
* Create an EventToSpanEventBridgeProcessor.
*/
static std::unique_ptr<LogRecordProcessor> Create();
};

} // namespace logs
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
12 changes: 12 additions & 0 deletions sdk/src/configuration/configuration_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/drop_aggregation_configuration.h"
#include "opentelemetry/sdk/configuration/event_to_span_event_bridge_log_record_processor_configuration.h"
#include "opentelemetry/sdk/configuration/exemplar_filter.h"
#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h"
#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h"
Expand Down Expand Up @@ -570,6 +571,13 @@ ConfigurationParser::ParseSimpleLogRecordProcessorConfiguration(
return model;
}

std::unique_ptr<EventToSpanEventBridgeLogRecordProcessorConfiguration>
ConfigurationParser::ParseEventToSpanEventBridgeLogRecordProcessorConfiguration(
const std::unique_ptr<DocumentNode> & /* node */) const
{
return std::make_unique<EventToSpanEventBridgeLogRecordProcessorConfiguration>();
}

std::unique_ptr<ExtensionLogRecordProcessorConfiguration>
ConfigurationParser::ParseExtensionLogRecordProcessorConfiguration(
const std::string &name,
Expand Down Expand Up @@ -615,6 +623,10 @@ ConfigurationParser::ParseLogRecordProcessorConfiguration(
{
model = ParseSimpleLogRecordProcessorConfiguration(child);
}
else if (name == "event_to_span_event_bridge/development")
{
model = ParseEventToSpanEventBridgeLogRecordProcessorConfiguration(child);
}
else
{
model = ParseExtensionLogRecordProcessorConfiguration(name, std::move(child));
Expand Down
16 changes: 16 additions & 0 deletions sdk/src/configuration/sdk_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#include "opentelemetry/sdk/instrumentationscope/scope_configurator.h"
#include "opentelemetry/sdk/logs/batch_log_record_processor_factory.h"
#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h"
#include "opentelemetry/sdk/logs/event_to_span_event_bridge_processor_factory.h"
#include "opentelemetry/sdk/logs/exporter.h"
#include "opentelemetry/sdk/logs/log_record_limits.h"
#include "opentelemetry/sdk/logs/logger_config.h"
Expand Down Expand Up @@ -756,6 +757,13 @@ class LogRecordProcessorBuilder
processor = sdk_builder_->CreateSimpleLogRecordProcessor(model);
}

void VisitEventToSpanEventBridge(
const opentelemetry::sdk::configuration::EventToSpanEventBridgeLogRecordProcessorConfiguration
*model) override
{
processor = sdk_builder_->CreateEventToSpanEventBridgeLogRecordProcessor(model);
}

void VisitExtension(
const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model)
override
Expand Down Expand Up @@ -1930,6 +1938,14 @@ SdkBuilder::CreateSimpleLogRecordProcessor(
return sdk;
}

std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor>
SdkBuilder::CreateEventToSpanEventBridgeLogRecordProcessor(
const opentelemetry::sdk::configuration::EventToSpanEventBridgeLogRecordProcessorConfiguration
* /* model */) const
{
return opentelemetry::sdk::logs::EventToSpanEventBridgeProcessorFactory::Create();
}

std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor>
SdkBuilder::CreateExtensionLogRecordProcessor(
const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) const
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/logs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ add_library(
event_logger.cc
simple_log_record_processor.cc
simple_log_record_processor_factory.cc
event_to_span_event_bridge_processor.cc
event_to_span_event_bridge_processor_factory.cc
batch_log_record_processor.cc
batch_log_record_processor_options.cc
batch_log_record_processor_factory.cc
Expand Down
Loading
Loading