Skip to content

Commit 56e6654

Browse files
authored
Merge branch 'main' into feature_add_cmake_package_components
2 parents d3d0db7 + 7f047d5 commit 56e6654

File tree

8 files changed

+48
-26
lines changed

8 files changed

+48
-26
lines changed

api/include/opentelemetry/nostd/type_traits.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# include "opentelemetry/config.h"
1818
# include "opentelemetry/nostd/detail/void.h" // IWYU pragma: export
1919
# include "opentelemetry/version.h"
20+
#endif
2021

2122
OPENTELEMETRY_BEGIN_NAMESPACE
2223
namespace nostd
@@ -70,6 +71,10 @@ struct remove_all_extents<std::array<T, N>> : remove_all_extents<T>
7071
template <typename T>
7172
using remove_all_extents_t = typename remove_all_extents<T>::type;
7273

74+
#if defined(OPENTELEMETRY_STL_VERSION) && OPENTELEMETRY_STL_VERSION >= 2017
75+
using std::is_nothrow_swappable;
76+
using std::is_swappable;
77+
#else
7378
/**
7479
* Back port of std::is_swappable
7580
*/
@@ -119,6 +124,7 @@ struct is_nothrow_swappable<false, T> : std::false_type
119124
} // namespace detail
120125
template <typename T>
121126
using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappable<T>::value, T>;
127+
#endif
122128

123129
/**
124130
* Back port of
@@ -127,12 +133,12 @@ using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappabl
127133
* std::is_trivialy_copy_assignable
128134
* std::is_trivialy_move_assignable
129135
*/
130-
# ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
136+
#ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
131137
using std::is_trivially_copy_assignable;
132138
using std::is_trivially_copy_constructible;
133139
using std::is_trivially_move_assignable;
134140
using std::is_trivially_move_constructible;
135-
# else
141+
#else
136142
template <typename T>
137143
struct is_trivially_copy_constructible
138144
{
@@ -156,7 +162,6 @@ struct is_trivially_move_assignable
156162
{
157163
static constexpr bool value = __is_trivial(T);
158164
};
159-
# endif
165+
#endif
160166
} // namespace nostd
161167
OPENTELEMETRY_END_NAMESPACE
162-
#endif /* OPENTELEMETRY_HAVE_STD_TYPE_TRAITS */

api/include/opentelemetry/std/type_traits.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55

66
// IWYU pragma: private, include "opentelemetry/nostd/type_traits.h"
77

8-
#include <type_traits>
8+
#include <type_traits> // IWYU pragma: keep
99

10-
#include "opentelemetry/version.h"
11-
12-
OPENTELEMETRY_BEGIN_NAMESPACE
13-
// Standard Type aliases in nostd namespace
14-
namespace nostd
15-
{
16-
17-
// nostd::enable_if_t<...>
18-
template <bool B, class T = void>
19-
using enable_if_t = typename std::enable_if<B, T>::type;
20-
21-
} // namespace nostd
22-
OPENTELEMETRY_END_NAMESPACE
10+
#include "opentelemetry/version.h" // IWYU pragma: keep

exporters/elasticsearch/src/es_log_recordable.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@
2323

2424
namespace nlohmann
2525
{
26+
template <class T>
27+
struct json_assign_visitor
28+
{
29+
T *j_;
30+
json_assign_visitor(T &j) : j_(&j) {}
31+
32+
template <class U>
33+
void operator()(const U &u)
34+
{
35+
*j_ = u;
36+
}
37+
};
38+
2639
template <>
2740
struct adl_serializer<opentelemetry::sdk::common::OwnedAttributeValue>
2841
{
2942
static void to_json(json &j, const opentelemetry::sdk::common::OwnedAttributeValue &v)
3043
{
31-
opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v);
44+
opentelemetry::nostd::visit(json_assign_visitor<json>(j), v);
3245
}
3346
};
3447

@@ -37,7 +50,7 @@ struct adl_serializer<opentelemetry::common::AttributeValue>
3750
{
3851
static void to_json(json &j, const opentelemetry::common::AttributeValue &v)
3952
{
40-
opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v);
53+
opentelemetry::nostd::visit(json_assign_visitor<json>(j), v);
4154
}
4255
};
4356
} // namespace nlohmann

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable
7676
* @param id the event Id to set
7777
* @param name the event name to set
7878
*/
79-
void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override
80-
{
81-
// TODO: export Event Id to OTLP
82-
}
79+
void SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept override;
8380

8481
/**
8582
* Set the trace id for this log.

exporters/otlp/src/otlp_log_recordable.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ void OtlpLogRecordable::SetBody(const opentelemetry::common::AttributeValue &mes
197197
OtlpPopulateAttributeUtils::PopulateAnyValue(proto_record_.mutable_body(), message);
198198
}
199199

200+
void OtlpLogRecordable::SetEventId(int64_t /* id */, nostd::string_view event_name) noexcept
201+
{
202+
proto_record_.set_event_name(event_name.data(), event_name.size());
203+
}
204+
200205
void OtlpLogRecordable::SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept
201206
{
202207
if (trace_id.IsValid())

exporters/otlp/test/otlp_log_recordable_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ TEST(OtlpLogRecordable, SetInstrumentationScope)
174174
EXPECT_EQ(&rec.GetInstrumentationScope(), inst_lib.get());
175175
}
176176

177+
TEST(OtlpLogRecordable, SetEventName)
178+
{
179+
OtlpLogRecordable rec;
180+
181+
nostd::string_view event_name = "Test Event";
182+
rec.SetEventId(0, event_name);
183+
184+
EXPECT_EQ(rec.log_record().event_name(), event_name);
185+
}
186+
177187
/**
178188
* AttributeValue can contain different int types, such as int, int64_t,
179189
* unsigned int, and uint64_t. To avoid writing test cases for each, we can

ext/src/http/client/curl/http_client_curl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <mutex>
1616
#include <string>
1717
#include <thread>
18-
#include <type_traits>
1918
#include <unordered_map>
2019
#include <unordered_set>
2120
#include <utility>
@@ -26,6 +25,7 @@
2625
#include "opentelemetry/ext/http/common/url_parser.h"
2726
#include "opentelemetry/nostd/shared_ptr.h"
2827
#include "opentelemetry/nostd/string_view.h"
28+
#include "opentelemetry/nostd/type_traits.h"
2929
#include "opentelemetry/sdk/common/thread_instrumentation.h"
3030
#include "opentelemetry/version.h"
3131

@@ -116,7 +116,7 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m
116116
// now empty input buffer (this will only occur for long incompressible streams, more than ~20 MB
117117
// for the default deflate memLevel of 8, or when *max_len is too small and less than the length
118118
// of the header plus one byte)
119-
auto hold = static_cast<std::remove_const_t<decltype(z_stream::next_in)>>(
119+
auto hold = static_cast<nostd::remove_const_t<decltype(z_stream::next_in)>>(
120120
strm->zalloc(strm->opaque, strm->avail_in, 1)); // allocated buffer to hold input data
121121
if (hold == Z_NULL)
122122
{

sdk/src/metrics/instrument_metadata_validator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99

1010
#if OPENTELEMETRY_HAVE_WORKING_REGEX
1111
# include <regex>
12+
#else
13+
# include <algorithm>
1214
#endif
1315

1416
OPENTELEMETRY_BEGIN_NAMESPACE
1517
namespace sdk
1618
{
1719
namespace metrics
1820
{
21+
#if OPENTELEMETRY_HAVE_WORKING_REGEX
1922
// instrument-name = ALPHA 0*254 ("_" / "." / "-" / "/" / ALPHA / DIGIT)
2023
const std::string kInstrumentNamePattern = "[a-zA-Z][-_./a-zA-Z0-9]{0,254}";
2124
//
2225
const std::string kInstrumentUnitPattern = "[\x01-\x7F]{0,63}";
2326
// instrument-unit = It can have a maximum length of 63 ASCII chars
27+
#endif
2428

2529
InstrumentMetaDataValidator::InstrumentMetaDataValidator()
2630
#if OPENTELEMETRY_HAVE_WORKING_REGEX

0 commit comments

Comments
 (0)