-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop and implement a plan to extend interfaces #1714
Comments
This comment has been minimized.
This comment has been minimized.
Per our discussion on this week's SIG call, see the following two issues from the grpc/grpc-go project for background on a couple of pertinent techniques: |
This comment has been minimized.
This comment has been minimized.
The way I understand the groups decision on how we want to handle interface changes in the future is conditional on what should implement the interface is and how it will be used.
End-User InterfacesThese interfaces will be called by the SDK and can be user provided. Adding or changing methods for these interfaces will break user implementations and therefore MUST NOT be done. These interfaces may also be called by the user themselves. Removing methods that users call from these interface definitions will break users' code and therefore MUST NOT be done. These interfaces MUST NOT change once they are made stable. If new functionality is needed for these interfaces it MUST be added by including an additional interface. That interface can be a simple interface for the specific functionality that you want to add or it can be a super-set of the original interface. For example, if you wanted to a type Exporter interface {
Export()
} A new interface, type Closer interface {
Close()
} Code that is passed the func caller(e Exporter) {
/* ... */
if c, ok := e.(Closer); ok {
c.Close()
}
/* ... */
} Alternatively, a new type that is the super-set of an type ClosingExporter struct {
Exporter
Close()
} This new type can be used similar to the simple interface above in that a passed This super-set approach can be useful if there is explicit behavior that needs to be coupled with the original type and passed as a unified type to a new function, but, because of this coupling, it also limits the applicability of the added functionality. If there exist other interfaces where this functionality should be added, each one will need their own super-set interfaces and will duplicate the pattern. For this reason, the simple targeted interface that defines the specific functionality should be preferred. Interfaces
Internal Only Interface ImplementationsThese interfaces should be guarded from external implementations. While not perfect, this should be done using an unexported method. Interfaces
SDK Implemented InterfacesThese interfaces can only accrete, methods MUST NOT be removed or changed. Users are expected to call the methods of these interfaces. These interfaces SHOULD NOT be guarded, a build failure should occur when things are added to the interface and SDK developers have not satisfied the new methods. This is an assumed responsibility that comes with development of an SDK. The default SDK will be released in lock-step with any changes to the interfaces such that it satisfies the interface. This divergence from the standard backwards compatibility guarantee of a Go API is part of the OpenTelemetry versioning policy and is meant to provide room to evolve the OpenTelemetry specification. Interfaces
* these interfaces are also internal only implementation. |
An interesting point to consider in the already decided configuration policy is that if we instead configure by just passing a configuration struct type we would not have any "Internal Only Interface" and all code written by users could be checked by the compiler without exception. |
The specification SIG has stated that they will consider additions to API/SDK interfaces that are not expected for instrumentation or operator users of OpenTelemetry to not be backwards incompatible. In Go adding a method to an Exported interface is a breaking change.
There are a few ways we can support these changes while remaining compatible:
To resolve this we need to:
The text was updated successfully, but these errors were encountered: