@interopio/otel 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/traces/traces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropagationInfo, PropagationInfoCarrier, TracesManager, FilteringContext, TracingState, WithSpanCallback } from "./types";
|
|
1
|
+
import { PropagationInfo, PropagationInfoCarrier, TracesManager, FilteringContext, TracingState, WithSpanCallback, WithSpanDecoratorOptions } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Null-safe singleton class that can be invoked even if you haven't initialized
|
|
4
4
|
* the library (yet?), or if you don't have access to the current manager instance.
|
|
@@ -12,16 +12,15 @@ export default class Traces {
|
|
|
12
12
|
static set currentTracingState(value: TracingState | null);
|
|
13
13
|
static removePropagationInfo(propagationInfoCarrier: PropagationInfo | PropagationInfoCarrier | null | undefined): PropagationInfo | PropagationInfoCarrier | null | undefined;
|
|
14
14
|
static extractPropagationInfo(propagationInfoCarrier: PropagationInfo | PropagationInfoCarrier | null | undefined, deleteProperty?: boolean | undefined): PropagationInfo | null;
|
|
15
|
-
static withSpan(root: string, decoratorOptions?:
|
|
16
|
-
argMapping?: {
|
|
17
|
-
[x: string]: string;
|
|
18
|
-
} | Array<string | null | undefined>;
|
|
19
|
-
thisMapping?: {
|
|
20
|
-
[x: string]: string;
|
|
21
|
-
};
|
|
22
|
-
}): Function;
|
|
15
|
+
static withSpan(root: string, decoratorOptions?: WithSpanDecoratorOptions): Function;
|
|
23
16
|
static withSpan<T>(source: string, callback: WithSpanCallback<T>): T;
|
|
24
17
|
static withSpan<T>(source: string, filteringContext: FilteringContext | null, callback: WithSpanCallback<T>): T;
|
|
25
18
|
static withSpan<T>(source: string, filteringContextOrCallback: FilteringContext | WithSpanCallback<T> | null, propagationInfoOrCallback?: PropagationInfo | PropagationInfoCarrier | WithSpanCallback<T> | null, callback?: WithSpanCallback<T>): T;
|
|
19
|
+
static withSpans<T>(tracingMap: {
|
|
20
|
+
[propertyName in (keyof T)]: ({
|
|
21
|
+
source: string;
|
|
22
|
+
decoratorOptions?: WithSpanDecoratorOptions;
|
|
23
|
+
} | string);
|
|
24
|
+
}, objectToTrace: T): T;
|
|
26
25
|
}
|
|
27
26
|
export declare const withSpan: typeof Traces.withSpan;
|
package/dist/traces/traces.js
CHANGED
|
@@ -43,23 +43,57 @@ class Traces {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
static withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, callback) {
|
|
46
|
-
// decorator
|
|
46
|
+
// decorator or wrapping a function
|
|
47
47
|
if (!(filteringContextOrCallback instanceof Function) &&
|
|
48
|
-
(!filteringContextOrCallback ||
|
|
48
|
+
(!filteringContextOrCallback ||
|
|
49
|
+
filteringContextOrCallback.argMapping ||
|
|
50
|
+
filteringContextOrCallback.thisMapping) &&
|
|
49
51
|
!propagationInfoOrCallback &&
|
|
50
52
|
!callback) {
|
|
51
53
|
return function (target, propertyKey, descriptor) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
let originalFn;
|
|
55
|
+
if (descriptor) {
|
|
56
|
+
// decorator
|
|
57
|
+
originalFn = descriptor.value;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// wrapping function directly
|
|
61
|
+
originalFn = target;
|
|
62
|
+
}
|
|
63
|
+
const tracedFunction = function (...args) {
|
|
64
|
+
return Traces.withSpan(source, filteringContextOrCallback
|
|
65
|
+
? (0, utils_1.extractFilteringContextFromArgs)(filteringContextOrCallback, args, this)
|
|
66
|
+
: {}, () => {
|
|
56
67
|
return originalFn.apply(this, args);
|
|
57
68
|
});
|
|
58
69
|
};
|
|
70
|
+
if (descriptor) {
|
|
71
|
+
descriptor.value = tracedFunction;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return tracedFunction;
|
|
75
|
+
}
|
|
59
76
|
};
|
|
60
77
|
}
|
|
61
78
|
return Traces.instance.withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, callback);
|
|
62
79
|
}
|
|
80
|
+
static withSpans(tracingMap, objectToTrace) {
|
|
81
|
+
for (const tracingMapPropertyName in tracingMap) {
|
|
82
|
+
if (typeof objectToTrace[tracingMapPropertyName] === "function") {
|
|
83
|
+
const originalMethod = objectToTrace[tracingMapPropertyName];
|
|
84
|
+
const tracingMapPropertyValue = tracingMap[tracingMapPropertyName];
|
|
85
|
+
let wrapperMaker;
|
|
86
|
+
if (typeof tracingMapPropertyValue === "string") {
|
|
87
|
+
wrapperMaker = Traces.withSpan(tracingMapPropertyValue);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
wrapperMaker = Traces.withSpan(tracingMapPropertyValue.source, tracingMapPropertyValue.decoratorOptions);
|
|
91
|
+
}
|
|
92
|
+
objectToTrace[tracingMapPropertyName] = wrapperMaker(originalMethod);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return objectToTrace;
|
|
96
|
+
}
|
|
63
97
|
}
|
|
64
98
|
exports.default = Traces;
|
|
65
99
|
Traces._instance = new nullTracesManager_1.NullTracesManager();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../src/traces/traces.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,kBAAkB;AAClB,2DAAwD;AACxD,yDAAsD;
|
|
1
|
+
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../src/traces/traces.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,kBAAkB;AAClB,2DAAwD;AACxD,yDAAsD;AAUtD,mCAA0D;AAE1D;;;GAGG;AACH,MAAqB,MAAM;IAElB,MAAM,KAAK,QAAQ;QACxB,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IACM,MAAM,KAAK,QAAQ,CAAC,KAAoB;QAC7C,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,C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,aAAa,CAAC,sBAAsB,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;aACtE;SACF;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;;AA/IH,yBAgJC;AA/IgB,gBAAS,GAAkB,IAAI,qCAAiB,EAAE,CAAC;AAiJvD,QAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC"}
|
package/dist/traces/types.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ export interface FilteringContext {
|
|
|
64
64
|
userId?: string;
|
|
65
65
|
[key: string]: string | number | boolean | undefined;
|
|
66
66
|
}
|
|
67
|
+
export interface WithSpanDecoratorOptions {
|
|
68
|
+
argMapping?: {
|
|
69
|
+
[x: string]: string;
|
|
70
|
+
} | Array<string | null | undefined>;
|
|
71
|
+
thisMapping?: {
|
|
72
|
+
[x: string]: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
67
75
|
export declare enum Verbosity {
|
|
68
76
|
OFF = 0,
|
|
69
77
|
LOWEST = 1,
|
|
@@ -179,11 +187,11 @@ export interface TracesDefaultsSettings {
|
|
|
179
187
|
*/
|
|
180
188
|
sample?: number | boolean;
|
|
181
189
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
* Whether the span will not inject its propagation info into data
|
|
191
|
+
* transfer objects for span nesting across system boundaries.
|
|
192
|
+
*
|
|
193
|
+
* Defaults to 'false'.
|
|
194
|
+
*/
|
|
187
195
|
disablePropagation?: boolean;
|
|
188
196
|
spanOptions?: SpanOptions;
|
|
189
197
|
}
|
package/dist/traces/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/traces/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/traces/types.ts"],"names":[],"mappings":";;;AA0GA,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,uCAAG,CAAA;IACH,6CAAM,CAAA;IACN,qDAAU,CAAA;IACV,2CAAK,CAAA;IACL,yCAAI,CAAA;IACJ,yCAAI,CAAA;IACJ,+CAAO,CAAA;AACT,CAAC,EARW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAQpB"}
|