Skip to content

Commit

Permalink
Continue doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Jul 10, 2023
1 parent 59947f2 commit 31f4288
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion docs/abi-version-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<opentelemetry::metrics::Meter> 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<opentelemetry::metrics::Meter> 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<metrics_api::Meter> 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 */
}
```

0 comments on commit 31f4288

Please sign in to comment.