Skip to content

Instantly share code, notes, and snippets.

@mgax
Created October 24, 2018 16:46
Show Gist options
  • Save mgax/26fc2a4727f1f813f06368edb05d927a to your computer and use it in GitHub Desktop.
Save mgax/26fc2a4727f1f813f06368edb05d927a to your computer and use it in GitHub Desktop.
import * as LibhoneyEventAPI from 'honeycomb-beeline/lib/api/libhoney'; // tslint:disable-line no-submodule-imports
import * as tracker from 'honeycomb-beeline/lib/async_tracker'; // tslint:disable-line no-submodule-imports
shimmer.wrap(LibhoneyEventAPI.prototype, 'startSpan', original => function () {
const eventPayload = original.apply(this, arguments);
const context = tracker.getTracked();
if (context.stack.length > 1) context.stack.pop();
return eventPayload;
});
shimmer.wrap(LibhoneyEventAPI.prototype, 'finishSpan', original => function () {
const ev = arguments[0];
const context = tracker.getTracked();
context.stack.push(ev);
return original.apply(this, arguments);
});
shimmer.wrap(LibhoneyEventAPI.prototype, 'finishTrace', original => function () {
const context = tracker.getTracked();
context.stack.pop();
return original.apply(this, arguments);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment