"github.com/julienschmidt/httprouter"
https://marcofranssen.nl/improved-graceful-shutdown-webserver/
https://github.com/julienschmidt/httprouter
package main
import (
"fmt"
"net/http"
"log"
"github.com/julienschmidt/httprouter"
)
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "Welcome!\n")
}
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}
func main() {
router := httprouter.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)
log.Fatal(http.ListenAndServe(":8080", router))
}
https://github.com/justinas/alice
https://github.com/andyfusniak/stackdriver-gae-logrus-plugin https://github.com/TV4/logrus-stackdriver-formatter
blendle/zapdriver#22 https://godoc.org/cloud.google.com/go/logging#hdr-Grouping_Logs_by_Request
https://medium.com/google-cloud/combining-correlated-log-lines-in-google-stackdriver-dd23284aeb29 https://github.com/Khan/webapp/blob/master/pkg/lib/log/api.go
https://cloud.google.com/trace/docs/troubleshooting
func NewGRPCServer(endpoints endpoint.Set, logger *zap.Logger) dataservice.DataServiceServer { options := []grpctransport.ServerOption{ grpctransport.ServerErrorLogger( kit.ZapAdapter(logger.Named("GrpcServer"), zapcore.ErrorLevel)), } //..... }
How do I force a request to be traced? To force a specific request to be traced, add an X-Cloud-Trace-Context header to the request. The header specification is:
"X-Cloud-Trace-Context: TRACE_ID/SPAN_ID;o=TRACE_TRUE" Where:
TRACE_ID is a 32-character hexadecimal value representing a 128-bit number. It should be unique between your requests, unless you intentionally want to bundle the requests together. You can use UUIDs.
SPAN_ID is the decimal representation of the (unsigned) span ID. It should be 0 for the first span in your trace. For subsequent requests, set SPAN_ID to the span ID of the parent request. See the description of TraceSpan (REST, RPC) for more information about nested traces.
TRACE_TRUE must be 1 to trace this request. Specify 0 to not trace the request.
For example, to force a trace with cURL:
curl "http://www.example.com" --header "X-Cloud-Trace-Context: 105445aa7843bc8bf206b120001000/0;o=1"