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

SpanBuilderShim: set span attribute before starting a span #3962

Closed
shawnsong opened this issue Dec 7, 2021 · 0 comments · Fixed by #3984
Closed

SpanBuilderShim: set span attribute before starting a span #3962

shawnsong opened this issue Dec 7, 2021 · 0 comments · Fixed by #3984
Assignees
Labels
Feature Request Suggest an idea for this project

Comments

@shawnsong
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In OpenTracing, we can elevate a trace's importance by adding a sampling.priority tag to a span. This doesn't seem to be supported in the opentracing-shim library. SpanBuilderShim starts a Span before its attributes are copied. This would cause the sampling decision to be made without considering the value of sampling.priority.

Describe the solution you'd like
Is it possible to copy the attributes/tags before starting a Span so we can have our own Sampler implementation which can respect the value of sampling.priority?

...

for (int i = 0; i < this.spanBuilderAttributeKeys.size(); i++) {
  AttributeKey key = this.spanBuilderAttributeKeys.get(i);
  Object value = this.spanBuilderAttributeValues.get(i);
  builder.setAttribute(key, value);
}

io.opentelemetry.api.trace.Span span = builder.startSpan();

if (error) {
  span.setStatus(StatusCode.ERROR);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Suggest an idea for this project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants