mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
chore(deps): use version.PrometheusUserAgent
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
parent
2a8ae586f4
commit
dd5ab743ea
|
@ -328,7 +328,7 @@ func main() {
|
||||||
kingpin.Fatalf("Failed to load HTTP config file: %v", err)
|
kingpin.Fatalf("Failed to load HTTP config file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRoundTripper, err = promconfig.NewRoundTripperFromConfig(*httpConfig, "promtool", promconfig.WithUserAgent("promtool/"+version.Version))
|
httpRoundTripper, err = promconfig.NewRoundTripperFromConfig(*httpConfig, "promtool", promconfig.WithUserAgent(version.ComponentUserAgent("promtool")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kingpin.Fatalf("Failed to create a new HTTP round tripper: %v", err)
|
kingpin.Fatalf("Failed to create a new HTTP round tripper: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,18 +70,14 @@ const (
|
||||||
authMethodManagedIdentity = "ManagedIdentity"
|
authMethodManagedIdentity = "ManagedIdentity"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// DefaultSDConfig is the default Azure SD configuration.
|
||||||
userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var DefaultSDConfig = SDConfig{
|
||||||
|
Port: 80,
|
||||||
// DefaultSDConfig is the default Azure SD configuration.
|
RefreshInterval: model.Duration(5 * time.Minute),
|
||||||
DefaultSDConfig = SDConfig{
|
Environment: "AzurePublicCloud",
|
||||||
Port: 80,
|
AuthenticationMethod: authMethodOAuth,
|
||||||
RefreshInterval: model.Duration(5 * time.Minute),
|
HTTPClientConfig: config_util.DefaultHTTPClientConfig,
|
||||||
Environment: "AzurePublicCloud",
|
}
|
||||||
AuthenticationMethod: authMethodOAuth,
|
|
||||||
HTTPClientConfig: config_util.DefaultHTTPClientConfig,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
var environments = map[string]cloud.Configuration{
|
var environments = map[string]cloud.Configuration{
|
||||||
"AZURECHINACLOUD": cloud.AzureChina,
|
"AZURECHINACLOUD": cloud.AzureChina,
|
||||||
|
@ -244,7 +240,7 @@ func (d *Discovery) createAzureClient() (client, error) {
|
||||||
c.logger = d.logger
|
c.logger = d.logger
|
||||||
|
|
||||||
telemetry := policy.TelemetryOptions{
|
telemetry := policy.TelemetryOptions{
|
||||||
ApplicationID: userAgent,
|
ApplicationID: version.PrometheusUserAgent(),
|
||||||
}
|
}
|
||||||
|
|
||||||
credential, err := newCredential(*d.cfg, policy.ClientOptions{
|
credential, err := newCredential(*d.cfg, policy.ClientOptions{
|
||||||
|
|
|
@ -132,7 +132,7 @@ func NewDiscovery(conf *SDConfig, logger *slog.Logger, metrics discovery.Discove
|
||||||
Transport: rt,
|
Transport: rt,
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
},
|
},
|
||||||
godo.SetUserAgent(fmt.Sprintf("Prometheus/%s", version.Version)),
|
godo.SetUserAgent(version.PrometheusUserAgent()),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error setting up digital ocean agent: %w", err)
|
return nil, fmt.Errorf("error setting up digital ocean agent: %w", err)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/prometheus/common/version"
|
"github.com/prometheus/common/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var userAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
type Applications struct {
|
type Applications struct {
|
||||||
VersionsDelta int `xml:"versions__delta"`
|
VersionsDelta int `xml:"versions__delta"`
|
||||||
|
|
|
@ -39,7 +39,7 @@ const (
|
||||||
hetznerLabelRobotCancelled = hetznerRobotLabelPrefix + "cancelled"
|
hetznerLabelRobotCancelled = hetznerRobotLabelPrefix + "cancelled"
|
||||||
)
|
)
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var userAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
// Discovery periodically performs Hetzner Robot requests. It implements
|
// Discovery periodically performs Hetzner Robot requests. It implements
|
||||||
// the Discoverer interface.
|
// the Discoverer interface.
|
||||||
|
|
|
@ -44,7 +44,7 @@ var (
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
}
|
}
|
||||||
userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
userAgent = version.PrometheusUserAgent()
|
||||||
matchContentType = regexp.MustCompile(`^(?i:application\/json(;\s*charset=("utf-8"|utf-8))?)$`)
|
matchContentType = regexp.MustCompile(`^(?i:application\/json(;\s*charset=("utf-8"|utf-8))?)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ package ionos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -77,7 +76,7 @@ func newServerDiscovery(conf *SDConfig, _ *slog.Logger) (*serverDiscovery, error
|
||||||
Transport: rt,
|
Transport: rt,
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
}
|
}
|
||||||
cfg.UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
cfg.UserAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
d.client = ionoscloud.NewAPIClient(cfg)
|
d.client = ionoscloud.NewAPIClient(cfg)
|
||||||
|
|
||||||
|
|
|
@ -59,14 +59,10 @@ const (
|
||||||
presentValue = model.LabelValue("true")
|
presentValue = model.LabelValue("true")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// DefaultSDConfig is the default Kubernetes SD configuration.
|
||||||
// Http header.
|
var DefaultSDConfig = SDConfig{
|
||||||
userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
// DefaultSDConfig is the default Kubernetes SD configuration.
|
}
|
||||||
DefaultSDConfig = SDConfig{
|
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
discovery.RegisterConfig(&SDConfig{})
|
discovery.RegisterConfig(&SDConfig{})
|
||||||
|
@ -336,7 +332,7 @@ func New(l *slog.Logger, metrics discovery.DiscovererMetrics, conf *SDConfig) (*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kcfg.UserAgent = userAgent
|
kcfg.UserAgent = version.PrometheusUserAgent()
|
||||||
kcfg.ContentType = "application/vnd.kubernetes.protobuf"
|
kcfg.ContentType = "application/vnd.kubernetes.protobuf"
|
||||||
|
|
||||||
c, err := kubernetes.NewForConfig(kcfg)
|
c, err := kubernetes.NewForConfig(kcfg)
|
||||||
|
|
|
@ -165,7 +165,7 @@ func NewDiscovery(conf *SDConfig, logger *slog.Logger, metrics discovery.Discove
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
client.SetUserAgent(fmt.Sprintf("Prometheus/%s", version.Version))
|
client.SetUserAgent(version.PrometheusUserAgent())
|
||||||
d.client = &client
|
d.client = &client
|
||||||
|
|
||||||
d.Discovery = refresh.NewDiscovery(
|
d.Discovery = refresh.NewDiscovery(
|
||||||
|
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/config"
|
"github.com/prometheus/common/config"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
|
"github.com/prometheus/common/version"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/discovery"
|
"github.com/prometheus/prometheus/discovery"
|
||||||
"github.com/prometheus/prometheus/discovery/refresh"
|
"github.com/prometheus/prometheus/discovery/refresh"
|
||||||
|
@ -173,7 +174,7 @@ func NewDockerDiscovery(conf *DockerSDConfig, logger *slog.Logger, metrics disco
|
||||||
}),
|
}),
|
||||||
client.WithScheme(hostURL.Scheme),
|
client.WithScheme(hostURL.Scheme),
|
||||||
client.WithHTTPHeaders(map[string]string{
|
client.WithHTTPHeaders(map[string]string{
|
||||||
"User-Agent": userAgent,
|
"User-Agent": version.PrometheusUserAgent(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ const (
|
||||||
swarmLabel = model.MetaLabelPrefix + "dockerswarm_"
|
swarmLabel = model.MetaLabelPrefix + "dockerswarm_"
|
||||||
)
|
)
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
|
||||||
|
|
||||||
// DefaultDockerSwarmSDConfig is the default Docker Swarm SD configuration.
|
// DefaultDockerSwarmSDConfig is the default Docker Swarm SD configuration.
|
||||||
var DefaultDockerSwarmSDConfig = DockerSwarmSDConfig{
|
var DefaultDockerSwarmSDConfig = DockerSwarmSDConfig{
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
RefreshInterval: model.Duration(60 * time.Second),
|
||||||
|
@ -169,7 +167,7 @@ func NewDiscovery(conf *DockerSwarmSDConfig, logger *slog.Logger, metrics discov
|
||||||
}),
|
}),
|
||||||
client.WithScheme(hostURL.Scheme),
|
client.WithScheme(hostURL.Scheme),
|
||||||
client.WithHTTPHeaders(map[string]string{
|
client.WithHTTPHeaders(map[string]string{
|
||||||
"User-Agent": userAgent,
|
"User-Agent": version.PrometheusUserAgent(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ var (
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
||||||
}
|
}
|
||||||
matchContentType = regexp.MustCompile(`^(?i:application\/json(;\s*charset=("utf-8"|utf-8))?)$`)
|
matchContentType = regexp.MustCompile(`^(?i:application\/json(;\s*charset=("utf-8"|utf-8))?)$`)
|
||||||
userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
userAgent = version.PrometheusUserAgent()
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -93,7 +93,7 @@ func newBaremetalDiscovery(conf *SDConfig) (*baremetalDiscovery, error) {
|
||||||
Transport: rt,
|
Transport: rt,
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
}),
|
}),
|
||||||
scw.WithUserAgent(fmt.Sprintf("Prometheus/%s", version.Version)),
|
scw.WithUserAgent(version.PrometheusUserAgent()),
|
||||||
scw.WithProfile(profile),
|
scw.WithProfile(profile),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -104,7 +104,7 @@ func newInstanceDiscovery(conf *SDConfig) (*instanceDiscovery, error) {
|
||||||
Transport: rt,
|
Transport: rt,
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
}),
|
}),
|
||||||
scw.WithUserAgent(fmt.Sprintf("Prometheus/%s", version.Version)),
|
scw.WithUserAgent(version.PrometheusUserAgent()),
|
||||||
scw.WithProfile(profile),
|
scw.WithProfile(profile),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -135,7 +135,7 @@ func NewDiscovery(conf *SDConfig, logger *slog.Logger, metrics discovery.Discove
|
||||||
Timeout: time.Duration(conf.RefreshInterval),
|
Timeout: time.Duration(conf.RefreshInterval),
|
||||||
})
|
})
|
||||||
|
|
||||||
d.client.SetUserAgent(fmt.Sprintf("Prometheus/%s", version.Version))
|
d.client.SetUserAgent(version.PrometheusUserAgent())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error setting up vultr agent: %w", err)
|
return nil, fmt.Errorf("error setting up vultr agent: %w", err)
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/prometheus/common/version"
|
"github.com/prometheus/common/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var userAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
// ResourceClient exposes the xDS protocol for a single resource type.
|
// ResourceClient exposes the xDS protocol for a single resource type.
|
||||||
// See https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#rest-json-polling-subscriptions .
|
// See https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#rest-json-polling-subscriptions .
|
||||||
|
|
|
@ -56,7 +56,7 @@ const (
|
||||||
alertmanagerLabel = "alertmanager"
|
alertmanagerLabel = "alertmanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var userAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
// Alert is a generic representation of an alert in the Prometheus eco-system.
|
// Alert is a generic representation of an alert in the Prometheus eco-system.
|
||||||
type Alert struct {
|
type Alert struct {
|
||||||
|
|
|
@ -792,7 +792,7 @@ func acceptEncodingHeader(enableCompression bool) string {
|
||||||
return "identity"
|
return "identity"
|
||||||
}
|
}
|
||||||
|
|
||||||
var UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
var UserAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
func (s *targetScraper) scrape(ctx context.Context) (*http.Response, error) {
|
func (s *targetScraper) scrape(ctx context.Context) (*http.Response, error) {
|
||||||
if s.req == nil {
|
if s.req == nil {
|
||||||
|
|
|
@ -66,7 +66,7 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// UserAgent represents Prometheus version to use for user agent header.
|
// UserAgent represents Prometheus version to use for user agent header.
|
||||||
UserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
UserAgent = version.PrometheusUserAgent()
|
||||||
|
|
||||||
remoteWriteContentTypeHeaders = map[config.RemoteWriteProtoMsg]string{
|
remoteWriteContentTypeHeaders = map[config.RemoteWriteProtoMsg]string{
|
||||||
config.RemoteWriteProtoMsgV1: appProtoContentType, // Also application/x-protobuf;proto=prometheus.WriteRequest but simplified for compatibility with 1.x spec.
|
config.RemoteWriteProtoMsgV1: appProtoContentType, // Also application/x-protobuf;proto=prometheus.WriteRequest but simplified for compatibility with 1.x spec.
|
||||||
|
|
Loading…
Reference in a new issue