Socket
Socket
Sign inDemoInstall

@opentelemetry/instrumentation-grpc

Package Overview
Dependencies
25
Maintainers
3
Versions
182
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.40.0 to 0.41.0

19

build/src/grpc-js/clientUtils.d.ts
/// <reference types="node" />
import { GrpcJsInstrumentation } from './';
import type { EventEmitter } from 'events';
import type { Span } from '@opentelemetry/api';
import type { Client, Metadata } from '@grpc/grpc-js';
import type * as grpcJs from '@grpc/grpc-js';
import type { GrpcJsInstrumentation } from './';
import type { GrpcClientFunc } from './types';
import { Span } from '@opentelemetry/api';
import type * as grpcJs from '@grpc/grpc-js';
import { EventEmitter } from 'events';
import { metadataCaptureType } from '../internal-types';
import type { metadataCaptureType } from '../internal-types';
/**

@@ -12,3 +13,3 @@ * Parse a package method list and return a list of methods to patch

*/
export declare function getMethodsToWrap(this: GrpcJsInstrumentation, client: typeof grpcJs.Client, methods: {
export declare function getMethodsToWrap(this: GrpcJsInstrumentation, client: typeof Client, methods: {
[key: string]: {

@@ -22,7 +23,7 @@ originalName?: string;

*/
export declare function makeGrpcClientRemoteCall(metadataCapture: metadataCaptureType, original: GrpcClientFunc, args: unknown[], metadata: grpcJs.Metadata, self: grpcJs.Client): (span: Span) => EventEmitter;
export declare function makeGrpcClientRemoteCall(metadataCapture: metadataCaptureType, original: GrpcClientFunc, args: unknown[], metadata: Metadata, self: Client): (span: Span) => EventEmitter;
/**
* Returns the metadata argument from user provided arguments (`args`)
*/
export declare function getMetadata(this: GrpcJsInstrumentation, grpcClient: typeof grpcJs, original: GrpcClientFunc, args: Array<unknown | grpcJs.Metadata>): grpcJs.Metadata;
export declare function getMetadata(this: GrpcJsInstrumentation, original: GrpcClientFunc, grpcClient: typeof grpcJs, args: Array<unknown | Metadata>): Metadata;
/**

@@ -33,3 +34,3 @@ * Inject opentelemetry trace context into `metadata` for use by another

*/
export declare function setSpanContext(metadata: grpcJs.Metadata): void;
export declare function setSpanContext(metadata: Metadata): void;
//# sourceMappingURL=clientUtils.d.ts.map

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

const api_1 = require("@opentelemetry/api");
const utils_1 = require("../utils");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const serverUtils_1 = require("./serverUtils");
const AttributeNames_1 = require("../enums/AttributeNames");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const status_code_1 = require("../status-code");
const utils_1 = require("../utils");
/**

@@ -139,3 +139,3 @@ * Parse a package method list and return a list of methods to patch

*/
function getMetadata(grpcClient, original, args) {
function getMetadata(original, grpcClient, args) {
let metadata;

@@ -177,3 +177,3 @@ // This finds an instance of Metadata among the arguments.

api_1.propagation.inject(api_1.context.active(), metadata, {
set: (metadata, k, v) => metadata.set(k, v),
set: (meta, k, v) => meta.set(k, v),
});

@@ -180,0 +180,0 @@ }

import type * as grpcJs from '@grpc/grpc-js';
import { InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
import { InstrumentationBase } from '@opentelemetry/instrumentation';
import { GrpcInstrumentationConfig } from '../types';
import type { GrpcInstrumentationConfig } from '../types';
import { InstrumentationNodeModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';
export declare class GrpcJsInstrumentation extends InstrumentationBase {

@@ -6,0 +5,0 @@ private _metadataCapture;

@@ -19,5 +19,5 @@ "use strict";

exports.GrpcJsInstrumentation = void 0;
const api_1 = require("@opentelemetry/api");
const instrumentation_1 = require("@opentelemetry/instrumentation");
const instrumentation_2 = require("@opentelemetry/instrumentation");
const api_1 = require("@opentelemetry/api");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const serverUtils_1 = require("./serverUtils");

@@ -27,4 +27,3 @@ const clientUtils_1 = require("./clientUtils");

const AttributeValues_1 = require("../enums/AttributeValues");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
class GrpcJsInstrumentation extends instrumentation_2.InstrumentationBase {
class GrpcJsInstrumentation extends instrumentation_1.InstrumentationBase {
constructor(name, version, config) {

@@ -90,3 +89,3 @@ super(name, version, config);

const self = this;
if ((0, serverUtils_1.shouldNotTraceServerCall)(call.metadata, name, config.ignoreGrpcMethods)) {
if ((0, serverUtils_1.shouldNotTraceServerCall)(name, config.ignoreGrpcMethods)) {
return (0, serverUtils_1.handleUntracedServerFunction)(type, originalFunc, call, callback);

@@ -166,3 +165,3 @@ }

const args = [...arguments];
const metadata = clientUtils_1.getMetadata.call(instrumentation, grpcClient, original, args);
const metadata = clientUtils_1.getMetadata.call(instrumentation, original, grpcClient, args);
const { service, method } = (0, utils_1._extractMethodAndService)(original.path);

@@ -169,0 +168,0 @@ const span = instrumentation.tracer

@@ -1,10 +0,4 @@

/**
* Symbol to include on grpc call if it has already emitted an error event.
* grpc events that emit 'error' will also emit 'finish' and so only the
* error event should be processed.
*/
import { Span } from '@opentelemetry/api';
import type * as grpcJs from '@grpc/grpc-js';
import type { Span } from '@opentelemetry/api';
import type { ServerCallWithMeta, SendUnaryDataCallback, HandleCall } from './types';
import { IgnoreMatcher } from '../types';
import type { IgnoreMatcher } from '../types';
export declare const CALL_SPAN_ENDED: unique symbol;

@@ -24,3 +18,3 @@ /**

*/
export declare function shouldNotTraceServerCall(metadata: grpcJs.Metadata, methodName: string, ignoreGrpcMethods?: IgnoreMatcher[]): boolean;
export declare function shouldNotTraceServerCall(methodName: string, ignoreGrpcMethods?: IgnoreMatcher[]): boolean;
//# sourceMappingURL=serverUtils.d.ts.map

@@ -19,11 +19,6 @@ "use strict";

exports.shouldNotTraceServerCall = exports.handleUntracedServerFunction = exports.handleServerFunction = exports.CALL_SPAN_ENDED = void 0;
/**
* Symbol to include on grpc call if it has already emitted an error event.
* grpc events that emit 'error' will also emit 'finish' and so only the
* error event should be processed.
*/
const api_1 = require("@opentelemetry/api");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const utils_1 = require("../utils");
const AttributeNames_1 = require("../enums/AttributeNames");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const status_code_1 = require("../status-code");

@@ -146,3 +141,3 @@ exports.CALL_SPAN_ENDED = Symbol('opentelemetry call span ended');

*/
function shouldNotTraceServerCall(metadata, methodName, ignoreGrpcMethods) {
function shouldNotTraceServerCall(methodName, ignoreGrpcMethods) {
const parsedName = methodName.split('/');

@@ -149,0 +144,0 @@ return (0, utils_1._methodIsIgnored)(parsedName[parsedName.length - 1] || methodName, ignoreGrpcMethods);

/// <reference types="node" />
import type * as grpcJs from '@grpc/grpc-js';
import type { EventEmitter } from 'events';
import type { CALL_SPAN_ENDED } from './serverUtils';
import type { requestCallback, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream, Metadata, Server, makeGenericClientConstructor } from '@grpc/grpc-js';
/**
* Server Unary callback type
*/
export declare type SendUnaryDataCallback<T> = grpcJs.requestCallback<T>;
export declare type SendUnaryDataCallback<T> = requestCallback<T>;
/**
* Intersection type of all grpc server call types
*/
export declare type ServerCall<T, U> = grpcJs.ServerUnaryCall<T, U> | grpcJs.ServerReadableStream<T, U> | grpcJs.ServerWritableStream<T, U> | grpcJs.ServerDuplexStream<T, U>;
export declare type ServerCall<T, U> = ServerUnaryCall<T, U> | ServerReadableStream<T, U> | ServerWritableStream<T, U> | ServerDuplexStream<T, U>;
/**

@@ -17,3 +17,3 @@ * {@link ServerCall} ServerCall extended with misc. missing utility types

export declare type ServerCallWithMeta<T, U> = ServerCall<T, U> & {
metadata: grpcJs.Metadata;
metadata: Metadata;
};

@@ -34,6 +34,6 @@ /**

};
export declare type ServerRegisterFunction = typeof grpcJs.Server.prototype.register;
export declare type MakeClientConstructorFunction = typeof grpcJs.makeGenericClientConstructor;
export declare type ServerRegisterFunction = typeof Server.prototype.register;
export declare type MakeClientConstructorFunction = typeof makeGenericClientConstructor;
export type { HandleCall } from '@grpc/grpc-js/build/src/server-call';
export type { PackageDefinition } from '@grpc/grpc-js/build/src/make-client';
//# sourceMappingURL=types.d.ts.map
export * from './instrumentation';
export { GrpcInstrumentationConfig } from './types';
export type { GrpcInstrumentationConfig } from './types';
//# sourceMappingURL=index.d.ts.map

@@ -17,14 +17,5 @@ "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 });
__exportStar(require("./instrumentation"), exports);
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./instrumentation"), exports);
//# sourceMappingURL=index.js.map

@@ -1,7 +0,6 @@

import { GrpcInstrumentationConfig } from './types';
import * as api from '@opentelemetry/api';
import type { GrpcInstrumentationConfig } from './types';
import type { MeterProvider, TracerProvider } from '@opentelemetry/api';
/** The metadata key under which span context is stored as a binary value. */
export declare const GRPC_TRACE_KEY = "grpc-trace-bin";
export declare class GrpcInstrumentation {
private _grpcNativeInstrumentation;
private _grpcJsInstrumentation;

@@ -25,3 +24,3 @@ readonly instrumentationName: string;

*/
setMeterProvider(meterProvider: api.MeterProvider): void;
setMeterProvider(meterProvider: MeterProvider): void;
/**

@@ -31,4 +30,4 @@ * Sets TraceProvider to this plugin

*/
setTracerProvider(tracerProvider: api.TracerProvider): void;
setTracerProvider(tracerProvider: TracerProvider): void;
}
//# sourceMappingURL=instrumentation.d.ts.map

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

const version_1 = require("./version");
const grpc_1 = require("./grpc");
const grpc_js_1 = require("./grpc-js");

@@ -30,7 +29,5 @@ /** The metadata key under which span context is stored as a binary value. */

this._grpcJsInstrumentation = new grpc_js_1.GrpcJsInstrumentation(this.instrumentationName, this.instrumentationVersion, config);
this._grpcNativeInstrumentation = new grpc_1.GrpcNativeInstrumentation(this.instrumentationName, this.instrumentationVersion, config);
}
setConfig(config) {
this._grpcJsInstrumentation.setConfig(config);
this._grpcNativeInstrumentation.setConfig(config);
}

@@ -52,7 +49,5 @@ /**

this._grpcJsInstrumentation.enable();
this._grpcNativeInstrumentation.enable();
}
disable() {
this._grpcJsInstrumentation.disable();
this._grpcNativeInstrumentation.disable();
}

@@ -65,3 +60,2 @@ /**

this._grpcJsInstrumentation.setMeterProvider(meterProvider);
this._grpcNativeInstrumentation.setMeterProvider(meterProvider);
}

@@ -74,3 +68,2 @@ /**

this._grpcJsInstrumentation.setTracerProvider(tracerProvider);
this._grpcNativeInstrumentation.setTracerProvider(tracerProvider);
}

@@ -77,0 +70,0 @@ }

@@ -1,14 +0,13 @@

import { Span } from '@opentelemetry/api';
import type * as grpcJsTypes from '@grpc/grpc-js';
import type * as grpcTypes from 'grpc';
import type { Span } from '@opentelemetry/api';
import type { Metadata } from '@grpc/grpc-js';
export declare type metadataCaptureType = {
client: {
captureRequestMetadata: (span: Span, metadata: grpcJsTypes.Metadata | grpcTypes.Metadata) => void;
captureResponseMetadata: (span: Span, metadata: grpcJsTypes.Metadata | grpcTypes.Metadata) => void;
captureRequestMetadata: (span: Span, metadata: Metadata) => void;
captureResponseMetadata: (span: Span, metadata: Metadata) => void;
};
server: {
captureRequestMetadata: (span: Span, metadata: grpcJsTypes.Metadata | grpcTypes.Metadata) => void;
captureResponseMetadata: (span: Span, metadata: grpcJsTypes.Metadata | grpcTypes.Metadata) => void;
captureRequestMetadata: (span: Span, metadata: Metadata) => void;
captureResponseMetadata: (span: Span, metadata: Metadata) => void;
};
};
//# sourceMappingURL=internal-types.d.ts.map

@@ -1,5 +0,5 @@

import { SpanStatusCode, SpanStatus, Span } from '@opentelemetry/api';
import type * as grpcTypes from 'grpc';
import type * as grpcJsTypes from '@grpc/grpc-js';
import { IgnoreMatcher } from './types';
import { SpanStatusCode } from '@opentelemetry/api';
import type { SpanStatus, Span } from '@opentelemetry/api';
import type { status as GrpcStatus, Metadata } from '@grpc/grpc-js';
import type { IgnoreMatcher } from './types';
export declare const URI_REGEX: RegExp;

@@ -11,3 +11,3 @@ export declare const findIndex: <T>(args: T[], fn: (arg: T) => boolean) => number;

*/
export declare const _grpcStatusCodeToOpenTelemetryStatusCode: (status?: grpcTypes.status | grpcJsTypes.status | undefined) => SpanStatusCode;
export declare const _grpcStatusCodeToOpenTelemetryStatusCode: (status?: GrpcStatus | undefined) => SpanStatusCode;
export declare const _grpcStatusCodeToSpanStatus: (status: number) => SpanStatus;

@@ -30,3 +30,3 @@ /**

};
export declare function metadataCapture(type: 'request' | 'response', metadataToAdd: string[]): (span: Span, metadata: grpcJsTypes.Metadata | grpcTypes.Metadata) => void;
export declare function metadataCapture(type: 'request' | 'response', metadataToAdd: string[]): (span: Span, metadata: Metadata) => void;
//# sourceMappingURL=utils.d.ts.map

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

.flatMap(value => (typeof value === 'string' ? value.toString() : []));
if (metadataValues === undefined || metadataValues === []) {
if (metadataValues === undefined || metadataValues.length === 0) {
continue;

@@ -115,0 +115,0 @@ }

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

export declare const VERSION = "0.40.0";
export declare const VERSION = "0.41.0";
//# sourceMappingURL=version.d.ts.map

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

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

@@ -19,6 +19,5 @@ "main": "build/src/index.js",

"watch": "tsc --build --watch",
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
"precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
"prewatch": "node ../../../scripts/version-update.js",
"peer-api-check": "node ../../../scripts/peer-api-check.js",
"postinstall": "node -e \"console.log(\\\"\\x1b[95m%s\\x1b[0m\\\", \\\"@opentelemetry/instrumentation-grpc - warning: The package 'grpc' (https://www.npmjs.com/package/grpc) is deprecated. It will no longer be instrumented in the next release of '@opentelemetry/instrumentation-grpc'. Please migrate to '@grpc/grpc-js' (https://www.npmjs.com/package/@grpc/grpc-js) to continue receiving telemetry.\\\");\""
"peer-api-check": "node ../../../scripts/peer-api-check.js"
},

@@ -53,17 +52,17 @@ "keywords": [

"@opentelemetry/api": "1.4.1",
"@opentelemetry/context-async-hooks": "1.14.0",
"@opentelemetry/core": "1.14.0",
"@opentelemetry/sdk-trace-base": "1.14.0",
"@opentelemetry/sdk-trace-node": "1.14.0",
"@types/mocha": "10.0.0",
"@opentelemetry/context-async-hooks": "1.15.0",
"@opentelemetry/core": "1.15.0",
"@opentelemetry/sdk-trace-base": "1.15.0",
"@opentelemetry/sdk-trace-node": "1.15.0",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/semver": "7.3.9",
"@types/sinon": "10.0.13",
"@types/semver": "7.5.0",
"@types/sinon": "10.0.15",
"codecov": "3.8.3",
"grpc": "1.24.11",
"mocha": "10.0.0",
"node-pre-gyp": "0.17.0",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"mocha": "10.2.0",
"nyc": "15.1.0",
"semver": "7.3.5",
"sinon": "15.0.0",
"semver": "7.5.3",
"sinon": "15.1.2",
"ts-mocha": "10.0.0",

@@ -76,8 +75,9 @@ "typescript": "4.4.4"

"dependencies": {
"@opentelemetry/instrumentation": "0.40.0",
"@opentelemetry/semantic-conventions": "1.14.0"
"@opentelemetry/instrumentation": "0.41.0",
"@opentelemetry/semantic-conventions": "1.15.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-grpc",
"sideEffects": false,
"gitHead": "edebbcc757535bc88f01340409dbbecc0bb6ccf8"
"gitHead": "06e919d6c909e8cc8e28b6624d9843f401d9b059"
}

@@ -8,3 +8,3 @@ # OpenTelemetry gRPC Instrumentation for Node.js

This module provides automatic instrumentation for [`grpc`](https://grpc.github.io/grpc/node/) and [`@grpc/grpc-js`](https://grpc.io/blog/grpc-js-1.0/). Currently, version [`1.x`](https://www.npmjs.com/package/grpc?activeTab=versions) of `grpc` and version [`1.x`](https://www.npmjs.com/package/@grpc/grpc-js?activeTab=versions) of `@grpc/grpc-js` is supported.
This module provides automatic instrumentation for [`@grpc/grpc-js`](https://grpc.io/blog/grpc-js-1.0/). Currently, version [`1.x`](https://www.npmjs.com/package/@grpc/grpc-js?activeTab=versions) of `@grpc/grpc-js` is supported.

@@ -22,3 +22,3 @@ For automatic instrumentation see the

OpenTelemetry gRPC Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [gRPC](https://www.npmjs.com/package/grpc) or ([grpc-js](https://www.npmjs.com/package/@grpc/grpc-js)).
OpenTelemetry gRPC Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with ([grpc-js](https://www.npmjs.com/package/@grpc/grpc-js)).

@@ -43,3 +43,3 @@ To load a specific instrumentation (**gRPC** in this case), specify it in the Node Tracer's configuration.

See [examples/grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/grpc) or [examples/grpc-js](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/grpc-js) for examples.
See [examples/grpc-js](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/grpc-js) for examples.

@@ -50,5 +50,5 @@ ### gRPC Instrumentation Options

| Options | Type | Description |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`ignoreGrpcMethods`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts#L25) | `IgnoreMatcher[]` | gRPC instrumentation will not trace any methods that match anything in this list. You may pass a string (case-insensitive match), a `RegExp` object, or a filter function. |
| Options | Type | Description |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`ignoreGrpcMethods`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts#L25) | `IgnoreMatcher[]` | gRPC instrumentation will not trace any methods that match anything in this list. You may pass a string (case-insensitive match), a `RegExp` object, or a filter function. |
| [`metadataToSpanAttributes`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-grpc/src/types.ts#L27) | `object` | List of case insensitive metadata to convert to span attributes. Client and server (outgoing requests, incoming responses) metadata attributes will be converted to span attributes in the form of `rpc.{request\response}.metadata.metadata_key`, e.g. `rpc.response.metadata.date` |

@@ -55,0 +55,0 @@

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

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc