@opentelemetry/plugin-grpc
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -32,3 +32,2 @@ /*! | ||
protected unpatch(): void; | ||
private _getSpanContext; | ||
private _setSpanContext; | ||
@@ -35,0 +34,0 @@ private _patchServer; |
@@ -18,4 +18,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api_1 = require("@opentelemetry/api"); | ||
const core_1 = require("@opentelemetry/core"); | ||
const api_1 = require("@opentelemetry/api"); | ||
const path = require("path"); | ||
@@ -68,17 +68,5 @@ const shimmer = require("shimmer"); | ||
} | ||
_getSpanContext(metadata) { | ||
const metadataValue = metadata.getMap()[exports.GRPC_TRACE_KEY]; | ||
// Entry doesn't exist | ||
if (!metadataValue) { | ||
return null; | ||
} | ||
return this._tracer.getBinaryFormat().fromBytes(metadataValue); | ||
_setSpanContext(metadata) { | ||
api_1.propagation.inject(metadata, (metadata, k, v) => metadata.set(k, v)); | ||
} | ||
_setSpanContext(metadata, spanContext) { | ||
const serializedSpanContext = this._tracer | ||
.getBinaryFormat() | ||
.toBytes(spanContext); | ||
const buffer = Buffer.from(serializedSpanContext); | ||
metadata.set(exports.GRPC_TRACE_KEY, buffer); | ||
} | ||
_patchServer() { | ||
@@ -98,23 +86,24 @@ return (originalRegister) => { | ||
kind: api_1.SpanKind.SERVER, | ||
parent: plugin._getSpanContext(call.metadata), | ||
}; | ||
plugin._logger.debug('patch func: %s', JSON.stringify(spanOptions)); | ||
const span = plugin._tracer | ||
.startSpan(spanName, spanOptions) | ||
.setAttributes({ | ||
[AttributeNames_1.AttributeNames.GRPC_KIND]: spanOptions.kind, | ||
[AttributeNames_1.AttributeNames.COMPONENT]: GrpcPlugin.component, | ||
api_1.context.with(api_1.propagation.extract(call.metadata, (carrier, key) => carrier.get(key)), () => { | ||
const span = plugin._tracer | ||
.startSpan(spanName, spanOptions) | ||
.setAttributes({ | ||
[AttributeNames_1.AttributeNames.GRPC_KIND]: spanOptions.kind, | ||
[AttributeNames_1.AttributeNames.COMPONENT]: GrpcPlugin.component, | ||
}); | ||
plugin._tracer.withSpan(span, () => { | ||
switch (type) { | ||
case 'unary': | ||
case 'client_stream': | ||
return plugin._clientStreamAndUnaryHandler(plugin, span, call, callback, originalFunc, self); | ||
case 'server_stream': | ||
case 'bidi': | ||
return plugin._serverStreamAndBidiHandler(plugin, span, call, originalFunc, self); | ||
default: | ||
break; | ||
} | ||
}); | ||
}); | ||
plugin._tracer.withSpan(span, () => { | ||
switch (type) { | ||
case 'unary': | ||
case 'client_stream': | ||
return plugin._clientStreamAndUnaryHandler(plugin, span, call, callback, originalFunc, self); | ||
case 'server_stream': | ||
case 'bidi': | ||
return plugin._serverStreamAndBidiHandler(plugin, span, call, originalFunc, self); | ||
default: | ||
break; | ||
} | ||
}); | ||
}; | ||
@@ -217,6 +206,5 @@ }); | ||
kind: api_1.SpanKind.CLIENT, | ||
parent: plugin._tracer.getCurrentSpan(), | ||
}) | ||
.setAttribute(AttributeNames_1.AttributeNames.COMPONENT, GrpcPlugin.component); | ||
return plugin._makeGrpcClientRemoteCall(original, args, this, plugin)(span); | ||
return plugin._tracer.withSpan(span, () => plugin._makeGrpcClientRemoteCall(original, args, this, plugin)(span)); | ||
}; | ||
@@ -276,3 +264,3 @@ }; | ||
}); | ||
this._setSpanContext(metadata, span.context()); | ||
this._setSpanContext(metadata); | ||
const call = original.apply(self, args); | ||
@@ -279,0 +267,0 @@ // if server stream or bidi |
@@ -16,2 +16,2 @@ /*! | ||
*/ | ||
export declare const VERSION = "0.4.0"; | ||
export declare const VERSION = "0.5.0"; |
@@ -19,3 +19,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.4.0'; | ||
exports.VERSION = '0.5.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/plugin-grpc", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "OpenTelemetry grpc automatic instrumentation package.", | ||
@@ -12,3 +12,4 @@ "main": "build/src/index.js", | ||
"clean": "rimraf build/*", | ||
"check": "gts check", | ||
"lint": "gts check", | ||
"lint:fix": "gts fix", | ||
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", | ||
@@ -18,3 +19,2 @@ "precompile": "tsc --version", | ||
"compile": "npm run version:update && tsc -p .", | ||
"fix": "gts fix", | ||
"prepare": "npm run compile" | ||
@@ -46,4 +46,6 @@ }, | ||
"devDependencies": { | ||
"@opentelemetry/node": "^0.4.0", | ||
"@opentelemetry/tracing": "^0.4.0", | ||
"@opentelemetry/context-async-hooks": "^0.5.0", | ||
"@opentelemetry/context-base": "^0.5.0", | ||
"@opentelemetry/node": "^0.5.0", | ||
"@opentelemetry/tracing": "^0.5.0", | ||
"@types/mocha": "^5.2.7", | ||
@@ -69,6 +71,6 @@ "@types/node": "^12.6.9", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.4.0", | ||
"@opentelemetry/core": "^0.4.0", | ||
"@opentelemetry/api": "^0.5.0", | ||
"@opentelemetry/core": "^0.5.0", | ||
"shimmer": "^1.2.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43683
22
644
+ Added@opentelemetry/api@0.5.2(transitive)
+ Added@opentelemetry/context-base@0.5.2(transitive)
+ Added@opentelemetry/core@0.5.2(transitive)
+ Addedsemver@7.6.3(transitive)
- Removed@opentelemetry/api@0.4.0(transitive)
- Removed@opentelemetry/core@0.4.0(transitive)
- Removedsemver@6.3.1(transitive)
Updated@opentelemetry/api@^0.5.0
Updated@opentelemetry/core@^0.5.0