|
| 1 | +# gRPC-Go Environment Variables |
| 2 | + |
| 3 | +This document lists the environment variables supported by the grpc-go |
| 4 | +implementation. |
| 5 | + |
| 6 | +Variables whose names contain `EXPERIMENTAL` are intentionally not documented |
| 7 | +here: they guard features that are still in development, and they may change |
| 8 | +behavior, change defaults, or be removed entirely in any release without |
| 9 | +notice. |
| 10 | + |
| 11 | +Unless stated otherwise, boolean variables are case-insensitive and only the |
| 12 | +values `true` and `false` are recognized; any other value leaves the default |
| 13 | +in effect. |
| 14 | + |
| 15 | +## Logging |
| 16 | + |
| 17 | +See [Log Levels](Documentation/log_levels.md) for a description of the log |
| 18 | +severities and how they are used. |
| 19 | + |
| 20 | +* `GRPC_GO_LOG_SEVERITY_LEVEL` |
| 21 | + |
| 22 | + The minimum severity of log messages written to stderr by the default |
| 23 | + logger. One of `ERROR`, `WARNING` or `INFO` (e.g. `INFO` enables info, |
| 24 | + warning and error logs). Defaults to `ERROR`. Has no effect if the |
| 25 | + application replaces the default logger via |
| 26 | + [`grpclog.SetLoggerV2`](https://pkg.go.dev/google.golang.org/grpc/grpclog#SetLoggerV2). |
| 27 | + |
| 28 | +* `GRPC_GO_LOG_VERBOSITY_LEVEL` |
| 29 | + |
| 30 | + The verbosity of info log messages, as a non-negative integer. Info logs |
| 31 | + at verbosity levels less than or equal to this value are emitted (subject |
| 32 | + to `GRPC_GO_LOG_SEVERITY_LEVEL` enabling info logs). Defaults to `0`. |
| 33 | + |
| 34 | +* `GRPC_GO_LOG_FORMATTER` |
| 35 | + |
| 36 | + Set to `json` to make the default logger emit log messages as JSON |
| 37 | + objects. Any other value uses the default plain-text format. |
| 38 | + |
| 39 | +## Binary logging |
| 40 | + |
| 41 | +* `GRPC_BINARY_LOG_FILTER` |
| 42 | + |
| 43 | + Enables binary logging and selects which methods are logged, as described |
| 44 | + in [gRFC A16](https://github.com/grpc/proposal/blob/master/A16-binary-logging.md). |
| 45 | + The value is a comma-separated list of method patterns, e.g. `*` (all |
| 46 | + methods), `package.Service/Method`, `package.Service/*`, or |
| 47 | + `-package.Service/Method` to exclude a method. A pattern may be suffixed |
| 48 | + with `{h[:len]}`, `{m[:len]}` or `{h[:len];m[:len]}` to limit the logged |
| 49 | + header and message sizes. Unset or empty disables binary logging. |
| 50 | + |
| 51 | +## Name resolution |
| 52 | + |
| 53 | +* `GRPC_ENABLE_TXT_SERVICE_CONFIG` |
| 54 | + |
| 55 | + Whether the DNS resolver performs TXT record lookups to retrieve the |
| 56 | + service config, as described in |
| 57 | + [gRFC A2](https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md). |
| 58 | + Defaults to `true`. |
| 59 | + |
| 60 | +* `GRPC_GO_IGNORE_TXT_ERRORS` |
| 61 | + |
| 62 | + Whether the DNS resolver ignores errors from TXT record lookups. When |
| 63 | + `true`, TXT lookup failures are logged but resolution proceeds without a |
| 64 | + service config; when `false`, the error is reported to the channel. |
| 65 | + Defaults to `true`. |
| 66 | + |
| 67 | +## xDS |
| 68 | + |
| 69 | +* `GRPC_XDS_BOOTSTRAP` |
| 70 | + |
| 71 | + Path to a file containing the xDS bootstrap configuration in JSON format. |
| 72 | + Takes precedence over `GRPC_XDS_BOOTSTRAP_CONFIG` if both are set. |
| 73 | + |
| 74 | +* `GRPC_XDS_BOOTSTRAP_CONFIG` |
| 75 | + |
| 76 | + The xDS bootstrap configuration itself, in JSON format. Used only if |
| 77 | + `GRPC_XDS_BOOTSTRAP` is unset. |
| 78 | + |
| 79 | +## Load balancing |
| 80 | + |
| 81 | +* `GRPC_RING_HASH_CAP` |
| 82 | + |
| 83 | + The maximum ring size for the |
| 84 | + [`ring_hash`](https://github.com/grpc/proposal/blob/master/A42-xds-ring-hash-lb-policy.md) |
| 85 | + load balancing policy. Configured ring sizes are capped at this value. |
| 86 | + Defaults to `4096`; values are clamped to the range `[1, 8388608]` (8M). |
| 87 | + This does not affect config validation, which rejects ring sizes larger |
| 88 | + than 8M. |
| 89 | + |
| 90 | +* `GRPC_XDS_ENDPOINT_HASH_KEY_BACKWARD_COMPAT` |
| 91 | + |
| 92 | + Set to `true` to restore the behavior that predates the endpoint hash key |
| 93 | + support from |
| 94 | + [gRFC A76](https://github.com/grpc/proposal/blob/master/A76-ring-hash-improvements.md), |
| 95 | + ignoring the hash key from EDS endpoint metadata. Defaults to `false`. |
| 96 | + This variable is transitional and will be removed in a future release. |
| 97 | + |
| 98 | +## Security |
| 99 | + |
| 100 | +* `GRPC_ENFORCE_ALPN_ENABLED` |
| 101 | + |
| 102 | + Whether TLS connections to peers that do not negotiate ALPN are rejected. |
| 103 | + HTTP/2 requires ALPN; this variable exists only for backward compatibility |
| 104 | + with non-compliant peers, and may be removed in a future release. Defaults |
| 105 | + to `true`. |
| 106 | + |
| 107 | +* `GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES` |
| 108 | + |
| 109 | + The maximum number of concurrent ALTS handshakes. Defaults to `100`; |
| 110 | + values are clamped to the range `[1, 100]`. |
| 111 | + |
| 112 | +## Server |
| 113 | + |
| 114 | +* `GRPC_GO_SERVER_GOROUTINE_LABELS` |
| 115 | + |
| 116 | + Controls the [runtime/pprof labels](https://pkg.go.dev/runtime/pprof#Labels) |
| 117 | + set on goroutines spawned by `grpc.Server` to handle incoming requests. |
| 118 | + The value is a comma-separated list of `label=true|false` entries; |
| 119 | + `grpc.method` is currently the only supported label. The values `all` and |
| 120 | + `none` enable and disable all supported labels. Defaults to no labels. |
| 121 | + |
| 122 | +## GCP observability |
| 123 | + |
| 124 | +Used by the [gcp/observability](https://pkg.go.dev/google.golang.org/grpc/gcp/observability) |
| 125 | +package; see its documentation for the configuration schema. |
| 126 | + |
| 127 | +* `GRPC_GCP_OBSERVABILITY_CONFIG_FILE` |
| 128 | + |
| 129 | + Path to a file containing the observability configuration in JSON format. |
| 130 | + Takes precedence over `GRPC_GCP_OBSERVABILITY_CONFIG` if both are set. |
| 131 | + |
| 132 | +* `GRPC_GCP_OBSERVABILITY_CONFIG` |
| 133 | + |
| 134 | + The observability configuration itself, in JSON format. Used only if |
| 135 | + `GRPC_GCP_OBSERVABILITY_CONFIG_FILE` is unset. |
0 commit comments