mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
tweaks based on suggestions
Signed-off-by: alexgreenbank <alex.greenbank@grafana.com>
This commit is contained in:
parent
033eaea415
commit
f0fc60f785
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## unreleased
|
## unreleased
|
||||||
|
|
||||||
* [CHANGE] Remote-Write: Ability to set User-Agent #15201
|
* [ENHANCEMENT] Remote-Write: Ability to set User-Agent #15201
|
||||||
* [ENHANCEMENT] OTLP receiver: Convert also metric metadata. #15416
|
* [ENHANCEMENT] OTLP receiver: Convert also metric metadata. #15416
|
||||||
|
|
||||||
## 3.0.0 / 2024-11-14
|
## 3.0.0 / 2024-11-14
|
||||||
|
|
|
@ -67,7 +67,7 @@ const (
|
||||||
var (
|
var (
|
||||||
// internalUserAgent should not be modified as it is to allow tracking of the
|
// internalUserAgent should not be modified as it is to allow tracking of the
|
||||||
// specific Prometheus version in use if UserAgent below is over-ridden.
|
// specific Prometheus version in use if UserAgent below is over-ridden.
|
||||||
// This value is used to set the X-Prometheus-User-Agent header.
|
// This value is used to set the X-Prometheus-Library-Version header.
|
||||||
internalUserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
internalUserAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
||||||
|
|
||||||
// UserAgent represents Prometheus version to use for the User-Agent header.
|
// UserAgent represents Prometheus version to use for the User-Agent header.
|
||||||
|
@ -284,7 +284,7 @@ func (c *Client) Store(ctx context.Context, req []byte, attempt int) (WriteRespo
|
||||||
httpReq.Header.Add("Content-Encoding", string(c.writeCompression))
|
httpReq.Header.Add("Content-Encoding", string(c.writeCompression))
|
||||||
httpReq.Header.Set("Content-Type", remoteWriteContentTypeHeaders[c.writeProtoMsg])
|
httpReq.Header.Set("Content-Type", remoteWriteContentTypeHeaders[c.writeProtoMsg])
|
||||||
httpReq.Header.Set("User-Agent", UserAgent)
|
httpReq.Header.Set("User-Agent", UserAgent)
|
||||||
httpReq.Header.Set("X-Prometheus-User-Agent", internalUserAgent)
|
httpReq.Header.Set("X-Prometheus-Library-Version", internalUserAgent)
|
||||||
if c.writeProtoMsg == config.RemoteWriteProtoMsgV1 {
|
if c.writeProtoMsg == config.RemoteWriteProtoMsgV1 {
|
||||||
// Compatibility mode for 1.0.
|
// Compatibility mode for 1.0.
|
||||||
httpReq.Header.Set(RemoteWriteVersionHeader, RemoteWriteVersion1HeaderValue)
|
httpReq.Header.Set(RemoteWriteVersionHeader, RemoteWriteVersion1HeaderValue)
|
||||||
|
@ -386,7 +386,7 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query, sortSeries bool)
|
||||||
httpReq.Header.Add("Accept-Encoding", "snappy")
|
httpReq.Header.Add("Accept-Encoding", "snappy")
|
||||||
httpReq.Header.Set("Content-Type", "application/x-protobuf")
|
httpReq.Header.Set("Content-Type", "application/x-protobuf")
|
||||||
httpReq.Header.Set("User-Agent", UserAgent)
|
httpReq.Header.Set("User-Agent", UserAgent)
|
||||||
httpReq.Header.Set("X-Prometheus-User-Agent", internalUserAgent)
|
httpReq.Header.Set("X-Prometheus-Library-Version", internalUserAgent)
|
||||||
httpReq.Header.Set("X-Prometheus-Remote-Read-Version", "0.1.0")
|
httpReq.Header.Set("X-Prometheus-Remote-Read-Version", "0.1.0")
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, c.timeout)
|
ctx, cancel := context.WithTimeout(ctx, c.timeout)
|
||||||
|
|
|
@ -112,9 +112,9 @@ func TestReadClientUserAgent(t *testing.T) {
|
||||||
called = true
|
called = true
|
||||||
receivedHeaders := r.Header
|
receivedHeaders := r.Header
|
||||||
|
|
||||||
// Check the X-Prometheus-User-Agent header.
|
// Check the X-Prometheus-Library-Version header.
|
||||||
require.Equal(t, []string{internalUserAgent}, receivedHeaders.Values("X-Prometheus-User-Agent"),
|
require.Equal(t, []string{internalUserAgent}, receivedHeaders.Values("X-Prometheus-Library-Version"),
|
||||||
"expected X-Prometheus-User-Agent header to be default value of %q", internalUserAgent)
|
"expected X-Prometheus-Library-Version header to be default value of %q", internalUserAgent)
|
||||||
|
|
||||||
if test.userAgent == "" {
|
if test.userAgent == "" {
|
||||||
// Expect original header value.
|
// Expect original header value.
|
||||||
|
@ -183,9 +183,9 @@ func TestWriteClientUserAgent(t *testing.T) {
|
||||||
called = true
|
called = true
|
||||||
receivedHeaders := r.Header
|
receivedHeaders := r.Header
|
||||||
|
|
||||||
// Check the X-Prometheus-User-Agent header.
|
// Check the X-Prometheus-Library-Version header.
|
||||||
require.Equal(t, []string{internalUserAgent}, receivedHeaders.Values("X-Prometheus-User-Agent"),
|
require.Equal(t, []string{internalUserAgent}, receivedHeaders.Values("X-Prometheus-Library-Version"),
|
||||||
"expected X-Prometheus-User-Agent header to be default value of %q", internalUserAgent)
|
"expected X-Prometheus-Library-Version header to be default value of %q", internalUserAgent)
|
||||||
|
|
||||||
if test.userAgent == "" {
|
if test.userAgent == "" {
|
||||||
// Expect original header value.
|
// Expect original header value.
|
||||||
|
|
Loading…
Reference in a new issue