Skip to content

[o11y] Add rudimentary user tracing support for connect() #3089

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

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

fhanau
Copy link
Contributor

@fhanau fhanau commented Nov 11, 2024

  • Use more descriptive name for IOContext function

@fhanau fhanau requested a review from mikea November 11, 2024 15:38
@fhanau fhanau marked this pull request as ready for review November 11, 2024 15:38
@fhanau fhanau requested review from a team as code owners November 11, 2024 15:38
@fhanau fhanau requested a review from a-robinson November 11, 2024 15:38
@@ -180,6 +180,7 @@ jsg::Ref<Socket> connectImplNoOutputLock(jsg::Lock& js,

auto& ioContext = IoContext::current();
JSG_REQUIRE(!ioContext.isFiddle(), TypeError, "Socket API not supported in web preview mode.");
ioContext.makeUserTraceSpan("connect"_kjc);
Copy link
Member

Choose a reason for hiding this comment

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

I imagine it's intentional that we're dropping the return value immediately and not measuring anything about the duration of the connect?

It looks a little funny, but so long as it's by design the code LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right – we want the span to exist for the entire duration of the function, and I guess if no variable is declared for it, it goes out of scope immediately instead of at the end of the function. In some other cases we need to assign the returned span so that we can extend its lifetime for async I/O or to create subspans, but I guess this is still needed here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mikea would this make makeUserTraceSpan() and similarly SpanBuilder::newChild() good candidates for adding the [[nodiscard]] to avoid this mistake in the future?

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like [[nodiscard]] is a must for them.

- Use more descriptive name for IOContext function
@fhanau fhanau force-pushed the felix/user-tracing-connect branch from f1e8ab1 to cf6cf6e Compare November 11, 2024 18:59
If newly created spans are immediately discarded, they will not be able
to capture the run time of the underlying operation.
@fhanau fhanau merged commit f117326 into main Nov 12, 2024
14 checks passed
@fhanau fhanau deleted the felix/user-tracing-connect branch November 12, 2024 18:49
danlapid pushed a commit that referenced this pull request Dec 3, 2024
* [o11y] Add rudimentary user tracing support for connect()

- Use more descriptive name for IOContext function

* Add [[nodiscard]] attribute to span creation functions

If newly created spans are immediately discarded, they will not be able
to capture the run time of the underlying operation.
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.

4 participants