Skip to content

Instantly share code, notes, and snippets.

@joekiller
Last active May 30, 2017 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joekiller/f6b5fe40da4b8b6b1949b54ff2bf124f to your computer and use it in GitHub Desktop.
Save joekiller/f6b5fe40da4b8b6b1949b54ff2bf124f to your computer and use it in GitHub Desktop.
Minimal Clojurescript aws x-ray lambda cljs-lambda

The basics here are to make sure you include the externs for advanced compliation and then to wrap the S3 client with an AWSXray capture client.

(def S3 (nodejs/require "aws-sdk/clients/s3"))
(def s3-client (S3. (clj->js {:httpOptions {:timeout 10000}})))

vs

(def S3 (nodejs/require "aws-sdk/clients/s3"))
(def AWSXRay (nodejs/require "aws-xray-sdk"))
(def s3-client (.captureAWSClient AWSXRay (S3. (clj->js {:httpOptions {:timeout 10000}}))))

References:

  1. https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-awssdkclients.html
  2. https://github.com/cljsjs/packages/wiki/Creating-Externs
(defproject ...
:npm {:dependencies
[[aws-sdk "2.7.15"]
[aws-xray-sdk "1.1.1"]]}
:cljsbuild
{:builds [{:id "prod"
:compiler {...
:externs ["xray.js"]
:optimizations :advanced}}]})
/** @interface */
function AWSXRay() {}
AWSXRay.prototype.captureAWSClient = function() {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment