35
35
argparser * flags.Parser
36
36
opts config.Opts
37
37
38
- audit * auditor.AzureAuditor
38
+ azureAuditor * auditor.AzureAuditor
39
39
40
40
// Git version information
41
41
gitCommit = "<unknown>"
@@ -50,11 +50,11 @@ func main() {
50
50
log .Info (string (opts .GetJson ()))
51
51
52
52
log .Infof ("starting audit" )
53
- audit = auditor .NewAzureAuditor ()
54
- audit .Opts = opts
55
- audit .UserAgent = UserAgent + gitTag
56
- audit .ParseConfig (opts .Config ... )
57
- audit .Run ()
53
+ azureAuditor = auditor .NewAzureAuditor ()
54
+ azureAuditor .Opts = opts
55
+ azureAuditor .UserAgent = UserAgent + gitTag
56
+ azureAuditor .ParseConfig (opts .Config ... )
57
+ azureAuditor .Run ()
58
58
59
59
log .Infof ("Starting http server on %s" , opts .ServerBind )
60
60
startHttpServer ()
@@ -198,10 +198,10 @@ func startHttpServer() {
198
198
RequestReport string
199
199
}{
200
200
Nonce : cspNonce ,
201
- Config : audit .GetConfig (),
201
+ Config : azureAuditor .GetConfig (),
202
202
ReportTitle : opts .Report .Title ,
203
203
ReportConfig : nil ,
204
- Reports : audit .GetReport (),
204
+ Reports : azureAuditor .GetReport (),
205
205
ServerPathReport : opts .ServerPathReport ,
206
206
RequestReport : "" ,
207
207
}
@@ -273,7 +273,7 @@ func startHttpServer() {
273
273
}
274
274
275
275
if reportName := r .URL .Query ().Get ("report" ); reportName != "" {
276
- reportList := audit .GetReport ()
276
+ reportList := azureAuditor .GetReport ()
277
277
if report , ok := reportList [reportName ]; ok {
278
278
279
279
if report .UpdateTime != nil {
@@ -366,7 +366,7 @@ func startHttpServer() {
366
366
http .HandleFunc ("/config" , func (w http.ResponseWriter , r * http.Request ) {
367
367
w .Header ().Add ("Content-Type" , "text/plain" )
368
368
369
- content , err := yaml .Marshal (audit .GetConfig ())
369
+ content , err := yaml .Marshal (azureAuditor .GetConfig ())
370
370
if err == nil {
371
371
if _ , writeErr := w .Write (content ); writeErr != nil {
372
372
log .Error (writeErr )
@@ -380,6 +380,13 @@ func startHttpServer() {
380
380
}
381
381
})
382
382
383
- http .Handle ("/metrics" , azuretracing .RegisterAzureMetricAutoClean (promhttp .Handler ()))
383
+ http .Handle ("/metrics" , http .HandlerFunc (
384
+ func (w http.ResponseWriter , r * http.Request ) {
385
+ azureAuditor .MetricsLock ().RLock ()
386
+ defer azureAuditor .MetricsLock ().RUnlock ()
387
+ azuretracing .RegisterAzureMetricAutoClean (promhttp .Handler ()).ServeHTTP (w , r )
388
+ },
389
+ ))
390
+
384
391
log .Error (http .ListenAndServe (opts .ServerBind , nil ))
385
392
}
0 commit comments