Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-fs

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-fs - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

2

build/src/instrumentation.d.ts
/// <reference types="node" />
import * as api from '@opentelemetry/api';
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';

@@ -15,4 +16,5 @@ import type * as fs from 'fs';

protected _runEndHook(...args: Parameters<EndHook>): ReturnType<EndHook>;
protected _shouldTrace(context: api.Context): boolean;
}
export {};
//# sourceMappingURL=instrumentation.d.ts.map

67

build/src/instrumentation.js

@@ -34,3 +34,3 @@ "use strict";

for (const fName of constants_1.SYNC_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs[fName])) {
if ((0, instrumentation_1.isWrapped)(fs[fName])) {
this._unwrap(fs, fName);

@@ -41,3 +41,3 @@ }

for (const fName of constants_1.CALLBACK_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs[fName])) {
if ((0, instrumentation_1.isWrapped)(fs[fName])) {
this._unwrap(fs, fName);

@@ -55,3 +55,3 @@ }

for (const fName of constants_1.PROMISE_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs.promises[fName])) {
if ((0, instrumentation_1.isWrapped)(fs.promises[fName])) {
this._unwrap(fs.promises, fName);

@@ -68,3 +68,3 @@ }

for (const fName of constants_1.SYNC_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs[fName])) {
if ((0, instrumentation_1.isWrapped)(fs[fName])) {
this._unwrap(fs, fName);

@@ -74,3 +74,3 @@ }

for (const fName of constants_1.CALLBACK_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs[fName])) {
if ((0, instrumentation_1.isWrapped)(fs[fName])) {
this._unwrap(fs, fName);

@@ -81,3 +81,3 @@ }

for (const fName of constants_1.PROMISE_FUNCTIONS) {
if (instrumentation_1.isWrapped(fs.promises[fName])) {
if ((0, instrumentation_1.isWrapped)(fs.promises[fName])) {
this._unwrap(fs.promises, fName);

@@ -93,5 +93,4 @@ }

return function (...args) {
if (core_1.isTracingSuppressed(api.context.active())) {
// Performance optimization. Avoid creating additional contexts and spans
// if we already know that the tracing is being suppressed.
const activeContext = api.context.active();
if (!instrumentation._shouldTrace(activeContext)) {
return original.apply(this, args);

@@ -102,3 +101,3 @@ }

}) === false) {
return api.context.with(core_1.suppressTracing(api.context.active()), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(activeContext), original, this, ...args);
}

@@ -108,3 +107,3 @@ const span = instrumentation.tracer.startSpan(`fs ${functionName}`);

// Suppress tracing for internal fs calls
const res = api.context.with(core_1.suppressTracing(api.trace.setSpan(api.context.active(), span)), original, this, ...args);
const res = api.context.with((0, core_1.suppressTracing)(api.trace.setSpan(activeContext, span)), original, this, ...args);
instrumentation._runEndHook(functionName, { args: args, span });

@@ -130,5 +129,4 @@ return res;

return function (...args) {
if (core_1.isTracingSuppressed(api.context.active())) {
// Performance optimization. Avoid creating additional contexts and spans
// if we already know that the tracing is being suppressed.
const activeContext = api.context.active();
if (!instrumentation._shouldTrace(activeContext)) {
return original.apply(this, args);

@@ -139,3 +137,3 @@ }

}) === false) {
return api.context.with(core_1.suppressTracing(api.context.active()), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(activeContext), original, this, ...args);
}

@@ -147,3 +145,3 @@ const lastIdx = args.length - 1;

// Return to the context active during the call in the callback
args[lastIdx] = api.context.bind(api.context.active(), function (error) {
args[lastIdx] = api.context.bind(activeContext, function (error) {
if (error) {

@@ -166,3 +164,3 @@ span.recordException(error);

// Suppress tracing for internal fs calls
return api.context.with(core_1.suppressTracing(api.trace.setSpan(api.context.active(), span)), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(api.trace.setSpan(activeContext, span)), original, this, ...args);
}

@@ -193,5 +191,4 @@ catch (error) {

const patchedFunction = function (...args) {
if (core_1.isTracingSuppressed(api.context.active())) {
// Performance optimization. Avoid creating additional contexts and spans
// if we already know that the tracing is being suppressed.
const activeContext = api.context.active();
if (!instrumentation._shouldTrace(activeContext)) {
return original.apply(this, args);

@@ -202,3 +199,3 @@ }

}) === false) {
return api.context.with(core_1.suppressTracing(api.context.active()), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(activeContext), original, this, ...args);
}

@@ -210,3 +207,3 @@ const lastIdx = args.length - 1;

// Return to the context active during the call in the callback
args[lastIdx] = api.context.bind(api.context.active(), function () {
args[lastIdx] = api.context.bind(activeContext, function () {
// `exists` never calls the callback with an error

@@ -222,3 +219,3 @@ instrumentation._runEndHook(functionName, {

// Suppress tracing for internal fs calls
return api.context.with(core_1.suppressTracing(api.trace.setSpan(api.context.active(), span)), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(api.trace.setSpan(activeContext, span)), original, this, ...args);
}

@@ -258,5 +255,4 @@ catch (error) {

return async function (...args) {
if (core_1.isTracingSuppressed(api.context.active())) {
// Performance optimization. Avoid creating additional contexts and spans
// if we already know that the tracing is being suppressed.
const activeContext = api.context.active();
if (!instrumentation._shouldTrace(activeContext)) {
return original.apply(this, args);

@@ -267,3 +263,3 @@ }

}) === false) {
return api.context.with(core_1.suppressTracing(api.context.active()), original, this, ...args);
return api.context.with((0, core_1.suppressTracing)(activeContext), original, this, ...args);
}

@@ -273,3 +269,3 @@ const span = instrumentation.tracer.startSpan(`fs ${functionName}`);

// Suppress tracing for internal fs calls
const res = await api.context.with(core_1.suppressTracing(api.trace.setSpan(api.context.active(), span)), original, this, ...args);
const res = await api.context.with((0, core_1.suppressTracing)(api.trace.setSpan(activeContext, span)), original, this, ...args);
instrumentation._runEndHook(functionName, { args: args, span });

@@ -315,4 +311,19 @@ return res;

}
_shouldTrace(context) {
if ((0, core_1.isTracingSuppressed)(context)) {
// Performance optimization. Avoid creating additional contexts and spans
// if we already know that the tracing is being suppressed.
return false;
}
const { requireParentSpan } = this.getConfig();
if (requireParentSpan) {
const parentSpan = api.trace.getSpan(context);
if (parentSpan == null) {
return false;
}
}
return true;
}
}
exports.default = FsInstrumentation;
//# sourceMappingURL=instrumentation.js.map

@@ -10,3 +10,3 @@ /// <reference types="node" />

export declare type FMember = FunctionPropertyNames<typeof fs>;
export declare type FPMember = FunctionPropertyNames<typeof fs['promises']>;
export declare type FPMember = FunctionPropertyNames<(typeof fs)['promises']>;
export declare type CreateHook = (functionName: FMember | FPMember, info: {

@@ -23,3 +23,4 @@ args: ArrayLike<unknown>;

endHook?: EndHook;
requireParentSpan?: boolean;
}
//# sourceMappingURL=types.d.ts.map

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

export declare const VERSION = "0.6.0";
export declare const VERSION = "0.7.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.6.0';
exports.VERSION = '0.7.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-fs",
"version": "0.6.0",
"version": "0.7.0",
"description": "OpenTelemetry automatic instrumentation package for fs",

@@ -57,13 +57,13 @@ "main": "build/src/index.js",

"rimraf": "3.0.2",
"sinon": "14.0.0",
"sinon": "15.0.1",
"ts-mocha": "10.0.0",
"typescript": "4.3.5"
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.34.0",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/semantic-conventions": "^1.0.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs#readme",
"gitHead": "59fa57cfd0dff4ae0e6f3833dff73c55dfd79ee5"
"gitHead": "63e0fc9b6b862f74304abf0343c506a5bd415191"
}

@@ -43,6 +43,7 @@ # OpenTelemetry `fs` Instrumentation for Node.js

| Options | Type | Description |
| ------- | ---- | ----------- |
| `createHook` | `(functionName: FMember | FPMember, info: { args: ArrayLike<unknown> }) => boolean` | Hook called before creating the span. If `false` is returned this and all the sibling calls will not be traced. |
| `endHook` | `( functionName: FMember | FPMember, info: { args: ArrayLike<unknown>; span: api.Span } ) => void` | Function called just before the span is ended. Useful for adding attributes. |
| Options | Type | Description |
| ------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `createHook` | `(functionName: FMember \| FPMember, info: { args: ArrayLike<unknown> }) => boolean` | Hook called before creating the span. If `false` is returned this and all the sibling calls will not be traced. |
| `endHook` | `( functionName: FMember \| FPMember, info: { args: ArrayLike<unknown>; span: api.Span } ) => void` | Function called just before the span is ended. Useful for adding attributes. |
| `requireParentSpan` | `boolean` | Require parent to create fs span, default when unset is `false`. |

@@ -49,0 +50,0 @@ ## Useful links

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