Skip to content
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

is_valid is currently a method on the SpanContext, the spec defines it as a bool flag #996

Closed
codeboten opened this issue Aug 17, 2020 · 5 comments · Fixed by #1005
Closed
Labels
api Affects the API package. good first issue Good first issue help wanted release:required-for-ga To be resolved before GA release

Comments

@codeboten
Copy link
Contributor

To be compliant with the tracing spec, we need a is_valid to be a boolean flag rather than a method on the SpanContext

https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#spancontext

@codeboten codeboten added good first issue Good first issue api Affects the API package. help wanted release:required-for-ga To be resolved before GA release labels Aug 17, 2020
@ffe4
Copy link
Contributor

ffe4 commented Aug 17, 2020

In the linked document it is simply described as "an API that returns a boolean value [...]". What would be the difference between a flag and a method here? Should it simply be defined as an attribute during instantiation, as is the case with is_remote?

@codeboten
Copy link
Contributor Author

codeboten commented Aug 17, 2020

@ffe4 right, the discrepancy between is_remote and is_valid is what I meant to address with this issue, as they're defined in the spec as the same thing, but they're implemented differently.

@lzchen
Copy link
Contributor

lzchen commented Aug 18, 2020

@codeboten
@ffe4

Actually I would think "returns" indicates that it is a method. So instead of changing is_valid into a property, I would think we should change is_remote to a function. Java seems to be taking this approach.

@ffe4
Copy link
Contributor

ffe4 commented Aug 18, 2020

@lzchen In Java they also use getter methods, so using a method might be more natural. However, Go and Ruby also seem to use methods.

We can also have them as properties, with the same semantics but an actual "return". In that sense, I think having them as data attributes / properties would be more flexible.

Another thought might be to have the same semantics everywhere in the codebase, but while Status.is_ok is a property, Span.is_recording_events is a method. Also see specification for IsRecording and GetIsOk.

I feel like properties are more idiomatic for boolean flags, but that might just be because of the libraries I'm using (e.g. requests)

@ffe4
Copy link
Contributor

ffe4 commented Aug 18, 2020

Another note while we are on the topic of wording. The specification explicitly uses flag for TraceFlags.sampled, SpanContext.IsRemote and Span.IsRecording, but not for SpanContext.IsValid. The former two have similar semantics, being a property and a data attribute respectively, while the latter two are both methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the API package. good first issue Good first issue help wanted release:required-for-ga To be resolved before GA release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants