-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix global log handle symbols when using dlopen (#1420)
- Loading branch information
Showing
10 changed files
with
87 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "opentelemetry/sdk/common/global_log_handler.h" | ||
|
||
#include <cstring> | ||
#include <random> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace common | ||
{ | ||
namespace internal_log | ||
{ | ||
|
||
LogHandler::~LogHandler() {} | ||
|
||
void DefaultLogHandler::Handle(LogLevel level, | ||
const char *file, | ||
int line, | ||
const char *msg, | ||
const sdk::common::AttributeMap &attributes) noexcept | ||
{ | ||
std::stringstream output_s; | ||
output_s << "[" << LevelToString(level) << "] "; | ||
if (file != nullptr) | ||
{ | ||
output_s << "File: " << file << ":" << line; | ||
} | ||
if (msg != nullptr) | ||
{ | ||
output_s << msg; | ||
} | ||
output_s << std::endl; | ||
// TBD - print attributes | ||
std::cout << output_s.str(); // thread safe. | ||
} | ||
|
||
void NoopLogHandler::Handle(LogLevel, | ||
const char *, | ||
int, | ||
const char *, | ||
const sdk::common::AttributeMap &) noexcept | ||
{} | ||
|
||
std::pair<nostd::shared_ptr<LogHandler>, LogLevel> &GlobalLogHandler::GetHandlerAndLevel() noexcept | ||
{ | ||
static std::pair<nostd::shared_ptr<LogHandler>, LogLevel> handler_and_level{ | ||
nostd::shared_ptr<LogHandler>(new DefaultLogHandler), LogLevel::Warning}; | ||
return handler_and_level; | ||
} | ||
|
||
} // namespace internal_log | ||
} // namespace common | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7e90dae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.BM_BaselineBuffer/2
18250286.57913208
ns/iter4129480.3619384766
ns/iter4.42
This comment was automatically generated by workflow using github-action-benchmark.