docs(commerce): add service README documenting LOG_LEVEL and env vars#7996
docs(commerce): add service README documenting LOG_LEVEL and env vars#7996mvanhorn wants to merge 2 commits intographql-hive:mainfrom
Conversation
Every service that parses `LOG_LEVEL` should document it in its README per graphql-hive#3462. The `commerce` service was the only one missing both a README and `LOG_LEVEL` documentation. Closes graphql-hive#3462
There was a problem hiding this comment.
Code Review
This pull request adds a comprehensive README for the @hive/commerce service, documenting its purpose and configuration options. The review feedback focuses on improving the accuracy and consistency of the configuration table by explicitly documenting default values for the RELEASE, PROMETHEUS_METRICS_LABEL_INSTANCE, REQUEST_LOGGING, and LOG_LEVEL environment variables.
| | ----------------------------------- | -------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | ||
| | `PORT` | No | The port this service is running on. | `4012` | | ||
| | `ENVIRONMENT` | No | The environment of your Hive app. (**Note:** This will be used for Sentry reporting.) | `staging` | | ||
| | `RELEASE` | No | The release identifier reported with Sentry events. | `v9.6.0` | |
There was a problem hiding this comment.
The RELEASE variable defaults to local in the code (packages/services/commerce/src/environment.ts:141). It should be documented here for completeness and consistency with other variables in this table.
| | `RELEASE` | No | The release identifier reported with Sentry events. | `v9.6.0` | | |
| | `RELEASE` | No | The release identifier reported with Sentry events. Defaults to local. | `v9.6.0` | |
References
- Focus on correctness and providing accurate documentation for the service configuration. (link)
| | `SENTRY` | No | Whether Sentry error reporting should be enabled. | `1` (enabled) or `0` (disabled) | | ||
| | `SENTRY_DSN` | No | The DSN for reporting errors to Sentry. Required when `SENTRY=1`. | `https://dooobars@o557896.ingest.sentry.io/12121212` | | ||
| | `PROMETHEUS_METRICS` | No | Whether Prometheus metrics should be enabled. | `1` (enabled) or `0` (disabled) | | ||
| | `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `commerce` | |
There was a problem hiding this comment.
The code defaults this to rate-limit (packages/services/commerce/src/environment.ts:173). While this might be a copy-paste artifact in the code (given this is the commerce service), the documentation should reflect the actual behavior.
| | `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `commerce` | | |
| | `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. Defaults to rate-limit. | `commerce` | |
References
- Focus on correctness and providing accurate documentation for the service configuration. (link)
| | `PROMETHEUS_METRICS` | No | Whether Prometheus metrics should be enabled. | `1` (enabled) or `0` (disabled) | | ||
| | `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `commerce` | | ||
| | `PROMETHEUS_METRICS_PORT` | No | Port on which prometheus metrics are exposed. Defaults to `10254`. | `10254` | | ||
| | `REQUEST_LOGGING` | No | Log http requests. | `1` (enabled) or `0` (disabled) | |
There was a problem hiding this comment.
The REQUEST_LOGGING variable defaults to 1 (enabled) in the code (packages/services/commerce/src/environment.ts:59-61). This should be mentioned in the description to match the format used for other variables in this file.
| | `REQUEST_LOGGING` | No | Log http requests. | `1` (enabled) or `0` (disabled) | | |
| | `REQUEST_LOGGING` | No | Log http requests. Defaults to 1. | `1` (enabled) or `0` (disabled) | |
References
- Focus on correctness and providing accurate documentation for the service configuration. (link)
| | `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `commerce` | | ||
| | `PROMETHEUS_METRICS_PORT` | No | Port on which prometheus metrics are exposed. Defaults to `10254`. | `10254` | | ||
| | `REQUEST_LOGGING` | No | Log http requests. | `1` (enabled) or `0` (disabled) | | ||
| | `LOG_LEVEL` | No | The verbosity of the service logs. One of `trace`, `debug`, `info`, `warn`, `error`, `fatal` or `silent` | `info` (default) | |
There was a problem hiding this comment.
For consistency with other entries in this table (e.g., lines 28, 30, 35), the default value should be mentioned in the 'Description' column rather than the 'Example Value' column.
| | `LOG_LEVEL` | No | The verbosity of the service logs. One of `trace`, `debug`, `info`, `warn`, `error`, `fatal` or `silent` | `info` (default) | | |
| | `LOG_LEVEL` | No | The verbosity of the service logs. One of `trace`, `debug`, `info`, `warn`, `error`, `fatal` or `silent`. Defaults to info. | `info` | |
References
- Focus on correctness and providing accurate documentation for the service configuration. (link)
…CS_LABEL_INSTANCE, REQUEST_LOGGING, and LOG_LEVEL gemini-code-assist review on graphql-hive#7996 asked for each env var's default to appear in the Description column for consistency with the rest of the table. Verified against src/environment.ts: - RELEASE -> 'local' (line 141) - PROMETHEUS_METRICS_LABEL_INSTANCE -> 'rate-limit' (line 173; likely a copy-paste from the rate-limit service, but it's the current behavior) - REQUEST_LOGGING -> '1' (line 59-61 .default('1')) - LOG_LEVEL -> 'info' (line 166)
|
Added defaults in af81781. Verified each against
|
Summary
Closes #3462. Adds a README for the
@hive/commerceservice, documenting every environment variable it parses (includingLOG_LEVEL). Thecommerceservice was the only one underpackages/services/without a README and was the only service still missingLOG_LEVELdocumentation from the original ask.Why this matters
@n1ru4l opened #3462 asking that
LOG_LEVELbe documented in every service README. Investigatingpackages/services/*/src/environment.tsshows 7 services parseLOG_LEVELtoday:commerce,policy,schema,server,tokens,usage,usage-ingestor,workflows. Cross-referencing each against its directory'sREADME.md, 6 of 7 already documentLOG_LEVEL— onlycommercewas missing, because it had no README at all.The new README also gives adopters a single place to look up what
commerceis (a tRPC router coveringusageEstimator,rateLimit, andstripeBilling, persrc/api.ts), along with its default port4012(fromenvironment.ts:64), which sibling READMEs already reference via theCOMMERCE_ENDPOINTvariable.Changes
packages/services/commerce/README.mdpackages/services/commerce/src/environment.ts, using the same GitHub-flavored Markdown layout aspackages/services/tokens/README.mdandpackages/services/usage/README.md.Requiredcolumn mirrors the zod schema (non-optional fields = Yes).LOG_LEVELdescription copied verbatim from the voice used in the sibling READMEs.No other files changed.
Testing
grep -rln "LOG_LEVEL" packages/services/*/src/environment.tsreturns the 7 services above.ls packages/services/commerce/before this PR:LICENSE package.json src tsconfig.json turbo.json(no README).environment.ts(no memory, no guesses). Default values and optionality flags match the code.COMMERCE_ENDPOINTcross-reference (http://127.0.0.1:4012) already lives inpackages/services/server/README.md:96andpackages/services/usage/README.md:14, so the port claim is cross-verified.Closes #3462
This contribution was developed with AI assistance (Claude Code).