Skip to content

Instantly share code, notes, and snippets.

@kobalski
Created May 31, 2019 14:57
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 kobalski/b8fcc88d1707f3d9f7c0583140fc2eb8 to your computer and use it in GitHub Desktop.
Save kobalski/b8fcc88d1707f3d9f7c0583140fc2eb8 to your computer and use it in GitHub Desktop.
let spanCounter = -1;
const HTTP_FILTER_RATIO = 2;
const thundra = require("@thundra/core")({
traceConfig: {
disableRequest: true,
disableResponse: true,
runCustomSamplerOnEachSpan: true,
sampler: {
isSampled(span) {
spanCounter++;
if (spanCounter === 0) {
return true;
}
if (span.className === 'HTTP' && spanCounter % HTTP_FILTER_RATIO !== 0) {
return true;
}
return false;
}
}
}
});
exports.handler = thundra((event, context, callback) => {
// Do not forget this line.
spanCounter = -1;
/// User code
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment