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

Trace HTTPClient request execution #320

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

slashmo
Copy link

@slashmo slashmo commented Dec 5, 2020

Motivation:

Context Propagation

In order to instrument distributed systems, metadata such as trace ids
must be propagated across network boundaries through HTTP headers.
As HTTPClient operates at one such boundary, it should take care of
injecting metadata into HTTP headers automatically using the configured
instrument.

Built-in tracing

Furthermore, HTTPClient should create a Span for executed requests
under the hood, so that users benefit from tracing effortlessly.

Modifications:

  • Propagate service context to server via HTTP request headers
  • Create Span for executed HTTP request

Result:

  • AsyncHTTPClient automatically creates a Distributed Tracing span per request
  • AsyncHTTPClient propagates service context to server, making server spans children of client spans

@swift-server-bot
Copy link

Can one of the admins verify this patch?

4 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@slashmo
Copy link
Author

slashmo commented Dec 5, 2020

I chatted with @ktoso earlier to discuss the manual context propagation, and we agreed that we probably shouldn't deprecate the "old" API accepting a Logger for each request overload, as we don't want to push users too much into the direction of manual context passing because that's ideally not necessary once the mentioned language changes have been made: https://github.com/apple/swift-distributed-tracing#important-note-on-adoption

@slashmo slashmo marked this pull request as draft December 5, 2020 17:11
Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

So since technically we're 0.1 and something may change... how do we want to tackle adoption here.

I was thinking to kick off a branch like tracing for now, so we can polish up there and once we're all confident merge into mainline? We could also tag those tracing releases, they'd follow normal releases e.g. 1.2.2-tracing.

I don't really expect anything breaking in the core APIs but the open telemetry support which we may want to use here could still fluctuate a little bit until they're final hmmm...

Sources/AsyncHTTPClient/HTTPHeadersInjector.swift Outdated Show resolved Hide resolved
Sources/AsyncHTTPClient/HTTPClient.swift Outdated Show resolved Hide resolved
Package.swift Outdated
],
targets: [
.target(
name: "AsyncHTTPClient",
dependencies: ["NIO", "NIOHTTP1", "NIOSSL", "NIOConcurrencyHelpers", "NIOHTTPCompression",
"NIOFoundationCompat", "NIOTransportServices", "Logging"]
"NIOFoundationCompat", "NIOTransportServices", "Logging", "Instrumentation"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we right away go with Tracing and do the full thing in a single PR?

Copy link
Author

Choose a reason for hiding this comment

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

That's my intention. I've added a checklist to the PR including creating a Span. I first wanted to get the instrumentation part down and then continue with tracing, but all inside this PR.

@slashmo slashmo force-pushed the feature/tracing branch 2 times, most recently from 047fbb0 to 87085d9 Compare December 7, 2020 17:05
@Lukasa
Copy link
Collaborator

Lukasa commented Dec 8, 2020

@swift-server-bot add to whitelist

@Lukasa
Copy link
Collaborator

Lukasa commented Dec 8, 2020

I'd like to punt this to a side-branch for iterative development if we can.

@slashmo
Copy link
Author

slashmo commented Dec 8, 2020

I'd like to punt this to a side-branch for iterative development if we can.
@Lukasa

Sure, sounds like a good approach. I can change the target branch once it's created.

@Lukasa
Copy link
Collaborator

Lukasa commented Dec 8, 2020

I've opened up the tracing-development branch.

@slashmo slashmo changed the base branch from main to tracing-development December 8, 2020 09:21
@slashmo
Copy link
Author

slashmo commented Dec 8, 2020

@ktoso The CI seems to fail because the Baggage repo cannot be cloned through the Git URL. Should we pin Tracing to 0.1.1 here in order to get the fix? (apple/swift-distributed-tracing/pull/25)

@ktoso
Copy link
Contributor

ktoso commented Dec 8, 2020

No, we need to tag a 0.1.1, I'll do that in a moment.

@ktoso
Copy link
Contributor

ktoso commented Dec 8, 2020

0.1.1. tagged, please depend on that.

Thanks Cory for the development branch, sounds good 👍

@ktoso
Copy link
Contributor

ktoso commented Dec 8, 2020

@swift-server-bot test this please

@ktoso
Copy link
Contributor

ktoso commented Dec 8, 2020

Can drafts get CI validation? 🤔

@Lukasa
Copy link
Collaborator

Lukasa commented Dec 8, 2020

Yes, they can: I think the CI isn't targeting that branch at the moment.

@slashmo slashmo changed the base branch from tracing-development to main December 30, 2024 21:32
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