aligning function name and log message to the official product name (#229)
* log: change log format to JSON payload for better log in Stackdriver
change the log format in Go written service from text payload to
JSON payload using 3rd party logging library (logrus).
https://cloud.google.com/logging/docs/structured-logging
33a1e118e1/json_formatter.go (L40-L49)
Effected services are frontend, productcatalogservice, checkoutservice,
and shippinservice.
Also change target container registry and locust scenario for testing.
* revert kubernetes manifests to point to the original container registry URLs
* revert skaffold.yaml to point to the original registry
* loadgenerator: revert locust settings
* align all function names and messages to the official product name "Stackdriver"
This commit is contained in:
parent
dc98b16a4d
commit
1c057fcbd8
5 changed files with 35 additions and 35 deletions
|
@ -214,7 +214,7 @@ public final class AdService {
|
|||
}
|
||||
|
||||
private static void initStackdriver() {
|
||||
logger.info("Initialize StackDriver");
|
||||
logger.info("Initialize Stackdriver");
|
||||
|
||||
long sleepTime = 10; /* seconds */
|
||||
int maxAttempts = 5;
|
||||
|
@ -252,7 +252,7 @@ public final class AdService {
|
|||
}
|
||||
}
|
||||
}
|
||||
logger.info("StackDriver initialization complete.");
|
||||
logger.info("Stackdriver initialization complete.");
|
||||
}
|
||||
|
||||
private static void initJaeger() {
|
||||
|
|
|
@ -131,7 +131,7 @@ func initStats(exporter *stackdriver.Exporter) {
|
|||
}
|
||||
}
|
||||
|
||||
func initStackDriverTracing() {
|
||||
func initStackdriverTracing() {
|
||||
// TODO(ahmetb) this method is duplicated in other microservices using Go
|
||||
// since they are not sharing packages.
|
||||
for i := 1; i <= 3; i++ {
|
||||
|
@ -140,22 +140,22 @@ func initStackDriverTracing() {
|
|||
log.Infof("failed to initialize stackdriver exporter: %+v", err)
|
||||
} else {
|
||||
trace.RegisterExporter(exporter)
|
||||
log.Info("registered stackdriver tracing")
|
||||
log.Info("registered Stackdriver tracing")
|
||||
|
||||
// Register the views to collect server stats.
|
||||
initStats(exporter)
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver exporter", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver exporter", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver exporter after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver exporter after retrying, giving up")
|
||||
}
|
||||
|
||||
func initTracing() {
|
||||
initJaegerTracing()
|
||||
initStackDriverTracing()
|
||||
initStackdriverTracing()
|
||||
}
|
||||
|
||||
func initProfiling(service, version string) {
|
||||
|
@ -170,14 +170,14 @@ func initProfiling(service, version string) {
|
|||
}); err != nil {
|
||||
log.Warnf("failed to start profiler: %+v", err)
|
||||
} else {
|
||||
log.Info("started stackdriver profiler")
|
||||
log.Info("started Stackdriver profiler")
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver profiler", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver profiler", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver profiler after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver profiler after retrying, giving up")
|
||||
}
|
||||
|
||||
func mustMapEnv(target *string, envKey string) {
|
||||
|
|
|
@ -191,20 +191,20 @@ func initStackdriverTracing(log logrus.FieldLogger) {
|
|||
// log.Warnf is used since there are multiple backends (stackdriver & jaeger)
|
||||
// to store the traces. In production setup most likely you would use only one backend.
|
||||
// In that case you should use log.Fatalf.
|
||||
log.Warnf("failed to initialize stackdriver exporter: %+v", err)
|
||||
log.Warnf("failed to initialize Stackdriver exporter: %+v", err)
|
||||
} else {
|
||||
trace.RegisterExporter(exporter)
|
||||
log.Info("registered stackdriver tracing")
|
||||
log.Info("registered Stackdriver tracing")
|
||||
|
||||
// Register the views to collect server stats.
|
||||
initStats(log, exporter)
|
||||
return
|
||||
}
|
||||
d := time.Second * 20 * time.Duration(i)
|
||||
log.Debugf("sleeping %v to retry initializing stackdriver exporter", d)
|
||||
log.Debugf("sleeping %v to retry initializing Stackdriver exporter", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver exporter after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver exporter after retrying, giving up")
|
||||
}
|
||||
|
||||
func initTracing(log logrus.FieldLogger) {
|
||||
|
@ -232,14 +232,14 @@ func initProfiling(log logrus.FieldLogger, service, version string) {
|
|||
}); err != nil {
|
||||
log.Warnf("warn: failed to start profiler: %+v", err)
|
||||
} else {
|
||||
log.Info("started stackdriver profiler")
|
||||
log.Info("started Stackdriver profiler")
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Debugf("sleeping %v to retry initializing stackdriver profiler", d)
|
||||
log.Debugf("sleeping %v to retry initializing Stackdriver profiler", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("warning: could not initialize stackdriver profiler after retrying, giving up")
|
||||
log.Warn("warning: could not initialize Stackdriver profiler after retrying, giving up")
|
||||
}
|
||||
|
||||
func mustMapEnv(target *string, envKey string) {
|
||||
|
|
|
@ -158,32 +158,32 @@ func initStats(exporter *stackdriver.Exporter) {
|
|||
}
|
||||
}
|
||||
|
||||
func initStackDriverTracing() {
|
||||
func initStackdriverTracing() {
|
||||
// TODO(ahmetb) this method is duplicated in other microservices using Go
|
||||
// since they are not sharing packages.
|
||||
for i := 1; i <= 3; i++ {
|
||||
exporter, err := stackdriver.NewExporter(stackdriver.Options{})
|
||||
if err != nil {
|
||||
log.Warnf("failed to initialize stackdriver exporter: %+v", err)
|
||||
log.Warnf("failed to initialize Stackdriver exporter: %+v", err)
|
||||
} else {
|
||||
trace.RegisterExporter(exporter)
|
||||
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
|
||||
log.Info("registered stackdriver tracing")
|
||||
log.Info("registered Stackdriver tracing")
|
||||
|
||||
// Register the views to collect server stats.
|
||||
initStats(exporter)
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver exporter", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver exporter", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver exporter after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver exporter after retrying, giving up")
|
||||
}
|
||||
|
||||
func initTracing() {
|
||||
initJaegerTracing()
|
||||
initStackDriverTracing()
|
||||
initStackdriverTracing()
|
||||
}
|
||||
|
||||
func initProfiling(service, version string) {
|
||||
|
@ -198,14 +198,14 @@ func initProfiling(service, version string) {
|
|||
}); err != nil {
|
||||
log.Warnf("failed to start profiler: %+v", err)
|
||||
} else {
|
||||
log.Info("started stackdriver profiler")
|
||||
log.Info("started Stackdriver profiler")
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver profiler", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver profiler", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver profiler after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver profiler after retrying, giving up")
|
||||
}
|
||||
|
||||
type productCatalog struct{}
|
||||
|
|
|
@ -161,32 +161,32 @@ func initStats(exporter *stackdriver.Exporter) {
|
|||
}
|
||||
}
|
||||
|
||||
func initStackDriverTracing() {
|
||||
func initStackdriverTracing() {
|
||||
// TODO(ahmetb) this method is duplicated in other microservices using Go
|
||||
// since they are not sharing packages.
|
||||
for i := 1; i <= 3; i++ {
|
||||
exporter, err := stackdriver.NewExporter(stackdriver.Options{})
|
||||
if err != nil {
|
||||
log.Warnf("failed to initialize stackdriver exporter: %+v", err)
|
||||
log.Warnf("failed to initialize Stackdriver exporter: %+v", err)
|
||||
} else {
|
||||
trace.RegisterExporter(exporter)
|
||||
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
|
||||
log.Info("registered stackdriver tracing")
|
||||
log.Info("registered Stackdriver tracing")
|
||||
|
||||
// Register the views to collect server stats.
|
||||
initStats(exporter)
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver exporter", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver exporter", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver exporter after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver exporter after retrying, giving up")
|
||||
}
|
||||
|
||||
func initTracing() {
|
||||
initJaegerTracing()
|
||||
initStackDriverTracing()
|
||||
initStackdriverTracing()
|
||||
}
|
||||
|
||||
func initProfiling(service, version string) {
|
||||
|
@ -201,12 +201,12 @@ func initProfiling(service, version string) {
|
|||
}); err != nil {
|
||||
log.Warnf("failed to start profiler: %+v", err)
|
||||
} else {
|
||||
log.Info("started stackdriver profiler")
|
||||
log.Info("started Stackdriver profiler")
|
||||
return
|
||||
}
|
||||
d := time.Second * 10 * time.Duration(i)
|
||||
log.Infof("sleeping %v to retry initializing stackdriver profiler", d)
|
||||
log.Infof("sleeping %v to retry initializing Stackdriver profiler", d)
|
||||
time.Sleep(d)
|
||||
}
|
||||
log.Warn("could not initialize stackdriver profiler after retrying, giving up")
|
||||
log.Warn("could not initialize Stackdriver profiler after retrying, giving up")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue