@@ -15,6 +15,7 @@ import (
1515	log "github.com/sirupsen/logrus" 
1616	"github.com/webdevops/azure-loganalytics-exporter/config" 
1717	"github.com/webdevops/azure-resourcegraph-exporter/kusto" 
18+ 	"github.com/webdevops/go-prometheus-common/azuretracing" 
1819	"net/http" 
1920	"strconv" 
2021	"time" 
2829	LogAnalyticsProber  struct  {
2930		QueryConfig  kusto.Config 
3031		Conf         config.Opts 
32+ 		UserAgent    string 
3133
3234		Azure  struct  {
3335			Environment           azure.Environment 
@@ -133,8 +135,8 @@ func (p *LogAnalyticsProber) AddWorkspaces(workspace ...string) {
133135func  (p  * LogAnalyticsProber ) LogAnalyticsQueryClient () operationalinsights.QueryClient  {
134136	// Create and authorize a operationalinsights client 
135137	client  :=  operationalinsights .NewQueryClientWithBaseURI (p .Azure .Environment .ResourceIdentifiers .OperationalInsights  +  OperationInsightsWorkspaceUrlSuffix )
138+ 	p .decorateAzureAutoRest (& client .Client )
136139	client .Authorizer  =  p .Azure .OpInsightsAuthorizer 
137- 	client .ResponseInspector  =  p .respondDecorator (nil )
138140	return  client 
139141}
140142
@@ -346,14 +348,6 @@ func (p *LogAnalyticsProber) sendQueryToWorkspace(logger *log.Entry, workspaceId
346348	}
347349}
348350
349- func  (p  * LogAnalyticsProber ) respondDecorator (subscriptionId  * string ) autorest.RespondDecorator  {
350- 	return  func (p  autorest.Responder ) autorest.Responder  {
351- 		return  autorest .ResponderFunc (func (r  * http.Response ) error  {
352- 			return  nil 
353- 		})
354- 	}
355- }
356- 
357351func  (p  * LogAnalyticsProber ) parseCacheTime (r  * http.Request ) (time.Duration , error ) {
358352	durationString  :=  r .URL .Query ().Get ("cache" )
359353	if  durationString  !=  ""  {
@@ -379,3 +373,11 @@ func (p *LogAnalyticsProber) NewSizedWaitGroup() sizedwaitgroup.SizedWaitGroup {
379373
380374	return  sizedwaitgroup .New (size )
381375}
376+ 
377+ func  (p  * LogAnalyticsProber ) decorateAzureAutoRest (client  * autorest.Client ) {
378+ 	client .Authorizer  =  p .Azure .AzureAuthorizer 
379+ 	if  err  :=  client .AddToUserAgent (p .UserAgent ); err  !=  nil  {
380+ 		log .Panic (err )
381+ 	}
382+ 	azuretracing .DecoreAzureAutoRest (client )
383+ }
0 commit comments