Skip to content

Commit f0c7212

Browse files
authored
[BUILD] Upgrade to rapidyaml 0.12.1 (open-telemetry#4076)
1 parent 52612db commit f0c7212

6 files changed

Lines changed: 65 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ Increment the:
104104
* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.41.1
105105
[#4075](https://github.com/open-telemetry/opentelemetry-cpp/pull/4075)
106106

107+
* [BUILD] Upgrade to rapidyaml 0.12.1
108+
[#4076](https://github.com/open-telemetry/opentelemetry-cpp/pull/4076)
109+
107110
Important changes:
108111

109112
* Enable WITH_OTLP_RETRY_PREVIEW by default

‎MODULE.bazel‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_o
1818
bazel_dep(name = "platforms", version = "1.1.0")
1919
bazel_dep(name = "prometheus-cpp", version = "1.3.0.bcr.2", repo_name = "com_github_jupp0r_prometheus_cpp")
2020
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
21-
bazel_dep(name = "rapidyaml", version = "0.10.0")
21+
bazel_dep(name = "rapidyaml", version = "0.12.1")
2222
bazel_dep(name = "rules_cc", version = "0.2.18")
2323
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
2424
bazel_dep(name = "rules_proto", version = "7.1.0")

‎install/cmake/third_party_latest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ nlohmann-json=v3.12.0
1616
opentelemetry-proto=v1.10.0
1717
opentracing-cpp=v1.6.0
1818
prometheus-cpp=v1.3.0
19-
ryml=v0.10.0
19+
ryml=v0.12.1

‎sdk/include/opentelemetry/sdk/configuration/ryml_document.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class RymlDocument : public Document
3737

3838
private:
3939
static ryml::Callbacks MakeCallbacks();
40-
[[noreturn]] static void OnError(const char *msg,
41-
size_t msg_len,
42-
ryml::Location location,
43-
void *user_data);
4440

4541
ryml::ParserOptions opts_;
4642
ryml::Parser::handler_type event_handler_;

‎sdk/src/configuration/ryml_document.cc‎

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,52 @@ namespace sdk
2424
namespace configuration
2525
{
2626

27-
// Custom ryml error callback that throws instead of calling abort().
28-
// This ensures the try-catch in ParseDocument works regardless of how
29-
// ryml was compiled (with or without RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS).
30-
void RymlDocument::OnError(const char *msg,
31-
size_t msg_len,
32-
ryml::Location location,
33-
void * /*user_data*/)
27+
#if RYML_VERSION_MINOR >= 11
28+
[[noreturn]] static void OnErrorBasic(c4::csubstr msg,
29+
const ryml::ErrorDataBasic &errdata,
30+
void * /*user_data*/)
31+
{
32+
DocumentNodeLocation loc;
33+
loc.offset = errdata.location.offset;
34+
loc.line = errdata.location.line;
35+
loc.col = errdata.location.col;
36+
loc.filename = std::string(errdata.location.name.str, errdata.location.name.len);
37+
38+
throw InvalidSchemaException(loc, std::string(msg.str, msg.len));
39+
}
40+
41+
[[noreturn]] static void OnErrorParse(c4::csubstr msg,
42+
const ryml::ErrorDataParse &errdata,
43+
void * /*user_data*/)
44+
{
45+
DocumentNodeLocation loc;
46+
loc.offset = errdata.ymlloc.offset;
47+
loc.line = errdata.ymlloc.line;
48+
loc.col = errdata.ymlloc.col;
49+
loc.filename = std::string(errdata.ymlloc.name.str, errdata.ymlloc.name.len);
50+
51+
throw InvalidSchemaException(loc, std::string(msg.str, msg.len));
52+
}
53+
54+
[[noreturn]] static void OnErrorVisit(c4::csubstr msg,
55+
const ryml::ErrorDataVisit &errdata,
56+
void * /*user_data*/)
57+
{
58+
DocumentNodeLocation loc;
59+
loc.offset = errdata.cpploc.offset;
60+
loc.line = errdata.cpploc.line;
61+
loc.col = errdata.cpploc.col;
62+
loc.filename = std::string(errdata.cpploc.name.str, errdata.cpploc.name.len);
63+
64+
// If rapidyaml fails internally, we declare the yaml document invalid.
65+
throw InvalidSchemaException(loc, std::string(msg.str, msg.len));
66+
}
67+
68+
#else
69+
[[noreturn]] static void OnError(const char *msg,
70+
size_t msg_len,
71+
ryml::Location location,
72+
void * /*user_data*/)
3473
{
3574
DocumentNodeLocation loc;
3675
loc.offset = location.offset;
@@ -40,11 +79,23 @@ void RymlDocument::OnError(const char *msg,
4079

4180
throw InvalidSchemaException(loc, std::string(msg, msg_len));
4281
}
82+
#endif
4383

84+
// Custom ryml error callback that throws instead of calling abort().
85+
// This ensures the try-catch in ParseDocument works regardless of how
86+
// ryml was compiled (with or without RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS).
4487
ryml::Callbacks RymlDocument::MakeCallbacks()
4588
{
4689
ryml::Callbacks cb = ryml::get_callbacks();
47-
cb.m_error = &RymlDocument::OnError;
90+
#if RYML_VERSION_MINOR >= 11
91+
// Starting with rapidyaml 0.11.0
92+
cb.m_error_basic = OnErrorBasic;
93+
cb.m_error_parse = OnErrorParse;
94+
cb.m_error_visit = OnErrorVisit;
95+
#else
96+
// Up to rapidyaml 0.10.0
97+
cb.m_error = OnError;
98+
#endif
4899
return cb;
49100
}
50101

‎third_party_release‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ nlohmann-json=v3.12.0
2525
opentelemetry-proto=v1.10.0
2626
opentracing-cpp=v1.6.0
2727
prometheus-cpp=v1.3.0
28-
ryml=v0.10.0
28+
ryml=v0.12.1

0 commit comments

Comments
 (0)