Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/baggage-span-processor

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/baggage-span-processor - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

build/src/types.d.ts

7

build/src/baggage-span-processor.d.ts

@@ -0,1 +1,2 @@

import { BaggageKeyPredicate } from './types';
import { Context } from '@opentelemetry/api';

@@ -25,3 +26,9 @@ import { SpanProcessor, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';

export declare class BaggageSpanProcessor implements SpanProcessor {
private _keyPredicate;
/**
* Constructs a new BaggageSpanProcessor instance.
* @param keyPredicate A predicate that determines whether a baggage key-value pair should be added to new spans as a span attribute.
*/
constructor(keyPredicate: BaggageKeyPredicate);
/**
* Forces to export all finished spans

@@ -28,0 +35,0 @@ */

13

build/src/baggage-span-processor.js

@@ -43,2 +43,9 @@ "use strict";

/**
* Constructs a new BaggageSpanProcessor instance.
* @param keyPredicate A predicate that determines whether a baggage key-value pair should be added to new spans as a span attribute.
*/
constructor(keyPredicate) {
this._keyPredicate = keyPredicate;
}
/**
* Forces to export all finished spans

@@ -57,5 +64,5 @@ */

var _a, _b;
((_b = (_a = api_1.propagation.getBaggage(parentContext)) === null || _a === void 0 ? void 0 : _a.getAllEntries()) !== null && _b !== void 0 ? _b : []).forEach(entry => {
span.setAttribute(entry[0], entry[1].value);
});
((_b = (_a = api_1.propagation.getBaggage(parentContext)) === null || _a === void 0 ? void 0 : _a.getAllEntries()) !== null && _b !== void 0 ? _b : [])
.filter(entry => this._keyPredicate(entry[0]))
.forEach(entry => span.setAttribute(entry[0], entry[1].value));
}

@@ -62,0 +69,0 @@ /**

@@ -1,2 +0,3 @@

export { BaggageSpanProcessor } from './baggage-span-processor';
export * from './baggage-span-processor';
export * from './types';
//# sourceMappingURL=index.d.ts.map

@@ -17,6 +17,15 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaggageSpanProcessor = void 0;
var baggage_span_processor_1 = require("./baggage-span-processor");
Object.defineProperty(exports, "BaggageSpanProcessor", { enumerable: true, get: function () { return baggage_span_processor_1.BaggageSpanProcessor; } });
__exportStar(require("./baggage-span-processor"), exports);
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

export declare const VERSION = "0.2.0";
export declare const PACKAGE_VERSION = "0.3.0";
export declare const PACKAGE_NAME = "@opentelemetry/baggage-span-processor";
//# sourceMappingURL=version.d.ts.map

@@ -18,5 +18,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.2.0';
exports.PACKAGE_VERSION = '0.3.0';
exports.PACKAGE_NAME = '@opentelemetry/baggage-span-processor';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/baggage-span-processor",
"version": "0.2.0",
"version": "0.3.0",
"description": "OpenTelemetry Baggage Span Processor for Node.js",

@@ -59,3 +59,3 @@ "main": "build/src/index.ts",

"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/baggage-span-processor#readme",
"gitHead": "54365a9aafaca6555e13f1276945d6f869d103da"
"gitHead": "0af1b70f7c3c9763c85ac51fa5e334c1e1512020"
}

@@ -30,7 +30,7 @@ # OpenTelemetry Baggage Span Processor for Node.js

Add to the span processors during configuration:
Add to the span processors that copies all baggage entries during configuration:
```javascript
import { NodeSDK, tracing } from "@opentelemetry/sdk-node";
import { BaggageSpanProcessor } from "@opentelemetry/baggage-span-processor";
import { NodeSDK, tracing } from '@opentelemetry/sdk-node';
import { ALLOW_ALL_BAGGAGE_KEYS, BaggageSpanProcessor } from '@opentelemetry/baggage-span-processor';

@@ -40,3 +40,3 @@ const spanProcessors = [

new tracing.ConsoleSpanExporter()),
new BaggageSpanProcessor()];
new BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS)];

@@ -51,7 +51,22 @@ const sdk = new NodeSDK({

Alternatively, you can provide a custom baggage key predicate to select which baggage keys you want to copy.
For example, to only copy baggage entries that start with `my-key`:
```javascript
new BaggageSpanProcessor((baggageKey: string) => key.startsWith('my-key'))
```
For example, to only copy baggage entries that matches the regex `^key.+`:
```javascript
const regex = new RegExp("^key.+")
new BaggageSpanProcessor((baggageKey: string) => regex.test(baggageKey))
```
## Useful links
* For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
* For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
* For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]

@@ -58,0 +73,0 @@ ## License

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc