diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9766f45700..fa39ffa5424 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: name: Lint runs-on: ubuntu-latest steps: + - name: Check out code uses: actions/checkout@v4 with: @@ -29,6 +30,7 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: "go.mod" + - name: check-fmt run: make check-fmt @@ -38,6 +40,9 @@ jobs: - name: lint run: make lint base=origin/${{github.base_ref}} + - name: generate-manifest + run: go run pkg/docsgen/generate_manifest.go + unit-tests: name: Run Unit Tests runs-on: ubuntu-latest diff --git a/cmd/tempo/app/app.go b/cmd/tempo/app/app.go index 732ec877336..1aa7133d706 100644 --- a/cmd/tempo/app/app.go +++ b/cmd/tempo/app/app.go @@ -270,7 +270,7 @@ func (t *App) writeStatusConfig(w io.Writer, r *http.Request) error { mode := r.URL.Query().Get("mode") switch mode { case "diff": - defaultCfg := newDefaultConfig() + defaultCfg := NewDefaultConfig() defaultCfgYaml, err := util.YAMLMarshalUnmarshal(defaultCfg) if err != nil { @@ -287,7 +287,7 @@ func (t *App) writeStatusConfig(w io.Writer, r *http.Request) error { return err } case "defaults": - output = newDefaultConfig() + output = NewDefaultConfig() case "": output = t.cfg default: diff --git a/cmd/tempo/app/config.go b/cmd/tempo/app/config.go index 2dc26d9ebbe..bcb483a8af6 100644 --- a/cmd/tempo/app/config.go +++ b/cmd/tempo/app/config.go @@ -56,7 +56,7 @@ type Config struct { CacheProvider cache.Config `yaml:"cache,omitempty"` } -func newDefaultConfig() *Config { +func NewDefaultConfig() *Config { defaultConfig := &Config{} defaultFS := flag.NewFlagSet("", flag.PanicOnError) defaultConfig.RegisterFlagsAndApplyDefaults("", defaultFS) diff --git a/cmd/tempo/app/config_test.go b/cmd/tempo/app/config_test.go index 1f2ccaa8c8c..85b1a93ae1a 100644 --- a/cmd/tempo/app/config_test.go +++ b/cmd/tempo/app/config_test.go @@ -25,7 +25,7 @@ func TestConfig_CheckConfig(t *testing.T) { }{ { name: "check default cfg and expect no warnings", - config: newDefaultConfig(), + config: NewDefaultConfig(), expect: nil, }, { @@ -76,7 +76,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "hit local backend warnings", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace = tempodb.Config{ Backend: backend.Local, BlocklistPollConcurrency: 1, @@ -92,7 +92,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "warnings for v2 settings when they drift from default", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace.Block.Version = vparquet4.VersionString cfg.StorageConfig.Trace.Block.IndexDownsampleBytes = 1 cfg.StorageConfig.Trace.Block.IndexPageSizeBytes = 1 @@ -112,7 +112,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "no warnings for v2 settings when they drift from default and v2 is the block version", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace.Block.Version = v2.VersionString cfg.StorageConfig.Trace.Block.IndexDownsampleBytes = 1 cfg.StorageConfig.Trace.Block.IndexPageSizeBytes = 1 @@ -126,7 +126,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "trace storage conflicts with overrides storage - local", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace.Backend = backend.Local cfg.StorageConfig.Trace.Local.Path = "/var/tempo" cfg.Overrides.UserConfigurableOverridesConfig.Client.Backend = backend.Local @@ -138,7 +138,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "trace storage conflicts with overrides storage - gcs", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace.Backend = backend.GCS cfg.StorageConfig.Trace.GCS.BucketName = "bucketname" cfg.StorageConfig.Trace.GCS.Prefix = "tempo" @@ -152,7 +152,7 @@ func TestConfig_CheckConfig(t *testing.T) { { name: "trace storage conflicts with overrides storage - different backends", config: func() *Config { - cfg := newDefaultConfig() + cfg := NewDefaultConfig() cfg.StorageConfig.Trace.Backend = backend.GCS cfg.StorageConfig.Trace.GCS.BucketName = "my-bucket" cfg.Overrides.UserConfigurableOverridesConfig.Client.Backend = backend.S3 diff --git a/docs/sources/tempo/configuration/manifest.md b/docs/sources/tempo/configuration/manifest.md index 99f82726ff6..842343b51e9 100644 --- a/docs/sources/tempo/configuration/manifest.md +++ b/docs/sources/tempo/configuration/manifest.md @@ -3,6 +3,8 @@ title: Manifest description: This manifest lists of all Tempo options and their defaults. weight: 110 --- +[//]: # THIS FILE IS GENERATED AUTOMATICALLY BY 'go run pkg/docsgen/generate_manifest.go' +[//]: # DO NOT EDIT THIS FILE DIRECTLY' # Manifest @@ -10,17 +12,8 @@ This document is a reference for all Tempo options and their defaults. If you ar started with Tempo, refer to [Tempo examples](https://github.com/grafana/tempo/tree/main/example/docker-compose) and other [configuration documentation]({{< relref "../configuration" >}}). Most installations will require only setting 10 to 20 of these options. -It was generated by running Tempo with a minimal configuration and accessing the `/status/config` endpoint: -``` -go run ./cmd/tempo --storage.trace.backend=local --storage.trace.local.path=/var/tempo/traces --storage.trace.wal.path=/var/tempo/wal -``` - ## Complete configuration -{{< admonition type="note" >}} -This manifest was generated on 2024-11-28. -{{% /admonition %}} - ```yaml target: all http_api_prefix: "" @@ -177,7 +170,7 @@ distributor: mirror_timeout: 2s heartbeat_period: 5s heartbeat_timeout: 5m0s - instance_id: local-instance + instance_id: instance_id instance_interface_names: - eth0 - en0 @@ -202,7 +195,7 @@ ingester_client: grpc_client_config: max_recv_msg_size: 104857600 max_send_msg_size: 104857600 - grpc_compression: snappy + grpc_compression: "" rate_limit: 0 rate_limit_burst: 0 backoff_on_ratelimits: false @@ -233,7 +226,7 @@ metrics_generator_client: grpc_client_config: max_recv_msg_size: 104857600 max_send_msg_size: 104857600 - grpc_compression: snappy + grpc_compression: "" rate_limit: 0 rate_limit_burst: 0 backoff_on_ratelimits: false @@ -270,7 +263,7 @@ querier: time_overlap_cutoff: 0.2 max_concurrent_queries: 20 frontend_worker: - frontend_address: 127.0.0.1:9095 + frontend_address: "" dns_lookup_duration: 10s parallelism: 2 match_max_concurrent: true @@ -278,7 +271,7 @@ querier: grpc_client_config: max_recv_msg_size: 104857600 max_send_msg_size: 16777216 - grpc_compression: gzip + grpc_compression: "" rate_limit: 0 rate_limit_burst: 0 backoff_on_ratelimits: false @@ -370,7 +363,7 @@ compactor: heartbeat_timeout: 1m0s wait_stability_min_duration: 1m0s wait_stability_max_duration: 5m0s - instance_id: local-instance + instance_id: instance_id instance_interface_names: - eth0 - en0 @@ -395,7 +388,7 @@ ingester: lifecycler: ring: kvstore: - store: inmemory + store: memberlist prefix: collectors/ consul: host: localhost:8500 @@ -435,16 +428,16 @@ ingester: join_after: 0s min_ready_duration: 15s interface_names: - - en0 + - eth0 enable_inet6: false final_sleep: 0s tokens_file_path: "" availability_zone: "" unregister_on_shutdown: true readiness_check_ring_health: true - address: 127.0.0.1 + address: "" port: 0 - id: local-instance + id: instance_id concurrent_flushes: 4 flush_check_period: 10s flush_op_timeout: 5m0s @@ -457,7 +450,7 @@ ingester: metrics_generator: ring: kvstore: - store: inmemory + store: memberlist prefix: collectors/ consul: host: localhost:8500 @@ -488,11 +481,11 @@ metrics_generator: mirror_timeout: 2s heartbeat_period: 5s heartbeat_timeout: 1m0s - instance_id: local-instance + instance_id: instance_id instance_interface_names: - eth0 - en0 - instance_addr: 127.0.0.1 + instance_addr: "" instance_port: 0 enable_inet6: false processor: @@ -616,7 +609,6 @@ storage: v2_encoding: snappy search_encoding: none ingestion_time_range_slack: 2m0s - version: vParquet4 block: bloom_filter_false_positive: 0.01 bloom_filter_shard_size_bytes: 102400 @@ -648,9 +640,9 @@ storage: blocklist_poll_tolerate_tenant_failures: 1 empty_tenant_deletion_enabled: false empty_tenant_deletion_age: 0s - backend: local + backend: "" local: - path: /var/tempo/traces + path: "" gcs: bucket_name: "" prefix: "" diff --git a/pkg/docsgen/generate_manifest.go b/pkg/docsgen/generate_manifest.go new file mode 100644 index 00000000000..30f47cb43d1 --- /dev/null +++ b/pkg/docsgen/generate_manifest.go @@ -0,0 +1,63 @@ +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + + "github.com/grafana/tempo/cmd/tempo/app" + "gopkg.in/yaml.v3" +) + +const ManifestPath = "docs/sources/tempo/configuration/manifest.md" + +const Cmd = "go run pkg/docsgen/generate_manifest.go" + +var Manifest = fmt.Sprintf(`--- +title: Manifest +description: This manifest lists of all Tempo options and their defaults. +weight: 110 +--- +[//]: # THIS FILE IS GENERATED AUTOMATICALLY BY '%s' +[//]: # DO NOT EDIT THIS FILE DIRECTLY' + +# Manifest + +This document is a reference for all Tempo options and their defaults. If you are just getting +started with Tempo, refer to [Tempo examples](https://github.com/grafana/tempo/tree/main/example/docker-compose) +and other [configuration documentation]({{< relref "../configuration" >}}). Most installations will require only setting 10 to 20 of these options. + +## Complete configuration + +`, Cmd) + +func main() { + newConfig := app.NewDefaultConfig() + // Override values that depend on the host specifics + const hostname = "hostname" + newConfig.Distributor.DistributorRing.InstanceID = hostname + newConfig.Compactor.ShardingRing.InstanceID = hostname + newConfig.Ingester.LifecyclerConfig.ID = hostname + newConfig.Ingester.LifecyclerConfig.InfNames = []string{"eth0"} + newConfig.Generator.Ring.InstanceID = hostname + + newConfigBytes, err := yaml.Marshal(newConfig) + if err != nil { + panic(err) + } + newManifest := Manifest + "```yaml\n" + string(newConfigBytes) + "```\n" + + err = os.WriteFile(ManifestPath, []byte(newManifest), 0o644) + if err != nil { + panic(err) + } + + cmd := exec.Command("git", "diff", "--exit-code", ManifestPath) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err = cmd.Run() + if err != nil { + log.Fatalf("The manifest with the default Tempo configuration has changed. Please run '%s' and commit the changes.", Cmd) + } +}