[v11.0.x] Loki: Support custom X-Query-Tags header (#86189)

Loki: Support custom `X-Query-Tags` header (#85123)

* Loki: Support custom `X-Query-Tags` header

* add comment

(cherry picked from commit 9a8ae3c932)

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-15 16:30:09 +01:00
committed by GitHub
co-authored by Sven Grossmann
parent 232798e0d0
commit 98417a579f
4 changed files with 121 additions and 24 deletions
+13 -1
View File
@@ -58,7 +58,7 @@ func TestApiLogVolume(t *testing.T) {
require.True(t, called)
})
t.Run("non-log-volume queries should not set log-volume http header", func(t *testing.T) {
t.Run("none queries should not set X-Query-Tags http header", func(t *testing.T) {
called := false
api := makeMockedAPI(200, "application/json", response, func(req *http.Request) {
called = true
@@ -70,6 +70,18 @@ func TestApiLogVolume(t *testing.T) {
require.True(t, called)
})
t.Run("any defined supporting query should not set X-Query-Tags http header", func(t *testing.T) {
called := false
api := makeMockedAPI(200, "application/json", response, func(req *http.Request) {
called = true
require.Equal(t, "Source=foo", req.Header.Get("X-Query-Tags"))
}, false)
_, err := api.DataQuery(context.Background(), lokiQuery{Expr: "", SupportingQueryType: SupportingQueryType("foo"), QueryType: QueryTypeRange}, ResponseOpts{})
require.NoError(t, err)
require.True(t, called)
})
t.Run("with `structuredMetadata` should set correct http header", func(t *testing.T) {
called := false
api := makeMockedAPI(200, "application/json", response, func(req *http.Request) {