mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
[node] add trace_events type definitions
This commit is contained in:
Vendored
+62
@@ -9008,3 +9008,65 @@ declare module "perf_hooks" {
|
||||
|
||||
const performance: Performance;
|
||||
}
|
||||
|
||||
declare module "trace_events" {
|
||||
/**
|
||||
* The `Tracing` object is used to enable or disable tracing for sets of
|
||||
* categories. Instances are created using the
|
||||
* `trace_events.createTracing()` method.
|
||||
*
|
||||
* When created, the `Tracing` object is disabled. Calling the
|
||||
* `tracing.enable()` method adds the categories to the set of enabled trace
|
||||
* event categories. Calling `tracing.disable()` will remove the categories
|
||||
* from the set of enabled trace event categories.
|
||||
*/
|
||||
export interface Tracing {
|
||||
/**
|
||||
* A comma-separated list of the trace event categories covered by this
|
||||
* `Tracing` object.
|
||||
*/
|
||||
readonly categories: string;
|
||||
|
||||
/**
|
||||
* Disables this `Tracing` object.
|
||||
*
|
||||
* Only trace event categories _not_ covered by other enabled `Tracing`
|
||||
* objects and _not_ specified by the `--trace-event-categories` flag
|
||||
* will be disabled.
|
||||
*/
|
||||
disable(): void;
|
||||
|
||||
/**
|
||||
* Enables this `Tracing` object for the set of categories covered by
|
||||
* the `Tracing` object.
|
||||
*/
|
||||
enable(): void;
|
||||
|
||||
/**
|
||||
* `true` only if the `Tracing` object has been enabled.
|
||||
*/
|
||||
readonly enabled: boolean;
|
||||
}
|
||||
|
||||
interface CreateTracingOptions {
|
||||
/**
|
||||
* An array of trace category names. Values included in the array are
|
||||
* coerced to a string when possible. An error will be thrown if the
|
||||
* value cannot be coerced.
|
||||
*/
|
||||
categories: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a Tracing object for the given set of categories.
|
||||
*/
|
||||
export function createTracing(options: CreateTracingOptions): Tracing;
|
||||
|
||||
/**
|
||||
* Returns a comma-separated list of all currently-enabled trace event
|
||||
* categories. The current set of enabled trace event categories is
|
||||
* determined by the union of all currently-enabled `Tracing` objects and
|
||||
* any categories enabled using the `--trace-event-categories` flag.
|
||||
*/
|
||||
export function getEnabledCategories(): string;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import * as async_hooks from "async_hooks";
|
||||
import * as http2 from "http2";
|
||||
import * as inspector from "inspector";
|
||||
import * as perf_hooks from "perf_hooks";
|
||||
import * as trace_events from "trace_events";
|
||||
import Module = require("module");
|
||||
|
||||
// Specifically test buffer module regression.
|
||||
@@ -4676,6 +4677,19 @@ import * as constants from 'constants';
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
/// Trace Events Tests ///
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
const enabledCategories: string = trace_events.getEnabledCategories();
|
||||
const tracing: trace_events.Tracing = trace_events.createTracing({ categories: ['node', 'v8'] });
|
||||
const categories: string = tracing.categories;
|
||||
const enabled: boolean = tracing.enabled;
|
||||
tracing.enable();
|
||||
tracing.disable();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// module tests : http://nodejs.org/api/modules.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user