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

@opentelemetry/instrumentation-knex

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-knex - npm Package Compare versions

Comparing version 0.38.0 to 0.39.0

7

build/src/instrumentation.d.ts
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import * as types from './types';
export declare class KnexInstrumentation extends InstrumentationBase {
constructor(config?: types.KnexInstrumentationConfig);
import { KnexInstrumentationConfig } from './types';
export declare class KnexInstrumentation extends InstrumentationBase<KnexInstrumentationConfig> {
constructor(config?: KnexInstrumentationConfig);
setConfig(config?: KnexInstrumentationConfig): void;
init(): InstrumentationNodeModuleDefinition;

@@ -6,0 +7,0 @@ private getRunnerNodeModuleFileInstrumentation;

@@ -28,7 +28,11 @@ "use strict";

maxQueryLength: 1022,
requireParentSpan: false,
};
class KnexInstrumentation extends instrumentation_1.InstrumentationBase {
constructor(config = {}) {
super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config));
super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, Object.assign(Object.assign({}, DEFAULT_CONFIG), config));
}
setConfig(config = {}) {
super.setConfig(Object.assign(Object.assign({}, DEFAULT_CONFIG), config));
}
init() {

@@ -72,3 +76,3 @@ const module = new instrumentation_1.InstrumentationNodeModuleDefinition(constants.MODULE_NAME, constants.SUPPORTED_VERSIONS);

const name = ((_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.filename) || ((_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.database);
const maxLen = instrumentation._config.maxQueryLength;
const { maxQueryLength } = instrumentation.getConfig();
const attributes = {

@@ -85,10 +89,16 @@ 'knex.version': moduleVersion,

};
if (maxLen !== 0) {
attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] = utils.limitLength(query === null || query === void 0 ? void 0 : query.sql, maxLen);
if (maxQueryLength) {
// filters both undefined and 0
attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] = utils.limitLength(query === null || query === void 0 ? void 0 : query.sql, maxQueryLength);
}
const parent = this.builder[contextSymbol];
const parentContext = this.builder[contextSymbol] || api.context.active();
const parentSpan = api.trace.getSpan(parentContext);
const hasActiveParent = parentSpan && api.trace.isSpanContextValid(parentSpan.spanContext());
if (instrumentation._config.requireParentSpan && !hasActiveParent) {
return original.bind(this)(...arguments);
}
const span = instrumentation.tracer.startSpan(utils.getName(name, operation, table), {
kind: api.SpanKind.CLIENT,
attributes,
}, parent);
}, parentContext);
const spanContext = api.trace.setSpan(api.context.active(), span);

@@ -95,0 +105,0 @@ return api.context

@@ -5,3 +5,5 @@ import { InstrumentationConfig } from '@opentelemetry/instrumentation';

maxQueryLength?: number;
/** only create spans if part of an existing trace */
requireParentSpan?: boolean;
}
//# sourceMappingURL=types.d.ts.map

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

export declare const PACKAGE_VERSION = "0.38.0";
export declare const PACKAGE_VERSION = "0.39.0";
export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-knex";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.PACKAGE_VERSION = '0.38.0';
exports.PACKAGE_VERSION = '0.39.0';
exports.PACKAGE_NAME = '@opentelemetry/instrumentation-knex';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/instrumentation-knex",
"version": "0.38.0",
"version": "0.39.0",
"description": "OpenTelemetry instrumentation for `knex` database SQL query builder",

@@ -65,3 +65,3 @@ "main": "build/src/index.js",

"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-knex#readme",
"gitHead": "ad8436d6a4174f2288cb939080cd4e74da94b0d7"
"gitHead": "c1d67f8befb716c57bb5083a9d24f154128963df"
}

@@ -50,2 +50,3 @@ # OpenTelemetry Knex Instrumentation for Node.js

| `maxQueryLength` | `number` | `100` | Truncate `db.statement` attribute to a maximum length. If the statement is truncated `'..'` is added to it's end. Default `1022`. `-1` leaves `db.statement` untouched. |
| `requireParentSpan` | `boolean` | `false` | Don't create spans unless they are part of an existing trace. Default is `false`. |

@@ -52,0 +53,0 @@ ## Semantic Conventions

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