Skip to content

Commit

Permalink
add workaround for urlencoded query
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed Mar 29, 2023
1 parent 4bd2c90 commit e70ad2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions metrics/azure.policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metrics

import (
"net/http"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
)
Expand All @@ -12,6 +13,9 @@ func (p noCachePolicy) Do(req *policy.Request) (*http.Response, error) {
// Mutate/process request.
req.Raw().Header.Set("cache-control", "no-cache")

// replace encoded %2C to ,
req.Raw().URL.RawQuery = strings.ReplaceAll(req.Raw().URL.RawQuery, "%2C", ",")

// Forward the request to the next policy in the pipeline.
return req.Next()
}
4 changes: 2 additions & 2 deletions metrics/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type (

func (p *MetricProber) MetricsClient(subscriptionId string) (*armmonitor.MetricsClient, error) {
clientOpts := p.AzureClient.NewArmClientOptions()
clientOpts.PerRetryPolicies = append(
clientOpts.PerRetryPolicies,
clientOpts.PerCallPolicies = append(
clientOpts.PerCallPolicies,
noCachePolicy{},
)
return armmonitor.NewMetricsClient(subscriptionId, p.AzureClient.GetCred(), clientOpts)
Expand Down

0 comments on commit e70ad2f

Please sign in to comment.