diff --git a/docs/sources/reference/cli/environment-variables.md b/docs/sources/reference/cli/environment-variables.md index 3eebbce3ef..094c4d89bf 100644 --- a/docs/sources/reference/cli/environment-variables.md +++ b/docs/sources/reference/cli/environment-variables.md @@ -16,6 +16,8 @@ The following environment variables are supported: * `HTTP_PROXY` * `PPROF_MUTEX_PROFILING_PERCENT` * `PPROF_BLOCK_PROFILING_RATE` +* `GOMEMLIMIT` + Refer to the [Go runtime][runtime] documentation for more information about Go runtime environment variables. @@ -23,11 +25,11 @@ Refer to the [Go runtime][runtime] documentation for more information about Go r You can use the `GODEBUG` environment variable to control the debugging variables within the Go runtime. The following arguments are supported. -Argument | Description | Default ---------------------------------|------------------------------------------------------------------------------------------------------|-------- -`x509usefallbackroots` | Enforce a fallback on the X.509 trusted root certificates. Set to `1` to enable. | `0` -`netdns` | Force a resolver. Set to `go` for a pure Go resolver. Set to `cgo` or `win32` for a native resolver. | -`netdns` | Show resolver debugging information. Set to `1` for basic information. Set to `2` for verbose. | + Argument | Description | Default +------------------------|------------------------------------------------------------------------------------------------------|--------- + `x509usefallbackroots` | Enforce a fallback on the X.509 trusted root certificates. Set to `1` to enable. | `0` + `netdns` | Force a resolver. Set to `go` for a pure Go resolver. Set to `cgo` or `win32` for a native resolver. | + `netdns` | Show resolver debugging information. Set to `1` for basic information. Set to `2` for verbose. | ## HTTP_PROXY @@ -45,4 +47,21 @@ You can use the `PPROF_BLOCK_PROFILING_RATE` environment variable to define the * `1`: All mutexes are tracked. * A value greater than `1`: The number of nanoseconds to track mutexes. +### GOMEMLIMIT + +Usually, the [Go runtime][runtime] will release memory back to the operating system when requested. +In some environments, this may cause issues such as Out Of Memory (OOM) errors. +You can use the `GOMEMLIMIT` environment variable to set a soft memory cap and limit the maximum memory {{< param "PRODUCT_NAME" >}} can use. +You can set `GOMEMLIMIT` to a numeric value in bytes with an optional unit suffix. +The supported unit suffixes are `B`, `KiB`, `MiB`, `GiB`, and `TiB`. +Don't treat the `GOMEMLIMIT` environment variable as a hard memory limit. +{{< param "PRODUCT_NAME" >}} processes can use more memory if that memory is required. +A rough number is to set `GOMEMLIMIT` to is 90% of the maximum memory required. +For example, if you want to keep memory usage below `10GiB`, use `GOMEMLIMIT=9GiB`. + +#### Automatically set GOMEMLIMIT + +The `GOMEMLIMIT` environment variable is either automatically set to 90% of an available `cgroup` value, or you can explicitly set the `GOMEMLIMIT` environment variable before you run {{< param "PRODUCT_NAME" >}}. +No changes will occur if the limit cannot be determined and you did not explicitly define a `GOMEMLIMIT` value. + [runtime]: https://pkg.go.dev/runtime diff --git a/docs/sources/reference/cli/run.md b/docs/sources/reference/cli/run.md index c195c77940..f246bb894e 100644 --- a/docs/sources/reference/cli/run.md +++ b/docs/sources/reference/cli/run.md @@ -173,7 +173,6 @@ original configuration. Include `--config.extra-args` to pass additional command line flags from the original format to the converter. Refer to [alloy convert][] for more details on how `extra-args` work. - [alloy convert]: ../convert/ [clustering]: ../../../get-started/clustering/ [go-discover]: https://github.com/hashicorp/go-discover diff --git a/internal/alloycli/cmd_run.go b/internal/alloycli/cmd_run.go index 89357f2323..33f9798eb7 100644 --- a/internal/alloycli/cmd_run.go +++ b/internal/alloycli/cmd_run.go @@ -217,9 +217,7 @@ func (fr *alloyRun) Run(configPath string) error { // Set the memory limit, this will honor GOMEMLIMIT if set // If there is a cgroup will follow that - if fr.minStability.Permits(featuregate.StabilityPublicPreview) { - memlimit.SetGoMemLimitWithOpts(memlimit.WithLogger(slog.New(l.Handler()))) - } + memlimit.SetGoMemLimitWithOpts(memlimit.WithLogger(slog.New(l.Handler()))) // Enable the profiling. setMutexBlockProfiling(l) diff --git a/internal/component/otelcol/exporter/datadog/config/config_datadog_test.go b/internal/component/otelcol/exporter/datadog/config/config_datadog_test.go index 22a05370cb..365e800427 100644 --- a/internal/component/otelcol/exporter/datadog/config/config_datadog_test.go +++ b/internal/component/otelcol/exporter/datadog/config/config_datadog_test.go @@ -1,6 +1,5 @@ //go:build !freebsd - package datadog_config_test import ( diff --git a/internal/component/otelcol/exporter/datadog/datadog_test.go b/internal/component/otelcol/exporter/datadog/datadog_test.go index d83d2e3bdc..29f88c5d2d 100644 --- a/internal/component/otelcol/exporter/datadog/datadog_test.go +++ b/internal/component/otelcol/exporter/datadog/datadog_test.go @@ -1,6 +1,5 @@ //go:build !freebsd - package datadog_test import ( @@ -47,8 +46,8 @@ func TestConfigConversion(t *testing.T) { defaultClient = confighttp.ClientConfig{ Timeout: defaultTimeout, } - connsPerHost = 10 - connsPerHostPtr = &connsPerHost + connsPerHost = 10 + connsPerHostPtr = &connsPerHost ) tests := []struct { diff --git a/internal/component/prometheus/exporter/oracledb/oracledb.go b/internal/component/prometheus/exporter/oracledb/oracledb.go index 07e10aaf51..7d88bf085e 100644 --- a/internal/component/prometheus/exporter/oracledb/oracledb.go +++ b/internal/component/prometheus/exporter/oracledb/oracledb.go @@ -43,11 +43,11 @@ var ( // Arguments controls the oracledb exporter. type Arguments struct { - ConnectionString alloytypes.Secret `alloy:"connection_string,attr"` - MaxIdleConns int `alloy:"max_idle_conns,attr,optional"` - MaxOpenConns int `alloy:"max_open_conns,attr,optional"` - QueryTimeout int `alloy:"query_timeout,attr,optional"` - CustomMetrics alloytypes.OptionalSecret `alloy:"custom_metrics,attr,optional"` + ConnectionString alloytypes.Secret `alloy:"connection_string,attr"` + MaxIdleConns int `alloy:"max_idle_conns,attr,optional"` + MaxOpenConns int `alloy:"max_open_conns,attr,optional"` + QueryTimeout int `alloy:"query_timeout,attr,optional"` + CustomMetrics alloytypes.OptionalSecret `alloy:"custom_metrics,attr,optional"` } // SetToDefault implements syntax.Defaulter. diff --git a/internal/component/prometheus/exporter/oracledb/oracledb_test.go b/internal/component/prometheus/exporter/oracledb/oracledb_test.go index 713319065e..cded8b4b61 100644 --- a/internal/component/prometheus/exporter/oracledb/oracledb_test.go +++ b/internal/component/prometheus/exporter/oracledb/oracledb_test.go @@ -85,10 +85,10 @@ func TestArgumentsValidate(t *testing.T) { { name: "valid OracleDB", args: Arguments{ - ConnectionString: alloytypes.Secret("oracle://user:password@localhost:1521/orcl.localnet"), - MaxIdleConns: 1, - MaxOpenConns: 1, - QueryTimeout: 5, + ConnectionString: alloytypes.Secret("oracle://user:password@localhost:1521/orcl.localnet"), + MaxIdleConns: 1, + MaxOpenConns: 1, + QueryTimeout: 5, CustomMetrics: alloytypes.OptionalSecret{ Value: `metrics: - context: "slow_queries" @@ -162,7 +162,7 @@ func TestConvertNoCustom(t *testing.T) { MaxIdleConns: DefaultArguments.MaxIdleConns, MaxOpenConns: DefaultArguments.MaxOpenConns, QueryTimeout: DefaultArguments.QueryTimeout, - CustomMetrics: "", + CustomMetrics: "", } require.Equal(t, expected, *res) } diff --git a/internal/static/integrations/oracledb_exporter/oracledb_exporter.go b/internal/static/integrations/oracledb_exporter/oracledb_exporter.go index 004bd2a1a4..eaecf5672a 100644 --- a/internal/static/integrations/oracledb_exporter/oracledb_exporter.go +++ b/internal/static/integrations/oracledb_exporter/oracledb_exporter.go @@ -40,6 +40,7 @@ type Config struct { QueryTimeout int `yaml:"query_timeout"` CustomMetrics string `yaml:"custom_metrics,omitempty"` } + // ValidateConnString attempts to ensure the connection string supplied is valid // to connect to an OracleDB instance func validateConnString(connStr string) error { @@ -102,9 +103,9 @@ func New(logger log.Logger, c *Config) (integrations.Integration, error) { } oeExporter, err := oe.NewExporter(logger, &oe.Config{ - DSN: string(c.ConnectionString), - MaxIdleConns: c.MaxIdleConns, - MaxOpenConns: c.MaxOpenConns, + DSN: string(c.ConnectionString), + MaxIdleConns: c.MaxIdleConns, + MaxOpenConns: c.MaxOpenConns, CustomMetrics: c.CustomMetrics, QueryTimeout: c.QueryTimeout, })