Skip to content

Commit

Permalink
[API] DO not allow unsafe Logger::EmitLogRecord (#2673)
Browse files Browse the repository at this point in the history
  • Loading branch information
owent authored May 28, 2024
1 parent 605c3e8 commit 17c3bc6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/include/opentelemetry/logs/logger_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <memory>
#include <type_traits>

#include "opentelemetry/common/attribute_value.h"
Expand Down Expand Up @@ -145,6 +146,10 @@ struct LogRecordSetterTrait<common::KeyValueIterable>
template <class ValueType>
struct LogRecordSetterTrait
{
static_assert(!std::is_same<nostd::unique_ptr<LogRecord>, ValueType>::value &&
!std::is_same<std::unique_ptr<LogRecord>, ValueType>::value,
"unique_ptr<LogRecord> is not allowed, please use std::move()");

template <class ArgumentType,
nostd::enable_if_t<std::is_convertible<ArgumentType, nostd::string_view>::value ||
std::is_convertible<ArgumentType, common::AttributeValue>::value,
Expand Down

2 comments on commit 17c3bc6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 17c3bc6 Previous: 605c3e8 Ratio
BM_NaiveSpinLockThrashing/4/process_time/real_time 1.6793118247502967 ms/iter 0.593912721884371 ms/iter 2.83

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 17c3bc6 Previous: 605c3e8 Ratio
BM_BaselineBuffer/2 7802274.227142334 ns/iter 2844405.174255371 ns/iter 2.74
BM_BaselineBuffer/4 15336954.593658447 ns/iter 2468392.8983584186 ns/iter 6.21
BM_LockFreeBuffer/2 8218231.201171875 ns/iter 1248226.6426086426 ns/iter 6.58
BM_LockFreeBuffer/4 9439129.829406738 ns/iter 1288424.7604259946 ns/iter 7.33

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.