telegraf
telegraf copied to clipboard
allow adding version to userAgent
Use Case
I would like to use https://github.com/influxdata/telegraf/blob/master/internal/internal.go#L52-L55 to get the telegraf version and set it in the userAgent , but if I execute the call in package level variable:
package opentelemetry
import (
"context
"github.com/influxdata/telegraf/plugins/common/tls"
"github.com/influxdata/telegraf/plugins/outputs"
)
var userAgent = fmt.Sprintf("telegraf %s (%s/%s)", internal.Version(), runtime.GOOS, runtime.GOARCH)
It will be empty, as it is set during runtime -> https://github.com/influxdata/telegraf/blob/master/cmd/telegraf/telegraf.go#L413-L417 not compile time.
Expected behavior
internal.Version() returning correct version
Actual behavior
internal.Version() is empty
Additional info
No response
Thanks for the issue and the PR!