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

feat(node): Instrumentation for node-cron library #9904

Merged
merged 17 commits into from
Jan 3, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Dec 18, 2023

Closes #9892

Usage

import * as Sentry from "@sentry/node";
import cron from "node-cron";

const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);

cronWithCheckIn.schedule(
  "* * * * *",
  () => {
    console.log("running a task every minute");
  },
  { name: "my-cron-job" },
);

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO let's namespace all the cron instrumentation under Sentry.cron.instrumentNodeCron. We don't have to care about treeshaking for this, and we avoid polluting global namespace.

@AbhiPrasad AbhiPrasad added the ci-codecov-ai-review AI Review by Codecov label Dec 19, 2023
@AbhiPrasad
Copy link
Member

gonna test something out with this PR

@timfish timfish marked this pull request as ready for review December 19, 2023 18:17
packages/node/src/checkin/node-cron.ts Outdated Show resolved Hide resolved
packages/node/src/cron/index.ts Outdated Show resolved Hide resolved
@timfish
Copy link
Collaborator Author

timfish commented Dec 21, 2023

I've moved replaceCronNames to common.ts as I need this for the other instrumentations!

@timfish timfish changed the title feat(node): Add wrapping of node-cron for check-ins feat(node): Instrumentation for node-cron library Dec 31, 2023
@timfish
Copy link
Collaborator Author

timfish commented Jan 3, 2024

This is now exported from all the downstream packages.

@AbhiPrasad AbhiPrasad merged commit da7c959 into getsentry:develop Jan 3, 2024
55 checks passed
@timfish timfish deleted the feat/node-cron-wrap branch January 10, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-codecov-ai-review AI Review by Codecov
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instrumentation for node-cron library
3 participants