Comments (13)
If the mongodb-core plugin worked with Mongoose that would be great, I don't think a specific mongoose plugin is needed.
from dd-trace-js.
What is the version of the underlying mongodb-core
module that is pulled as a transitive dependency?
from dd-trace-js.
I tried it with Mongoose 5.2.4, which uses mongodb-core 3.1.0
from dd-trace-js.
I'll have to try it. I wonder if it's in the way that mongoose
uses mongodb-core
.
Is this issue basically just to fix the mongodb-core
plugin or are you looking for an actual mongoose
plugin as well?
from dd-trace-js.
Just wrote a simple test case using findOne()
and I get a span as expected.
Are you loading mongoose
before or after calling tracer.trace()
? Also, are you using import
or require
? Sometimes the order will change once transpiled when using import
because of hoisting.
from dd-trace-js.
I am using Express, and Mongoose, Express tracing is working fine, and I get the http requests too, but mongo does nothing.
Here is a copy of the order I am bringing in the my libraries:
const when = require('when');
const request = require('request');
const requestRetry = require('requestretry');
const ioredis = require('ioredis');
const compression = require('compression');
const config = require('./src/config.js');
const tracer = require('dd-trace').init({
service : 'ls-service-'+ config.ENVIRONMENT,
//hostname: 'service.' + config.ENVIRONMENT,
hostname: 'host.docker.internal',
port: 8126,
debug: true,
});
tracer.use('express');
//tracer.trace();
const mongoose = require('mongoose');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
This is the one I just tested adding tracer.trace(); and I get a deprecatin warning for it saying "Please use tracer.startSpan() and tracer.scopeManager() instead.See: https://datadog.github.io/dd-trace-js/#manual-instrumentation."
I also tried adding tracer.use('mongodb-core'); but from what I understand, it doesn't matter if I have plugins defaulted to true.
from dd-trace-js.
It is correct that tracer.use()
is not necessary if you don't explicitly disable all plugins in the configuration.
The code from the snippet you provided seems correct. Would you be able to provide a small sample of Mongoose code that you would expect to get a span but doesn't?
Also, which version of the tracer are you using?
from dd-trace-js.
I decided to try it on a different server that has a more simplified layout. And it is working with Mongoose and Express. The difference is that it has all of its functions in the 1 file, and the model as a separate file. The service it wasn't working with, has the express message handlers in an a separate file, which call the models in.
Server1 (not working)
app.js
---> Message-handlers.js
\---> Models.js
Server2 (working)
app.js
---> Models.js
I am using dd-trace version 0.5.3
from dd-trace-js.
This shouldn't change the behavior. Is it possible maybe that this line const config = require('./src/config.js');
requires mongoose
by indirection?
from dd-trace-js.
Thank you. That fixed it, it now shows up. All my tests I hadn't put it above config as I wanted the environment from the config.
It doesn't seem to grab the parent span/scope with it, all the Mongo queries are separately listed in the traces. Would that be because of the extra tier of requires?
It works perfectly on our "Server2", and properly attaches the Mongo query to the Express request.
I should also mention the Mongo queries show up, but they have long strings attached to them, which breaks the formatting on the Datadog APM page.
Here is a sample name:
find database-stage.organisations {"_id":{"_bsontype":"?","id":{"0":"?","1":"?","2":"?","3":"?","4":"?","5":"?","6":"?","7":"?","8":"?","9":"?","10":"?","11":"?","asciiSlice":"?","base64Slice":"?","latin1Slice":"?","hexSlice":"?","ucs2Slice":"?","utf8Slice":"?","asciiWrite":"?","base64Write":"?","latin1Write":"?","hexWrite":"?","ucs2Write":"?","utf8Write":"?","parent":{},"offset":"?","copy":"?","toString":"?","equals":"?","inspect":"?","compare":"?","indexOf":"?","lastIndexOf":"?","includes":"?","fill":"?","write":"?","toJSON":"?","slice":"?","readUIntLE":"?","readUIntBE":"?","readUInt8":"?","readUInt16LE":"?","readUInt16BE":"?","readUInt32LE":"?","readUInt32BE":"?","readIntLE":"?","readIntBE":"?","readInt8":"?","readInt16LE":"?","readInt16BE":"?","readInt32LE":"?","readInt32BE":"?","readFloatLE":"?","readFloatBE":"?","readDoubleLE":"?","readDoubleBE":"?","writeUIntLE":"?","writeUIntBE":"?","writeUInt8":"?","writeUInt16LE":"?","writeUInt16BE":"?","writeUInt32LE":"?","writeUInt32BE":"?","writeIntLE":"?","writeIntBE":"?","writeInt8":"?","writeInt16LE":"?","writeInt16BE":"?","writeInt32LE":"?","writeInt32BE":"?","writeFloatLE":"?","writeFloatBE":"?","writeDoubleLE":"?","writeDoubleBE":"?","swap16":"?","swap32":"?","swap64":"?","toLocaleString":"?"},"toHexString":"?","get_inc":"?","getInc":"?","generate":"?","toString":"?","toJSON":"?","equals":"?","getTimestamp":"?","generationTime":"?"}}
from dd-trace-js.
It doesn't seem to grab the parent span/scope with it, all the Mongo queries are separately listed in the traces.
I see you are using when
which handles promises in a way that is not compatible with context propagation. We will look at patching the most popular promise libraries eventually, but for the moment this is unfortunately not supported. Using the native Promise if you can would fix the issue. Otherwise you could also propagate the context manually as well.
I should also mention the Mongo queries show up, but they have long strings attached to them, which breaks the formatting on the Datadog APM page.
This is definitely not the expected behavior. While the format of the string is correct, it shouldn't contain all these buffer methods. I'll have to take a look.
from dd-trace-js.
This was fixed in #241
@AndrewLugg Can you confirm if it ended up working for you?
from dd-trace-js.
Yes this is working for us. Thank you.
from dd-trace-js.
Related Issues (20)
- Next.JS plugin integration HOT 5
- Question: Way to map specific aws resources to custom names
- Mapping request headers to baggage keys HOT 1
- Express plugin not working HOT 1
- Kafka.js instrumentation causes unhandled rejections
- Support Mocha parallel tests HOT 3
- dd-trace breaks in ESM when using package with circular imports HOT 2
- Properly name `bulkWrite` operations in the mongo plugin
- datadog-plugin-graphql is not validating if directives is an array HOT 5
- Cypress tests not reporting correctly in CI Testing Visibility with `cypress-fail-fast` HOT 24
- Timeout Errors not Displayed in Datadog Dashboard Despite Successful Reporting with DD_TRACE_DEBUG HOT 9
- Segmentation for monorepos HOT 5
- Official DD-tracer Document should be updated to point out `none` OF DBM option is replaced with value `disabled` HOT 2
- Unhandled rejection thrown with Mongodb 6.4.0 HOT 1
- Add tags to the Service Entry Span in Middleware HOT 1
- How to trace jest with custom environment HOT 1
- Code that outputs neverthrow ResultAsync promise-like objects cannot be traced or wrapped
- Dogstatsd is undefined during jest tests HOT 7
- Added histogram method to dogstatsd
- Difficulties adding TAGS to test executions in CI Test Visibility HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dd-trace-js.