k8ssandra / k8ssandra-operator

The Kubernetes operator for K8ssandra
https://k8ssandra.io/
Apache License 2.0
159 stars 74 forks source link

Vector Agent config `DefaultScrapeInterval` should be of type `time.Duration` #826

Open emerkle826 opened 1 year ago

emerkle826 commented 1 year ago

The Vector default scrape interval is defined as an int32. It would be better to define it as type time.Duration

┆Issue is synchronized with this Jira Story by Unito

olim7t commented 1 year ago

Note: the constant has moved to vector/vector.go since the creation of this ticket.

Maybe the code has changed, but I don't see a strong need to change the type.

The public-facing telemetry.Vector.ScrapeInterval uses a duration, but we truncate it to seconds when we convert it to the internal vector.VectorConfig.ScrapeInterval -- which makes sense since it's eventually used to fill scrape_interval_secs in the text config. DefaultScrapeInterval provides the default for the latter, for example in stargate/vector.go:

    var scrapeInterval int32 = vector.DefaultScrapeInterval
    if telemetrySpec.Vector.ScrapeInterval != nil {
        scrapeInterval = int32(telemetrySpec.Vector.ScrapeInterval.Seconds())
    }

    config := vector.VectorConfig{
        Sinks:          vectorConfigToml,
        ScrapePort:     stargatepkg.MetricsPort,
        ScrapeInterval: scrapeInterval,
    }

If we change the type of DefaultScrapeInterval, we'd have to immediately apply an int32() conversion on the first line.