Skip to content

feat: add node_env to batch submitter#678

Merged
snario merged 5 commits intomasterfrom
feat/node_env
Apr 30, 2021
Merged

feat: add node_env to batch submitter#678
snario merged 5 commits intomasterfrom
feat/node_env

Conversation

@annieke
Copy link
Copy Markdown
Contributor

@annieke annieke commented Apr 28, 2021

Description
Our services currently run without knowing their environment, which adds extra overhead to how we distinguish errors and metrics between mainnet, kovan, and soon goerli. This PR adds NODE_ENV and ETH_NETWORK to the batch submitter and the related logic for Sentry and prom-client, so we can distinguish between local dev and deployments.

Additional context
I plan to make an equivalent PR for the data transport layer, but that requires a bigger refactor related to service-base so want to get this reviewed first.

Metadata

@annieke annieke requested a review from karlfloersch as a code owner April 28, 2021 19:56
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 28, 2021

⚠️ No Changeset found

Latest commit: 20b386f

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think about making the tracesSampleRate configurable itself instead of coupling it to an environment? Now if we want sentry on a different testnet, then we have to add code here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also NODE_ENV is used in the JS ecosystem to be production or development to differentiate between those things. https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production is an example. We have multiple "production" environments, in particular kovan and mainnet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i'm open to it! i don't love the extra moving piece, but if trace rate is the only thing we will distinguish between goerli and the others happy to make this an extra config. what else might we want to be different?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only other thing that appears to be different is the environment field passed into Metrics.labels. That could also be configured independently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

made this its own env var!

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

I don't love the idea of configuring things based on the name of the network, ie mainnet vs goerli because this results in needing to change code if we want to deploy to a different testnet. I could see us deploying to many ETH2 testnets in the future. I think that it would be better to just configure the actual values themselves instead of making them implicitly based on the network. This way we can change the values with a restart of the process in case we need to change them for some reason

@annieke annieke requested a review from snario April 28, 2021 20:17
@annieke annieke requested review from snario and tynes April 29, 2021 18:56
sentryOptions: {
release,
dsn: process.env.SENTRY_DSN,
tracesSampleRate: parseInt(process.env.SENTRY_TRACE_RATE, 10) || 0.05,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would we ever want to set this to 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tynes I equate that to not deploying sentry right now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would disable tracing, but we primary need sentry for error tracking, so setting it to 0 would still keep error tracking enabled.

@annieke annieke requested review from snario and tynes April 30, 2021 00:22
@snario snario merged commit 7e38638 into master Apr 30, 2021
@snario snario deleted the feat/node_env branch April 30, 2021 22:59
InoMurko pushed a commit to omgnetwork/optimism that referenced this pull request May 25, 2021
* add node_env to batch submitter

* rename log to logger for service consistency

* address review comments

* make ETH_NETWORK_NAME to disambiguate

* move tx data to debug
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