opentelemetry-js
opentelemetry-js copied to clipboard
Consider adding optional fields and functions in Interfaces to avoid breaking changes in minor version updates
We use opentelemetry-js in some of our projects and have a small implementation of the Span interface to be used in our unit tests. With the release of api v1.9 the Span interface contains additional non-optional fields/functions addLink and addLinks: https://github.com/open-telemetry/opentelemetry-js/pull/4528 . This broke our implementation of the interface.
While I can part of understand the reasoning stated in https://github.com/open-telemetry/opentelemetry-specification/blob/a03382ada8afa9415266a84dafac0510ec8c160f/specification/upgrading.md?plain=1#L97-L122 I would like to point out that it is possible to define optional fields/functions in interfaces. This can e.g. be used to add new logic in minor versions without breaking existing implementations and set the field/function to required in the next major version. This might come with a small drawback of a check like 'addLink' in span to ensure the function exists before calling it.
- [x] This only affects the JavaScript OpenTelemetry library
- [ ] This may affect other libraries, but I would like to get opinions here first