-
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
Should Tracer#WithSpan
take options?
#149
Comments
I support the idea in principle, but it feels like it clutters the API too, because you'll have to write a
|
@jmacd You don't have to create a slice to pass var args. WithSpan could be: WithSpan(
ctx context.Context,
operation string,
body func(ctx context.Context) error,
opts ...Option,
) error |
This would also make it symmetric to NewHandler and the like. |
I think placing the variable length args after the function destroys
readability.
…On Tue, Oct 8, 2019 at 6:18 PM Edward Muller ***@***.***> wrote:
This would also make it symmetric to NewHandler
<https://godoc.org/go.opentelemetry.io/plugin/othttp#NewHandler> and the
like.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#149?email_source=notifications&email_token=AA3WFCJ25IQHIV4HUHLQBRDQNUWMRA5CNFSM4I25NOE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAWE4PI#issuecomment-539774525>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3WFCLMHYGWYZGRBKAGHV3QNUWMRANCNFSM4I25NOEQ>
.
|
It's not great, but IMO, it is better than the odd chaining thing. return trace.WithSpan(ctx,"op",
func(c context.Context) error {
...
},
trace.WithMore(...),trace.WithHere(...),
) Additionally, adding the variable options at the end is compatible with the existing signature. |
It's not bad, I agree. I support this. It's a bit of a "buried lede", where potentially most important information is a distance away from the start of the statement. I'd accompany this with a recommendation to avoid lengthy in-line |
Just throwing another idea, what if we change this a little bit and do something like: return trace.WithSpan(ctx,"op", trace.WithMore(...),trace.WithHere(...))
.Do(func(c context.Context) error {
...
}) |
I like that. |
What happens if |
Having a hard time thinking of a good name for the intermediate type returned by edit: I'm not liking this ideia anymore, please ignore.
|
I think that We could create the span when the |
That is one problem with chaining in that way. As for a type name: Given that |
Any more thoughts on this? It seems like the trailing varargs is most straightforward. |
🤷♂ Sure! |
Let's go with trailing varargs. |
No description provided.
The text was updated successfully, but these errors were encountered: