Skip to content

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

Merged
AbhiPrasad merged 17 commits intogetsentry:developfrom
timfish:feat/node-cron-wrap
Jan 3, 2024
Merged

feat(node): Instrumentation for node-cron library#9904
AbhiPrasad merged 17 commits intogetsentry:developfrom
timfish:feat/node-cron-wrap

Conversation

@timfish
Copy link
Copy Markdown
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" },
);

@timfish timfish requested a review from AbhiPrasad December 19, 2023 11:32
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

gonna test something out with this PR

@timfish timfish marked this pull request as ready for review December 19, 2023 18:17
@AbhiPrasad AbhiPrasad requested a review from gaprl December 19, 2023 19:20
@timfish timfish requested a review from AbhiPrasad December 21, 2023 14:09
@timfish
Copy link
Copy Markdown
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
Copy Markdown
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
@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