Skip to content

Commit eca54eb

Browse files
authored
Merge branch 'main' into fix-install-sdk-config
2 parents 15e3d9f + 7e90dae commit eca54eb

File tree

17 files changed

+135
-39
lines changed

17 files changed

+135
-39
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ LICENSE* text
4141
## git files
4242
.gitignore text eol=lf
4343
.gitattributes text eol=lf
44+
45+
## bazel files
46+
WORKSPACE text eol=lf
47+
BUILD text eol=lf

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Increment the:
1515

1616
## [Unreleased]
1717

18+
* [METRICS] Only record non-negative / finite / Non-NAN histogram values([#1427](https://github.com/open-telemetry/opentelemetry-cpp/pull/1427))
19+
1820
## [1.4.0] 2022-05-17
1921

2022
* [API SDK] Upgrade proto to v0.17.0, update log data model ([#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383))

api/include/opentelemetry/trace/span_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class SpanContext final
8181

8282
bool IsRemote() const noexcept { return is_remote_; }
8383

84-
static SpanContext GetInvalid() { return SpanContext(false, false); }
84+
static SpanContext GetInvalid() noexcept { return SpanContext(false, false); }
8585

8686
bool IsSampled() const noexcept { return trace_flags_.IsSampled(); }
8787

exporters/etw/include/opentelemetry/exporters/etw/etw_logger_exporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# include "opentelemetry/common/key_value_iterable_view.h"
1717

18-
# include "opentelemetry/logs/tracer_provider.h"
18+
# include "opentelemetry/logs/logger_provider.h"
1919
# include "opentelemetry/trace/span_id.h"
2020
# include "opentelemetry/trace/trace_id.h"
2121

exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class PropertyValue : public PropertyVariant
192192
{}
193193

194194
/**
195-
* @brief Convert owning PropertyValue to non-owning common::AttributeValue
195+
* @brief Convert non-owning common::AttributeValue to owning PropertyValue.
196196
* @return
197197
*/
198198
PropertyValue &FromAttributeValue(const common::AttributeValue &v)
@@ -222,7 +222,8 @@ class PropertyValue : public PropertyVariant
222222
break;
223223
}
224224
case common::AttributeType::kTypeString: {
225-
PropertyVariant::operator=(nostd::string_view(nostd::get<nostd::string_view>(v)).data());
225+
PropertyVariant::operator=
226+
(std::string{nostd::string_view(nostd::get<nostd::string_view>(v)).data()});
226227
break;
227228
}
228229

exporters/etw/test/etw_logger_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# include <map>
99
# include <string>
1010

11-
# include "opentelemetry/exporters/etw/etw_logger.h"
11+
# include "opentelemetry/exporters/etw/etw_logger_exporter.h"
1212
# include "opentelemetry/sdk/trace/simple_processor.h"
1313

1414
using namespace OPENTELEMETRY_NAMESPACE;

exporters/jaeger/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ cc_library(
180180
tags = ["jaeger"],
181181
deps = [
182182
":jaeger_exporter",
183+
"//sdk/src/common:global_log_handler",
183184
],
184185
)
185186

sdk/include/opentelemetry/sdk/common/global_log_handler.h

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ inline std::string LevelToString(LogLevel level)
5555
class LogHandler
5656
{
5757
public:
58-
virtual ~LogHandler() = default;
58+
virtual ~LogHandler();
5959

6060
virtual void Handle(LogLevel level,
6161
const char *file,
@@ -71,22 +71,7 @@ class DefaultLogHandler : public LogHandler
7171
const char *file,
7272
int line,
7373
const char *msg,
74-
const sdk::common::AttributeMap &attributes) noexcept override
75-
{
76-
std::stringstream output_s;
77-
output_s << "[" << LevelToString(level) << "] ";
78-
if (file != nullptr)
79-
{
80-
output_s << "File: " << file << ":" << line;
81-
}
82-
if (msg != nullptr)
83-
{
84-
output_s << msg;
85-
}
86-
output_s << std::endl;
87-
// TBD - print attributes
88-
std::cout << output_s.str(); // thread safe.
89-
}
74+
const sdk::common::AttributeMap &attributes) noexcept override;
9075
};
9176

9277
class NoopLogHandler : public LogHandler
@@ -96,10 +81,7 @@ class NoopLogHandler : public LogHandler
9681
const char *file,
9782
int line,
9883
const char *msg,
99-
const sdk::common::AttributeMap &error_attributes) noexcept override
100-
{
101-
// ignore the log message
102-
}
84+
const sdk::common::AttributeMap &error_attributes) noexcept override;
10385
};
10486

10587
/**
@@ -113,7 +95,7 @@ class GlobalLogHandler
11395
*
11496
* By default, a default LogHandler is returned.
11597
*/
116-
static const nostd::shared_ptr<LogHandler> &GetLogHandler() noexcept
98+
static inline const nostd::shared_ptr<LogHandler> &GetLogHandler() noexcept
11799
{
118100
return GetHandlerAndLevel().first;
119101
}
@@ -123,7 +105,7 @@ class GlobalLogHandler
123105
* This should be called once at the start of application before creating any Provider
124106
* instance.
125107
*/
126-
static void SetLogHandler(nostd::shared_ptr<LogHandler> eh) noexcept
108+
static inline void SetLogHandler(nostd::shared_ptr<LogHandler> eh) noexcept
127109
{
128110
GetHandlerAndLevel().first = eh;
129111
}
@@ -133,22 +115,17 @@ class GlobalLogHandler
133115
*
134116
* By default, a default log level is returned.
135117
*/
136-
static LogLevel GetLogLevel() noexcept { return GetHandlerAndLevel().second; }
118+
static inline LogLevel GetLogLevel() noexcept { return GetHandlerAndLevel().second; }
137119

138120
/**
139121
* Changes the singleton Log level.
140122
* This should be called once at the start of application before creating any Provider
141123
* instance.
142124
*/
143-
static void SetLogLevel(LogLevel level) noexcept { GetHandlerAndLevel().second = level; }
125+
static inline void SetLogLevel(LogLevel level) noexcept { GetHandlerAndLevel().second = level; }
144126

145127
private:
146-
static std::pair<nostd::shared_ptr<LogHandler>, LogLevel> &GetHandlerAndLevel() noexcept
147-
{
148-
static std::pair<nostd::shared_ptr<LogHandler>, LogLevel> handler_and_level{
149-
nostd::shared_ptr<LogHandler>(new DefaultLogHandler), LogLevel::Warning};
150-
return handler_and_level;
151-
}
128+
static std::pair<nostd::shared_ptr<LogHandler>, LogLevel> &GetHandlerAndLevel() noexcept;
152129
};
153130

154131
} // namespace internal_log

sdk/src/common/BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ cc_library(
2727
include_prefix = "src/common",
2828
deps = [
2929
"//api",
30+
"//sdk:headers",
3031
"//sdk/src/common/platform:fork",
3132
],
3233
)
34+
35+
cc_library(
36+
name = "global_log_handler",
37+
srcs = [
38+
"global_log_handler.cc",
39+
],
40+
deps = [
41+
"//api",
42+
"//sdk:headers",
43+
],
44+
)

sdk/src/common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(COMMON_SRCS random.cc core.cc)
1+
set(COMMON_SRCS random.cc core.cc global_log_handler.cc)
22
if(WIN32)
33
list(APPEND COMMON_SRCS platform/fork_windows.cc)
44
else()

0 commit comments

Comments
 (0)