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

Update Go guidance for attributes #3927

Closed
wants to merge 7 commits into from
Closed

Conversation

cartermp
Copy link
Contributor

@cartermp cartermp commented Feb 2, 2024

@cartermp cartermp requested review from a team February 2, 2024 00:00
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

This is the way for for users would like to reduce the amount of heap allocations: https://cloud-native.slack.com/archives/CJFCJHG4Q/p1706821596412959?thread_ts=1706816394.957449&cid=CJFCJHG4Q

CC @MrAlias

content/en/docs/languages/go/instrumentation.md Outdated Show resolved Hide resolved
are useful for aggregating, filtering, and grouping traces. Attributes can be
added at span creation, or at any other time during the lifecycle of a span
before it has completed.

Generally speaking, you should try to set attributes during span creation. This
will incur less overhead compared to setting attributes after span creation, and
Copy link
Member

Choose a reason for hiding this comment

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

This
will incur less overhead compared to setting attributes after span creation

^ Is this actually true? I think the answer is - it depends.!

If the sampler is ParentBased and the parent's decision is to Drop, then providing all attributes at startup time is wasted as the span is going to be dropped anyway...
If user choses to add it after span creation, he/she can avoid the cost of representing attributes completes, by short-circuiting if span is not recording.

The only reason spec recommended providing attributes at creation time is for the trace-sampler to access it, not perf. If Golang implementation makes it more performant, then this section makes sense - but I wanted to double check if that is indeed true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the justification: https://cloud-native.slack.com/archives/CJFCJHG4Q/p1706816394957449 (SetAttributes also takes a variadic argument). My question would be if the Go compiler optimizes the single value case though.

Copy link
Member

@theletterf theletterf left a comment

Choose a reason for hiding this comment

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

Some suggestions.

content/en/docs/languages/go/instrumentation.md Outdated Show resolved Hide resolved
content/en/docs/languages/go/instrumentation.md Outdated Show resolved Hide resolved
content/en/docs/languages/go/instrumentation.md Outdated Show resolved Hide resolved
Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]>
@pellared
Copy link
Member

While I have nothing against the changes I just want to point out that in my opinion the description is misleading

In service towards https://cloud-native.slack.com/archives/CJFCJHG4Q/p1706816394957449

See: #3927 (review)

@svrnm svrnm added the sig:go label Mar 5, 2024
@svrnm
Copy link
Member

svrnm commented Apr 11, 2024

@cartermp @open-telemetry/go-approvers is this PR something we want to continue?

@pellared
Copy link
Member

pellared commented Apr 11, 2024

The content and title LGTM.

However, I think that the description is not true.
More: #3927 (comment).

CC @MrAlias

@svrnm
Copy link
Member

svrnm commented Apr 15, 2024

However, I think that the description is not true. More: #3927 (comment).

@cartermp does this help you to finalize this PR?

@cartermp
Copy link
Contributor Author

gonna close this one out, it's been rather long

@cartermp cartermp closed this Jun 15, 2024
@svrnm svrnm deleted the cartermp/go-attributes branch December 9, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants