Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import (
"net/http"
"os"
"runtime"
"strings"
"time"

azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
"go.uber.org/zap"

"github.com/google/uuid"
"github.com/jessevdk/go-flags"
"github.com/patrickmn/go-cache"
Expand Down Expand Up @@ -61,6 +65,7 @@ func main() {

logger.Infof("init Azure connection")
initAzureConnection()
initAzLogger()
initMetricCollector()

logger.Infof("starting http server on %s", opts.Server.Bind)
Expand Down Expand Up @@ -204,3 +209,21 @@ func initMetricCollector() {
)
prometheus.MustRegister(prometheusMetricRequests)
}

func initAzLogger() {
if cls := os.Getenv("AZURE_SDK_GO_LOGGING"); cls != "all" {
azlog.SetEvents(azlog.EventRetryPolicy)
azlog.SetListener(func(cls azlog.Event, msg string) {
if cls == azlog.EventRetryPolicy {
if strings.HasPrefix(msg, "response 2") ||
strings.HasPrefix(msg, "=====> Try=") ||
strings.HasPrefix(msg, "End Try") ||
msg == "exit due to non-retriable status code" {
return
}

logger.WithOptions(zap.AddCallerSkip(3)).Warnln(msg)
}
})
}
}