{"id":48034,"library":"grpc-interceptor-opentracing","title":"grpc-interceptor-opentracing","description":"grpc-interceptor-opentracing is an OpenTracing interceptor for gRPC Node.js servers that automatically creates and propagates spans for each gRPC call. Version 1.3.1 (stable) uses the experimental gRPC interceptor API from @grpc/grpc-js. It chains spans on existing contexts and reports them on call completion. Requires the opentracing package (v0.14) and an OpenTracing-compatible tracer like Jaeger. Unlike manual instrumentation, it provides automatic tracing with minimal configuration. The library is ESM-only and intended for use with the experimental server interceptor pattern (gRPC >=1.24).","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/edvardchen/node-grpc-experimental-server-interceptors","tags":["javascript","grpc","opentracing","jaeger","interceptor"],"install":[{"cmd":"npm install grpc-interceptor-opentracing","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-interceptor-opentracing","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-interceptor-opentracing","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for the OpenTracing API (global tracer or custom tracer)","package":"opentracing","optional":false}],"imports":[{"note":"Package exports a default function that returns an interceptor. CommonJS require fails because the package is ESM-only.","wrong":"const opentracing = require('grpc-interceptor-opentracing');","symbol":"opentracing","correct":"import opentracing from 'grpc-interceptor-opentracing';"},{"note":"If using CommonJS with dynamic import or bundler that supports ESM, you must access the .default property. Direct require returns the module object.","wrong":"const opentracing = require('grpc-interceptor-opentracing');","symbol":"opentracing","correct":"const opentracing = require('grpc-interceptor-opentracing').default;"},{"note":"TypeScript users may need to import the options interface for type safety. Not exported in all versions; check typings.","wrong":null,"symbol":"OpentracingInterceptorOptions","correct":"import type { OpentracingInterceptorOptions } from 'grpc-interceptor-opentracing';"}],"quickstart":{"code":"import grpc from '@grpc/grpc-js';\nimport opentracing from 'grpc-interceptor-opentracing';\nimport Tracer from 'opentracing'; // or your tracer implementation\n\nconst tracer = new Tracer(); // e.g., initJaegerTracer from 'jaeger-client'\nconst options = { tracer };\n\nconst server = new grpc.Server();\nserver.use(opentracing(options));\n\n// Add your services and start server as usual\nserver.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {\n  console.log('gRPC server with OpenTracing started');\n});","lang":"typescript","description":"Creates a gRPC server with automatic OpenTracing spans via the interceptor. Requires @grpc/grpc-js and opentracing."},"warnings":[{"fix":"Upgrade to @grpc/grpc-js >=1.24 or use the @grpc/proto-loader interceptor alternative.","message":"Requires gRPC experimental interceptor API (gRPC >=1.24). Not compatible with older gRPC versions.","severity":"breaking","affected_versions":"<1.24"},{"fix":"For client-side tracing, use a separate instrumented client or apply the interceptor on the client side.","message":"The interceptor only works on server-side calls, not client-side.","severity":"gotcha","affected_versions":"ALL"},{"fix":"Consider migrating to opentracing instrumentation using the new gRPC API, such as @opentracing/instrumentation-grpc.","message":"gRPC Node.js experimental interceptor API is deprecated in favor of the new async-intercept API. This library may stop working in future gRPC versions.","severity":"deprecated","affected_versions":">=1.24"},{"fix":"Always provide a tracer instance, or ensure a global tracer has been initialized before using the interceptor.","message":"If no tracer is provided in options, the global tracer from opentracing is used. If no global tracer is set, an error may occur.","severity":"gotcha","affected_versions":"ALL"},{"fix":"If you need no new root spans, ensure your application passes an active span context.","message":"The library assumes the gRPC call context already has an active span. If no parent span exists, a root span is created.","severity":"gotcha","affected_versions":"ALL"}],"env_vars":null,"search_vec":"'1.24':90 '1.3.1':28 'api':35 'automat':18,68 'call':26,48 'chain':39 'compat':59 'complet':49 'configur':72 'context':43 'creat':19 'esm':77 'esm-on':76 'exist':42 'experiment':32,85 'grpc':2,6,14,25,33,89,92 'grpc-interceptor-opentrac':1,5 'grpc/grpc-js':37 'instrument':65 'intend':80 'interceptor':3,7,12,34,87,95 'jaeger':62,94 'javascript':91 'librari':74 'like':61 'manual':64 'minim':71 'node.js':15 'opentrac':4,8,11,52,58,93 'opentracing-compat':57 'packag':53 'pattern':88 'propag':21 'provid':67 'report':45 'requir':50 'server':16,86 'span':22,40 'stabl':29 'trace':69 'tracer':60 'unlik':63 'use':30,82 'v0.14':54 'version':27","created_at":"2026-06-07T16:54:35.607443+00:00","updated_at":"2026-06-07T16:54:35.607443+00:00","problems":[{"fix":"Run 'npm install grpc-interceptor-opentracing' and use import/require correctly.","cause":"Missing package installation or wrong import path.","error":"Error: Cannot find module 'grpc-interceptor-opentracing'"},{"fix":"Use import statement: 'import opentracing from \"grpc-interceptor-opentracing\";' or in CommonJS: 'const opentracing = require(\"grpc-interceptor-opentracing\").default;'","cause":"Using CommonJS require without accessing .default. Package is ESM-only.","error":"TypeError: opentracing is not a function"},{"fix":"Either pass a tracer in options: 'opentracing({ tracer })' or initialize a global tracer via opentracing.initGlobalTracer().","cause":"No tracer option passed and no global opentracing tracer instance.","error":"Error: No tracer provided and no global tracer registered"},{"fix":"Upgrade to @grpc/grpc-js >=1.24 which supports server.use() experimental interceptor.","cause":"gRPC version <1.24 or using old gRPC API (grpc library instead of @grpc/grpc-js).","error":"TypeError: server.use is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/edvardchen/node-grpc-experimental-server-interceptors/tree/master/packages/grpc-interceptor-opentracing#readme","github":"https://github.com/edvardchen/node-grpc-experimental-server-interceptors","docs":null,"changelog":null,"pypi":null,"npm":"grpc-interceptor-opentracing","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}