@@ -24,26 +24,6 @@ export type CLSMechanism =
2424
2525/** Available configuration options. */
2626export interface Config {
27- /**
28- * The trace context propagation mechanism to use. The following options are
29- * available:
30- * - 'async-hooks' uses an implementation of CLS on top of the Node core
31- * `async_hooks` module in Node 8+. This option should not be used if the
32- * Node binary version requirements are not met.
33- * - 'async-listener' uses an implementation of CLS on top of the
34- * `continuation-local-storage` module.
35- * - 'auto' behaves like 'async-hooks' on Node 8+, and 'async-listener'
36- * otherwise.
37- * - 'none' disables CLS completely.
38- * - 'singular' allows one root span to exist at a time. This option is meant
39- * to be used internally by Google Cloud Functions, or in any other
40- * environment where it is guaranteed that only one request is being served
41- * at a time.
42- * The 'auto' mechanism is used by default if this configuration option is
43- * not explicitly set.
44- */
45- clsMechanism ?: CLSMechanism ;
46-
4727 /**
4828 * Log levels: 0=disabled, 1=error, 2=warn, 3=info, 4=debug
4929 * The value of GCLOUD_TRACE_LOGLEVEL takes precedence over this value.
@@ -70,6 +50,43 @@ export interface Config {
7050 */
7151 rootSpanNameOverride ?: string | ( ( name : string ) => string ) ;
7252
53+ /**
54+ * The trace context propagation mechanism to use. The following options are
55+ * available:
56+ * - 'async-hooks' uses an implementation of CLS on top of the Node core
57+ * `async_hooks` module in Node 8+. This option should not be used if the
58+ * Node binary version requirements are not met.
59+ * - 'async-listener' uses an implementation of CLS on top of the
60+ * `continuation-local-storage` module.
61+ * - 'auto' behaves like 'async-hooks' on Node 8+, and 'async-listener'
62+ * otherwise.
63+ * - 'none' disables CLS completely.
64+ * - 'singular' allows one root span to exist at a time. This option is meant
65+ * to be used internally by Google Cloud Functions, or in any other
66+ * environment where it is guaranteed that only one request is being served
67+ * at a time.
68+ * The 'auto' mechanism is used by default if this configuration option is
69+ * not explicitly set.
70+ */
71+ clsMechanism ?: CLSMechanism ;
72+
73+ /**
74+ * The number of local spans per trace to allow before emitting an error log.
75+ * An unexpectedly large number of spans per trace may suggest a memory leak.
76+ * This value should be 1-2x the estimated maximum number of RPCs made on
77+ * behalf of a single incoming request.
78+ */
79+ spansPerTraceSoftLimit ?: number ;
80+
81+ /**
82+ * The maximum number of local spans per trace to allow in total. Creating
83+ * more spans in a single trace will cause the agent to log an error, and such
84+ * spans will be dropped. (This limit does not apply when using a RootSpan
85+ * instance to create child spans.)
86+ * This value should be greater than spansPerTraceSoftLimit.
87+ */
88+ spansPerTraceHardLimit ?: number ;
89+
7390 /**
7491 * The maximum number of characters reported on a label value. This value
7592 * cannot exceed 16383, the maximum value accepted by the service.
@@ -197,11 +214,13 @@ export interface Config {
197214 * user-provided value will be used to extend the default value.
198215 */
199216export const defaultConfig = {
200- clsMechanism : 'auto' as CLSMechanism ,
201217 logLevel : 1 ,
202218 enabled : true ,
203219 enhancedDatabaseReporting : false ,
204220 rootSpanNameOverride : ( name : string ) => name ,
221+ clsMechanism : 'auto' as CLSMechanism ,
222+ spansPerTraceSoftLimit : 200 ,
223+ spansPerTraceHardLimit : 1000 ,
205224 maximumLabelValueSize : 512 ,
206225 plugins : {
207226 // enable all by default
0 commit comments