-
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
Move the Event type from the API to the SDK #1845
Comments
What do you think about creating a That seems to resolve both problems. |
Ah, yeah, thanks for pointing that out. I forgot to include it. I had initially discarded this solution because it would mean we would have an option for an option. This seemed excessive to me, but I'm open to hear if that is a shared sentiment. |
Could you explain more about that? Do you mean that we would end up writing |
So
|
Would we even need a func WithLink(sc SpanContext, attrs attribute.KeyValue...) linkSpanOption {...} The invocation at tracer.Start("name", WithLink(spancontext, attrs...)), WithAttributes(/* ... */)) |
One of the things I was thinking with this approach is if the specification wanted to add something like a "type" to track the specific types of links it would be a breaking change to try and include something like that. |
We could work around that with a new |
That seems like a valid approach if we need to extend in the future, I'm not opposed to this approach either. |
Decision from the Go SIG meeting is to go with replacing func WithLink(sc SpanContext, attrs ...attribute.KeyValue) SpanOption {...} |
One thing I missed is the opentelemetry-go/trace/config.go Line 56 in 08f4c27
I'm second guessing if we can move this type completely out of the API without just replacing it with an anonymous struct. |
Hmm, can we even do that? Wouldn't an SDK need to be able to use the |
Agreed. |
Currently the API exports an
Event
type:opentelemetry-go/trace/trace.go
Lines 542 to 556 in ca130e5
This type is not used in the API, it is used in the trace SDK and those values of this type that it creates are passed down the processing pipeline. It does not make sense to have this type exported from the API. It should be included in the package that actually uses it, the trace SDK.
What about the API asymmetry between the Link and Event?
The following is mostly added to capture the though process that went into the decision to not move the
Link
type as well and is included for transparency and future understanding of the decision.It seems wrong to move this type without also moving the
Link
type also declared in the API. This cannot be done though because theLink
type is directly used in the API by being passed to theWithLinks
SpanOption
.opentelemetry-go/trace/config.go
Lines 160 to 164 in ca130e5
This exposes an underlying asymmetry issue between the argument structure of functions in the API. The methods that create a span event accept the component parts of the event as arguments, but the function to create a span link accepts the composite
struct
type itself. This is the only part of the API where we use an underlyingstruct
type to pass configuration state as an argument instead of functional options.Possible Solutions
1) Move
Event
andLink
type to SDK and updateWithLinks
SpanOption
Event
type to theotel/sdk/trace
package.Link
type to theotel/sdk/trace
package.WithLinks
SpanOption
.WithLink
SpanOption
to theotel/trace
package. E.g.Pros:
Cons:
2) Move the
Event
type to SDK, but leave theLink
typeEvent
type to theotel/sdk/trace
package.Pros:
Cons:
3) Update the
AddEvent
method of the"otel/trace".Span
interface to accept theEvent
type instead ofEventOption
s."otel/trace".Span
interfaceAddEvent
method to accept theEvent
type instead ofEventOption
sPros:
Event
andLink
functionsCons:
RecordError
method, which creates an event, should be updated (or not) to support thisProposed Solution
Move the
Event
type to SDK, but leave theLink
type.The text was updated successfully, but these errors were encountered: