async-http-client icon indicating copy to clipboard operation
async-http-client copied to clipboard

Trace HTTPClient request execution

Open slashmo opened this issue 5 years ago • 16 comments

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:

  • [x] Propagate service context to server via HTTP request headers
  • [x] 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

slashmo avatar Dec 05 '20 17:12 slashmo

Can one of the admins verify this patch?

swift-server-bot avatar Dec 05 '20 17:12 swift-server-bot

Can one of the admins verify this patch?

swift-server-bot avatar Dec 05 '20 17:12 swift-server-bot

Can one of the admins verify this patch?

swift-server-bot avatar Dec 05 '20 17:12 swift-server-bot

Can one of the admins verify this patch?

swift-server-bot avatar Dec 05 '20 17:12 swift-server-bot

Can one of the admins verify this patch?

swift-server-bot avatar Dec 05 '20 17:12 swift-server-bot

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 avatar Dec 05 '20 17:12 slashmo

@swift-server-bot add to whitelist

Lukasa avatar Dec 08 '20 09:12 Lukasa

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

Lukasa avatar Dec 08 '20 09:12 Lukasa

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.

slashmo avatar Dec 08 '20 09:12 slashmo

I've opened up the tracing-development branch.

Lukasa avatar Dec 08 '20 09:12 Lukasa

@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)

slashmo avatar Dec 08 '20 09:12 slashmo

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

ktoso avatar Dec 08 '20 09:12 ktoso

0.1.1. tagged, please depend on that.

Thanks Cory for the development branch, sounds good 👍

ktoso avatar Dec 08 '20 10:12 ktoso

@swift-server-bot test this please

ktoso avatar Dec 08 '20 10:12 ktoso

Can drafts get CI validation? 🤔

ktoso avatar Dec 08 '20 10:12 ktoso

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

Lukasa avatar Dec 08 '20 11:12 Lukasa