Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Opentelemetry version 0.15 support #54

Closed
sidharthv96 opened this issue Jan 25, 2021 · 9 comments · Fixed by #58
Closed

Opentelemetry version 0.15 support #54

sidharthv96 opened this issue Jan 25, 2021 · 9 comments · Fixed by #58

Comments

@sidharthv96
Copy link

As withSpan was removed, the plugin will not work anymore.

open-telemetry/opentelemetry-js#1764 (review)

Please mention in Readme to use version 0.14 till a fix is released.

@blumamir
Copy link
Contributor

Hi @sidharthv96
Since the plugins depend on @opentelemetry/api@^0.14.0, they should install v0.14.0 along with any other api versions and use it (and not v0.15.0).
Did you try it with v0.15.0 and had a compatibility issue? if so can you elaborate on what you observed?

Anyhow, we plan to migrate to v0.15.0 in the next week or so.

@sidharthv96
Copy link
Author

Yes, I'm pretty new to the OpenTelemetry Ecosystem and was following tutorials which only had npm install <package-name> so that installed v0.15 and when I later installed this plugin, it threw the error that this._tracer.withSpan is not a function.

The express plugin also had similar issue. I was able to find the root cause after some digging around the release notes and source code.

open-telemetry/opentelemetry-js#1764 (review) mentions how we should replace the usage of withSpan.

It works perfectly after I downgraded all the versions to 0.14. ❤️

@blumamir
Copy link
Contributor

@sidharthv96 cool thanks for letting us know.
I'll add the supported version to the README, and we'll upgrade all plugins to v0.15.0 soon.

Please let us know if you observe any other issues or experience unclarity when using this repo :)

@sidharthv96
Copy link
Author

Awesome!
Really blown away how easily everything works after the initial setup.
I expected some manual work to connect express traces with kafka traces, but it worked out of the box with no extra configs.
Keep up the amazing work! 🚀

@blumamir
Copy link
Contributor

Hi @sidharthv96 ,
I was trying to reproduce your issue but did not succeed in getting the error you are seeing.
Is it possible for you to share which plugin you were using and a minimal code snippet that reproduces it?

This is the code I run which did not throw the above error:

import { NodeTracerProvider } from '@opentelemetry/node';
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';

const provider = new NodeTracerProvider({
    plugins: {
      kafkajs: {
        enabled: true,
        // You may use a package name or absolute path to the file.
        path: "opentelemetry-plugin-kafkajs",
      },
    },
  });

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

provider.register();

import {Kafka} from 'kafkajs';
const kafka = new Kafka({
    clientId: 'open-telemetry-demo',
    brokers: ['localhost:9092'],
});
const producer = kafka.producer();
producer.connect().then( async () => {
    console.log('connected');
    await producer.send({topic: 'test', messages: [{value: 'hello world'}]});
});

and my package.json:

{
  "name": "otel-15-pg",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "ts-node index.ts"
  },
  "devDependencies": {
    "typescript": "^4.1.3"
  },
  "dependencies": {
    "@opentelemetry/node": "^0.15.0",
    "@opentelemetry/tracing": "^0.15.0",
    "kafkajs": "^1.15.0",
    "opentelemetry-plugin-kafkajs": "^0.1.2",
    "ts-node": "^9.1.1"
  }
}

and the output to console:

{
  traceId: '7dc0842279ec38e9847e9100a575a4b1',
  parentId: undefined,
  name: 'test',
  id: '1c37102b70e53445',
  kind: 3,
  timestamp: 1611668057292756,
  duration: 58030,
  attributes: {
    'messaging.system': 'kafka',
    'messaging.destination': 'test',
    'messaging.destination_kind': 'topic'
  },
  status: { code: 1 },
  events: []
}

@sidharthv96
Copy link
Author

I think we are missing something...

From these commits, the withSpan method has clearly been removed in api and tracing packages.

But it is used in the kafkajs plugin, so it should throw an error..

const eachMessagePromise = thisPlugin._tracer.withSpan(span, () => {

@sidharthv96
Copy link
Author

Got it @blumamir !
The withSpan part is only there in consumer tracer. So if you add a consumer to that topic, you should be able to replicate it.

@sidharthv96
Copy link
Author

image
Source

The change seems straight forward and is referenced in their upgrade guidelines.
image

@blumamir
Copy link
Contributor

Thanks, I managed to reproduce it with consumer 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants