Skip to content

v3: usage tracking #1163

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

Merged
merged 21 commits into from
Jun 18, 2024
Merged

v3: usage tracking #1163

merged 21 commits into from
Jun 18, 2024

Conversation

ericallam
Copy link
Member

In preparation for adding billing support for the v3 cloud, this PR introduces the tracking of run usage, and changes the machine configuration to use preset names instead of any combination of CPU/Memory.

Machine presets:

export const presets = {
  micro: {
    cpu: 0.25,
    memory: 0.25,
    centsPerMs: env.CENTS_PER_HOUR_MICRO / 3_600_000,
  },
  "small-1x": {
    cpu: 0.5,
    memory: 0.5,
    centsPerMs: env.CENTS_PER_HOUR_SMALL_1X / 3_600_000,
  },
  "small-2x": {
    cpu: 1,
    memory: 1,
    centsPerMs: env.CENTS_PER_HOUR_SMALL_2X / 3_600_000,
  },
  "medium-1x": {
    cpu: 1,
    memory: 2,
    centsPerMs: env.CENTS_PER_HOUR_MEDIUM_1X / 3_600_000,
  },
  "medium-2x": {
    cpu: 2,
    memory: 4,
    centsPerMs: env.CENTS_PER_HOUR_MEDIUM_2X / 3_600_000,
  },
  "large-1x": {
    cpu: 4,
    memory: 8,
    centsPerMs: env.CENTS_PER_HOUR_LARGE_1X / 3_600_000,
  },
  "large-2x": {
    cpu: 8,
    memory: 16,
    centsPerMs: env.CENTS_PER_HOUR_LARGE_2X / 3_600_000,
  },
};

You can also now configure a default machine in trigger.config.ts.

Copy link

changeset-bot bot commented Jun 13, 2024

⚠️ No Changeset found

Latest commit: bb5f836

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@samejr
Copy link
Member

samejr commented Jun 14, 2024

I think "Micro" should be renamed "extra-small-1x". "Micro" feels hard to place as a size and doesn't fit with the pattern which is nice other than this.

@ericallam ericallam force-pushed the v3/usage-tracking branch from 731aebd to c05d958 Compare June 14, 2024 12:33
.setIssuedAt()
.setIssuer("https://id.trigger.dev")
.setAudience("https://api.trigger.dev")
.setExpirationTime("2h")
Copy link
Member

Choose a reason for hiding this comment

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

What happens if some a task is still executing after 2 hours?

@matt-aitken
Copy link
Member

We need to support refreshing the JWT tokens because some runs last longer than a day

@ericallam ericallam force-pushed the v3/usage-tracking branch from 95e1bb8 to 9523366 Compare June 14, 2024 15:43
@ericallam ericallam merged commit 85a543d into main Jun 18, 2024
2 checks passed
@ericallam ericallam deleted the v3/usage-tracking branch June 18, 2024 08:40
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.

3 participants