Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

is the return type of with_child_span/3 correct? #170

Open
dvic opened this issue Jun 2, 2021 · 3 comments
Open

is the return type of with_child_span/3 correct? #170

dvic opened this issue Jun 2, 2021 · 3 comments

Comments

@dvic
Copy link

dvic commented Jun 2, 2021

My understanding of Erlang is limited, but is the typespec of with_child_span/3 correct in terms of its return type (opencensus:maybe(opencensus:span_ctx())? The return type should be whatever the function returns right?

@dvic
Copy link
Author

dvic commented Jun 2, 2021

As a reference, here are the relevant lines:

-spec with_child_span(unicode:unicode_binary(), opencensus:attributes(), fun()) -> maybe(opencensus:span_ctx()).
with_child_span(Name, Attributes, Fun) ->
CurrentSpanCtx = current_span_ctx(),
NewSpanCtx = oc_trace:start_span(Name, CurrentSpanCtx, #{attributes => Attributes}),
with_span_ctx(NewSpanCtx),
try Fun()
after
oc_trace:finish_span(current_span_ctx()),
with_span_ctx(CurrentSpanCtx)
end.

@dvic
Copy link
Author

dvic commented Jun 2, 2021

Thanks, I've opened a PR, not sure if I got it right 😅

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants