Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for v4 of mongodb driver #105

Open
brycepolly opened this issue Oct 27, 2021 · 4 comments
Open

Support for v4 of mongodb driver #105

brycepolly opened this issue Oct 27, 2021 · 4 comments

Comments

@brycepolly
Copy link

Mongo dependency is not being monitored when using v4+ of the driver https://www.npmjs.com/package/mongodb/v/4.1.3

@berkcent
Copy link
Contributor

@hectorhdzg is there any plan for MongoDB Driver v4+ support?

@emmansun
Copy link

Any good news?

@hectorhdzg
Copy link
Member

We are in the process of using OpenTelemetry internally in Application Insights SDK to generate dependencies/requests data, OpenTelemetry currently supports v4 of MongoDB among other libraries, we are planning to release a beta version soon, we don't have plans to add the functionality in this package in the near future.

@emmansun
Copy link

well, then we use mongodb driver's APM to publish APM events manually as a temporary solution.

  mongoClient.on('commandStarted', (event) => {
    if (eventMap[event.requestId]) {
      return;
    }
    contextMap[event.requestId] = channel.bindToContext((cb) => cb());
    eventMap[event.requestId] = {
      ...event,
      time: new Date()
    };
  });
  mongoClient.on('commandSucceeded', (event) => {
    const startedData = eventMap[event.requestId];
    if (startedData) {
      delete eventMap[event.requestId];
    }
    if (typeof event === 'object' && typeof contextMap[event.requestId] === 'function') {
      contextMap[event.requestId](() => channel.publish('mongodb', { startedData, event, succeeded: true }));
      delete contextMap[event.requestId];
    }
  });
  mongoClient.on('commandFailed', (event) => {
    const startedData = eventMap[event.requestId];
    if (startedData) {
      delete eventMap[event.requestId];
    }
    if (typeof event === 'object' && typeof contextMap[event.requestId] === 'function') {
      contextMap[event.requestId](() => channel.publish('mongodb', { startedData, event, succeeded: false }));
      delete contextMap[event.requestId];
    }
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants