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

add WithSpanKind option to span creation #234

Merged
merged 7 commits into from
Oct 23, 2019
Merged

add WithSpanKind option to span creation #234

merged 7 commits into from
Oct 23, 2019

Conversation

paivagustavo
Copy link
Member

This updates the trace api with SpanKind spec. Closes #233

Copy link
Contributor

@rghetia rghetia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

api/trace/api.go Outdated
@@ -137,13 +138,25 @@ type Link struct {
Attributes []core.KeyValue
}

// SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span
// will be processed and visualized by various backends.
type SpanKind int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to make this type string. For the instances below, use the conventional name "server", "client", ...

I suggest this because in OpenTracing, instead of an explicit field in the span structure, a span.kind attribute was specified. In an OpenTracing bridge, we can just use SpanKind(value) and won't have to construct an explicit switch statement.

I think it's an added benefit that users can specify unconventional span kinds as well, although some will disagree. I see this value as an advisory statement, helpful to vendors, but we shouldn't force all span kinds to be one of these four values.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the bullet here and changed it to string and implemented the bridge for SpanKind. I think this is fine for now, but we should go to specs to clarify the behavior of the SpanKind, java implementation is an Enum and only accept the values on the spec and any other value goes to internal.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. 😄
I think we should do it, and I'll agree to back this up by filing an issue in the spec repo, sometime this week.

@paivagustavo paivagustavo requested a review from jmacd October 23, 2019 02:57
Copy link
Member

@krnowak krnowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits.

experimental/bridge/opentracing/mix_test.go Outdated Show resolved Hide resolved
exporter/trace/stdout/stdout_test.go Outdated Show resolved Hide resolved
for _, sk := range sks {
var te testExporter
tp, _ := NewProvider(WithSyncer(&te), WithConfig(Config{DefaultSampler: AlwaysSample()}))
tr := tp.GetTracer("withSpanKind")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reuse the exporter, provider and tracer from the outer scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the endSpan method created a testExporter and used it to process a single span. But with the changes of the Provider, it started to receive the testExporter as a parameter, and it expected that we got exactly one span on the exporter, that why we should not reuse it.

There is a simpler way to do this, just reset the span list of the testExporter.

@jmacd
Copy link
Contributor

jmacd commented Oct 24, 2019

@paivagustavo See open-telemetry/opentelemetry-specification#337

@paivagustavo paivagustavo deleted the with-span-kind branch October 24, 2019 21:38
@pellared pellared added this to the untracked milestone Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SpanKind option to Span Creation
5 participants