gsoc-swift-tracing icon indicating copy to clipboard operation
gsoc-swift-tracing copied to clipboard

Add Swift Lambda Runtime (and XRay) use case

Open slashmo opened this issue 5 years ago • 7 comments

One interesting use case for us could be the AWS Lambda Runtime. I can imagine an example where some processing happens in a Lambda that adds to a BaggageContext. (Once we get to this use case we can come up with a more specific plan on what to do)

slashmo avatar Jun 18 '20 08:06 slashmo

Yup! It should be very simple to adopt it in the Lambda lib.

FYI @fabianfett @tomerd

ktoso avatar Jun 18 '20 09:06 ktoso

Just looked up the XRay tracing deamons api. Looks like it is just JSON over UDP. https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-daemon

To get it into JSON without using Foundation this might be a good starting point: https://github.com/fabianfett/swift-log-json-to-std/blob/affbe225cbd5bf22c3d4943f48edada5c9cbdbff/Sources/LoggingJSONToSTD/JSONLogHandler.swift#L115

@slashmo @ktoso I sadly haven't followed the two off you to closely... Is there already a protocol to implement for Tracing Backends?

JSON over UDP sounds like a fun challenge for me. I haven't set up a channel pipeline yet, but this sounds like a good first time.

fabianfett avatar Jun 18 '20 09:06 fabianfett

Just looked up the XRay tracing deamons api. Looks like it is just JSON over UDP. https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-daemon

Cool, very nice that it's so simple.

Is there already a protocol to implement for Tracing Backends?

It's a bit to early to point at specifics, but yes there will be. Today we only have instruments which are about extracting/injecting metadata into a baggage context object (i.e. from headers -> baggage -> outgoing headers when making requests); We don't have the Tracer "shape" yet.

I guess there's a difference between "lambda lib uses baggage context" and "there is an XRay tracing backend" :-) This was more about the prior, but yes the latter will be a goal as well eventually!

No action required from you, just FYI that we're looking at the Lambda lib as one of the use cases :)

ktoso avatar Jun 18 '20 09:06 ktoso

For future reference XRay's Segment Design: https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html

fabianfett avatar Jun 18 '20 09:06 fabianfett

JSON over UDP sounds like a fun challenge for me. I haven't set up a channel pipeline yet, but this sounds like a good first time.

@fabianfett we done some similar work in https://github.com/apple/swift-statsd-client maybe some inspiration there

tomerd avatar Jun 18 '20 19:06 tomerd

Hi all,

I implemented XRay Recorder for Swift: https://github.com/pokryfka/aws-xray-sdk-swift

I do use XRay tracing in Lambdas a lot and was lacking that when "Messing with Swift AWS Lambda Runtime".

Following up this project, happy to help with XRay client testing/implementation when protocols for Tracing Backends are defined.

BTW, for my "lambda purposes" I send all the segments via HTTP (using PutTraceSegments API) or UDP, just once at the end of each lambda event processing.

pokryfka avatar Jun 25 '20 13:06 pokryfka

That's awesome, thanks for reaching out! I expect we'll get some initial shapes of tracer instrument protocols very soon -- will ping here so you can try them out as well, thanks!

ktoso avatar Jun 25 '20 13:06 ktoso