-
Notifications
You must be signed in to change notification settings - Fork 227
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
chore: add TAV tests for mongoose #3408
Closed
Closed
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
72584ad
chore: add mongoose samples
david-luna 5c82542
Merge branch 'main' into dluna/3161-mongoose-spans-in-wrong-transaction
david-luna a69ad83
chore: add TAV tests for mongoose
david-luna 8d53c5f
chore: update comments
david-luna 1a20122
chore: update docs
david-luna 815e9aa
chore: removed test file
david-luna 6108ce5
chore: fix lint
david-luna 039fa70
chore: add guards for incompatible versions of node
david-luna fe66297
need to start mongodb service for mongoose tests
trentm cc68cdf
chore: split tests
david-luna bbe1f49
Merge branch 'dluna/3161-mongoose-spans-in-wrong-transaction' of gith…
david-luna b0f1f33
chore: simplify test
david-luna a13283c
chore: remove mongoose from dependencies
david-luna 31f645c
chore: add mongoose as devDependency
david-luna 91cc1b7
chore: simplify test
david-luna 10d397b
chore: simplify test
david-luna df9e7f5
chore: removed deps
david-luna 899c7d0
chore: do not test with context manager = patch
david-luna f393366
Merge branch 'main' into dluna/3161-mongoose-spans-in-wrong-transaction
david-luna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
"memcached", | ||
"mongodb", | ||
"mongodb-core", | ||
"mongoose", | ||
"mysql", | ||
"mysql2", | ||
"next", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that mongoose is in devDeps, I think the change in this file can be dropped as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and other contributors where applicable. | ||
* Licensed under the BSD 2-Clause License; you may not use this file except in | ||
* compliance with the BSD 2-Clause License. | ||
*/ | ||
|
||
// A small example showing Elastic APM tracing the 'mongoose' package. | ||
// | ||
// This assumes a MongoDB server running on localhost. You can use: | ||
// npm run docker:start mongodb | ||
// to start a MongoDB docker container. Then `npm run docker:stop` to stop it. | ||
// | ||
// Some of the following code is adapted from | ||
// https://github.com/Automattic/mongoose/tree/master/examples/statics | ||
|
||
const apm = require('../').start({ // elastic-apm-node | ||
serviceName: 'example-trace-mongoose', | ||
logUncaughtExceptions: true | ||
}) | ||
|
||
const mongoose = require('mongoose') | ||
|
||
const DB_URL = 'mongodb://localhost:27017/example-trace-mongoose' | ||
|
||
// Define a schema. | ||
const PersonSchema = new mongoose.Schema({ | ||
name: String, | ||
age: Number, | ||
birthday: Date | ||
}) | ||
mongoose.model('Person', PersonSchema) | ||
|
||
async function run () { | ||
// For tracing spans to be created, there must be an active transaction. | ||
// Typically, a transaction is automatically started for incoming HTTP | ||
// requests to a Node.js server. However, because this script is not running | ||
// an HTTP server, we manually start a transaction. More details at: | ||
// https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html | ||
const t1 = apm.startTransaction('t1') | ||
|
||
const Person = mongoose.model('Person') | ||
await mongoose.connect(DB_URL) | ||
|
||
const bill = await Person.create({ | ||
name: 'bill', | ||
age: 25, | ||
birthday: new Date().setFullYear((new Date().getFullYear() - 25)) | ||
}) | ||
console.log('Person added to db: %s', bill) | ||
|
||
const result = await Person.find({}) | ||
console.log('find result:', result) | ||
|
||
// Cleanup. | ||
await Person.deleteMany() | ||
await mongoose.disconnect() | ||
t1.end() | ||
} | ||
|
||
run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THis puts us at 34 * 7 = 238 combinations, so still under the 256 GH actions jobs limit. All good.