Please answer these questions before submitting a bug report.
latest
latest
If possible, provide a recipe for reproducing the error.
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const opentelemetry = require('@opentelemetry/core');
const { NodeTracer } = require('@opentelemetry/node');
// Create and initialize NodeTracer
const tracer = new NodeTracer();
const exporter = new JaegerExporter({ serviceName: 'hello-world' });
tracer.addSpanProcessor(new BatchSpanProcessor(exporter));
// Initialize the tracer
opentelemetry.initGlobalTracer(tracer);
tracing
ReferenceError: BatchSpanProcessor is not defined
Would be nice to have an example with both automated instrumentation + export (jaeger or zipkin) ... is the above ordering correct?
I think there is a sample using jeager/zipkin and autoinstrumentation in folder examples/http.
In your sample there is nothing like const { BatchSpanProcessor } = require('@opentelemetry/tracing');.
Thanks @Flarna, taking from the example you . mentioned I was able to achieve instrumentation and export to jaeger with the following config.
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const opentelemetry = require('@opentelemetry/core');
const { NodeTracer } = require('@opentelemetry/node');
const { BatchSpanProcessor } = require('@opentelemetry/tracing');
// Create and initialize NodeTracer
const tracer = new NodeTracer({
plugins: {
http: {
enabled: true,
// You may use a package name or absolute path to the file.
path: '@opentelemetry/plugin-http',
// http plugin options
},
},
});
const exporter = new JaegerExporter({ serviceName: 'hello-world' });
tracer.addSpanProcessor(new BatchSpanProcessor(exporter));
// Initialize the tracer
opentelemetry.initGlobalTracer(tracer);
However there is an issue when we do not have the http plugin installed, my understanding is that it would fetch the required plugin automatically but it errors out with: PluginLoader#load: applying patch to [email protected] using @opentelemetry/plugin-http module
PluginLoader#load: could not load plugin @opentelemetry/plugin-http of module http. Error: Cannot find module '@opentelemetry/plugin-http' I will create a separate issue.
The simpler way is: const tracer = new NodeTracer(); <= just initialize NodeTracer. No need to pass plugins config unless you want to override default values (like path, ignoreUrls, ignoreMethods etc.).
Thanks @mayurkale22 but this is actually the message i get when initializing the tracer without any plugins config (or with the plugin config, but the plugin not explicitly installed)
That's to say both
const tracer = new NodeTracer();
And
const tracer = new NodeTracer({
plugins: {
http: {
enabled: true,
// You may use a package name or absolute path to the file.
path: '@opentelemetry/plugin-http',
// http plugin options
},
},
});
(without @opentelemetry/plugin-http in node_modules)
yield :
PluginLoader#load: trying loading [email protected]
PluginLoader#load: applying patch to [email protected] using @opentelemetry/plugin-http module
PluginLoader#load: could not load plugin @opentelemetry/plugin-http of module http. Error: Cannot find module '@opentelemetry/plugin-http'
Should I open a separate issue?
Should I open a separate issue?
That would be ideal and we can close this one.
The temporary workaround is that you can install the package(npm install @opentelemetry/plugin-http) manually in order to work the HTTP instrumentation.
Most helpful comment
I think there is a sample using jeager/zipkin and autoinstrumentation in folder
examples/http.In your sample there is nothing like
const { BatchSpanProcessor } = require('@opentelemetry/tracing');.