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

Add script to test live API integration #128

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Mr0grog
Copy link
Collaborator

@Mr0grog Mr0grog commented Nov 11, 2024

⚠️ Depends on #125. It was just easier to write this against promises. But it can be re-done with callbacks if needed.

This adds a npm run check-integration script that sends some metrics to Datadog using this library, then queries the API for those same metric values to make sure they were successfully ingested and will be visible in Datadog's UI.

The goal here is to provide a minimal check of real, live integration in case a change to the actual reporter or Datadog client breaks or mis-formats something in a way that our unit tests don’t effectively catch. In most cases, our unit tests should be enough (this is why we use nock instead of just mocking the Datadog client), so this check is pretty lightweight (it only checks one metric type, for example).

I haven’t included any CI changes since @dbader would need to configure CI with working credentials. If we get that going, great, otherwise this will just have to be something maintainers run locally as needed (mainly before publishing releases).

Fixes #89.

This basic script sends some metrics to Datadog using this library, then queries the API for those same values to make sure they were successfully ingested and will be visible in Datadog's UI. This is mainly meant as a simple test to ensure changes to the underlying Datadog client keep sending things in the correct form. Unit tests *mostly* cover this use case, so the check here is pretty lightweight. We don't check every metric type, for example. But this is still important.

Fixes #89.
@Mr0grog Mr0grog force-pushed the 89-it-never-hurts-to-check-the-live-api branch from 6406f08 to ebfe508 Compare November 12, 2024 20:27
It turns out Mocha was seeing these (or at least the ones that are JS) and at least executing the top-level code. We could adjust Mocha's settings, but it's probably better to separate these checks anyway, since they aren't really unit tests.
@Mr0grog Mr0grog changed the base branch from 84-async-promise-support-is-overdue to main November 12, 2024 20:44
@Mr0grog
Copy link
Collaborator Author

Mr0grog commented Nov 12, 2024

I updated this to not depend on #125, which is a lot more complicated to review. I also moved this script and a couple others from the test directory into a new test-other directory, so test is just unit-tests, and test-other is other tooling or scripts that test things (linting comments and docs, testing types, etc.).

@dbader any chance you are able to add credentials for a test Datadog account to the repository secrets? Then I can add a CI workflow for this. I have usable credentials if you don’t; just send me an e-mail if you want them.

Since distributions get send through an entirely different API endpoint, we should include them in the test.
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

Successfully merging this pull request may close these issues.

Add tests for actual metrics submission to Datadog
1 participant