@netlify/opentelemetry-utils 1.1.0 → 1.2.1
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/lib/index.d.ts +6 -1
- package/lib/index.js +13 -1
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Context, Attributes } from '@opentelemetry/api';
|
|
2
2
|
/**
|
|
3
|
-
* Sets attributes to be propagated across child spans under the current active context
|
|
3
|
+
* Sets attributes to be propagated across child spans under the current active context. Contexts are immutable so the
|
|
4
|
+
* newly returned context must be used when instantiating a new span for these new properties to be used.
|
|
4
5
|
*/
|
|
5
6
|
export declare const setMultiSpanAttributes: (attributes: {
|
|
6
7
|
[key: string]: string;
|
|
7
8
|
}) => Context;
|
|
9
|
+
/**
|
|
10
|
+
* Add the provided attributes to the current active span (if any).
|
|
11
|
+
*/
|
|
12
|
+
export declare const addAttributesToActiveSpan: (attributes?: Attributes) => void;
|
|
8
13
|
/**
|
|
9
14
|
* Add error information to the current active span (if any). Optionally sets the provided attributes on the span too.
|
|
10
15
|
*/
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { context, propagation, trace, SpanStatusCode } from '@opentelemetry/api';
|
|
2
2
|
/**
|
|
3
|
-
* Sets attributes to be propagated across child spans under the current active context
|
|
3
|
+
* Sets attributes to be propagated across child spans under the current active context. Contexts are immutable so the
|
|
4
|
+
* newly returned context must be used when instantiating a new span for these new properties to be used.
|
|
4
5
|
*/
|
|
5
6
|
export const setMultiSpanAttributes = function (attributes) {
|
|
6
7
|
const currentBaggage = propagation.getBaggage(context.active());
|
|
@@ -11,6 +12,17 @@ export const setMultiSpanAttributes = function (attributes) {
|
|
|
11
12
|
});
|
|
12
13
|
return propagation.setBaggage(context.active(), baggage);
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Add the provided attributes to the current active span (if any).
|
|
17
|
+
*/
|
|
18
|
+
export const addAttributesToActiveSpan = function (attributes) {
|
|
19
|
+
const span = trace.getActiveSpan();
|
|
20
|
+
if (!span)
|
|
21
|
+
return;
|
|
22
|
+
if (attributes !== undefined) {
|
|
23
|
+
span.setAttributes(attributes);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
14
26
|
/**
|
|
15
27
|
* Add error information to the current active span (if any). Optionally sets the provided attributes on the span too.
|
|
16
28
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/opentelemetry-utils",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Opentelemetry utility methods",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@opentelemetry/api": "~1.8.0",
|
|
35
|
-
"@opentelemetry/sdk-trace-base": "~1.
|
|
36
|
-
"@opentelemetry/sdk-trace-node": "~1.
|
|
35
|
+
"@opentelemetry/sdk-trace-base": "~1.24.0",
|
|
36
|
+
"@opentelemetry/sdk-trace-node": "~1.24.0",
|
|
37
37
|
"@types/node": "^14.18.53",
|
|
38
38
|
"@vitest/coverage-c8": "^0.33.0",
|
|
39
39
|
"@vitest/ui": "^0.34.0",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "95038d0359de8abef07cb3caadd8cea0c3fb539e"
|
|
48
48
|
}
|