Skip to main content

MongoDB

Beta

This feature is currently in beta and is subject to change. If you are interested in testing it out, please reach out to us via Discord or email out support.

MongoDB instrument to measure the performance of queries directly in the CI.

Getting Startedโ€‹

Prerequisitesโ€‹

  • MongoDB instrument enabled in your CodSpeed account (reach out to us to enable)
  • MongoDB instance running in your CI environment or the cloud
How to set up a MongoDB instance in your CI environment?

Activate the mongodb instrument in the CodSpeed Actionโ€‹

To activate the MongoDB instrument during the run of your benchmarks in the CodSpeed Action, make the following changes to your workflow file:

- name: Run benchmarks
uses: @CodSpeed/action@v2
run: <your-benchmark-command>
with:
# Activate the MongoDB instrument
instruments: mongodb
# (Optional) Specify the name of the environment variable that contains the MongoDB
# connection string and is used by your application to connect to MongoDB.
# If not specified, you will have to provide the connection string dynamically during
# the setup phase of your benchmarks.
mongo-uri-env-name: MONGO_URL
using mongo-uri-env-name

If using the mongo-uri-env-name option, make sure to set the actual value of the environment variable in the env section of your workflow file. Otherwise, the MongoDB instrument will not be able to connect to your MongoDB instance.

- name: Run benchmarks
uses: @CodSpeed/action@v2
run: <your-benchmark-command>
with:
instruments: mongodb
mongo-uri-env-name: MONGO_URL
env:
MONGO_URL: mongodb://localhost:27017
dynamic connection string

If the value of connection string cannot be set in the workflow file, you can omit the mongo-uri-env-name option and provide the connection string dynamically during the setup phase of your benchmarks.

- name: Run benchmarks
uses: @CodSpeed/action@v2
run: <your-benchmark-command>
with:
instruments: mongodb

Language specific examplesโ€‹

tip

If you are using the mongo-uri-env-name option, the integration should work out of the box at this stage ๐ŸŽ‰

However, if you are not using the mongo-uri-env-name option, you will have to provide the connection string dynamically during the setup phase of your benchmarks. Select your language below to see how to do that.

To view examples and how to dynamically provide the connection string during the setup phase of your benchmarks, select your language below:

  • Python: Not supported yet (coming soon)
  • Rust: Not supported yet (coming soon)