trace-event.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * trace-event - A library to create a trace of your node app per
  3. * Google's Trace Event format:
  4. * // JSSTYLED
  5. * https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
  6. */
  7. /// <reference types="node" />
  8. import { Readable as ReadableStream } from "stream";
  9. export interface Event {
  10. ts: number;
  11. pid: number;
  12. tid: number;
  13. /** event phase */
  14. ph?: string;
  15. [otherData: string]: any;
  16. }
  17. export interface Fields {
  18. cat?: any;
  19. args?: any;
  20. [filedName: string]: any;
  21. }
  22. export interface TracerOptions {
  23. parent?: Tracer | null;
  24. fields?: Fields | null;
  25. objectMode?: boolean | null;
  26. noStream?: boolean;
  27. }
  28. export declare class Tracer extends ReadableStream {
  29. private _objectMode;
  30. /** Node Stream internal APIs */
  31. private _push;
  32. private firstPush?;
  33. private noStream;
  34. private events;
  35. private parent;
  36. private fields;
  37. constructor(opts?: TracerOptions);
  38. /**
  39. * If in no streamMode in order to flush out the trace
  40. * you need to call flush.
  41. */
  42. flush(): void;
  43. _read(_: number): void;
  44. private _pushString;
  45. private _flush;
  46. child(fields: Fields): Tracer;
  47. begin(fields: Fields): void;
  48. end(fields: Fields): void;
  49. completeEvent(fields: Fields): void;
  50. instantEvent(fields: Fields): void;
  51. mkEventFunc(ph: string): (fields: Fields) => void;
  52. }