From 31f428875ca8b236f5941fe747284939d2431da7 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 10 Jul 2023 21:34:46 +0200 Subject: [PATCH] Continue doc. --- docs/abi-version-policy.md | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/abi-version-policy.md b/docs/abi-version-policy.md index c19a7988ae..438e93d230 100644 --- a/docs/abi-version-policy.md +++ b/docs/abi-version-policy.md @@ -458,13 +458,63 @@ public: nostd::string_view library_version = "", nostd::string_view schema_url = "") noexcept = 0; #endif + + /* ... */ }; ``` +Note how the ABI changes, while the API stays compatible, requiring no code +change in the caller when providing up to 3 parameters. + #### SDK change -TODO +In the SDK class declaration, implement the expected API. + +``` +class MeterProvider final : public opentelemetry::metrics::MeterProvider +{ +public: + + /* ... */ + +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + nostd::shared_ptr GetMeter( + nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "", + const opentelemetry::common::KeyValueIterable *attributes = nullptr) noexcept override; +#else + nostd::shared_ptr GetMeter( + nostd::string_view name, + nostd::string_view version = "", + nostd::string_view schema_url = "") noexcept override; +#endif + + /* ... */ +}; +``` +In the SDK implementation: +* either get the new parameters from the extended ABI v2 method +* or provide default values for the old ABI v1 method +``` +nostd::shared_ptr MeterProvider::GetMeter( + nostd::string_view name, + nostd::string_view version, + nostd::string_view schema_url +#if OPENTELEMETRY_ABI_VERSION_NO >= 2 + , + const opentelemetry::common::KeyValueIterable *attributes +#endif + ) noexcept +{ +#if OPENTELEMETRY_ABI_VERSION_NO < 2 + const opentelemetry::common::KeyValueIterable *attributes = nullptr; +#endif + + /* common implementation, use attributes */ +} +```