Skip to content

Instantly share code, notes, and snippets.

@TonPC64
Last active February 24, 2022 14:38
Show Gist options
  • Save TonPC64/2048cdef989d23805b5a32f059e10037 to your computer and use it in GitHub Desktop.
Save TonPC64/2048cdef989d23805b5a32f059e10037 to your computer and use it in GitHub Desktop.
func main() {
// create server
mux := http.NewServeMux()
// wrapped handler for use propagation to extract trace signal from http header to request context
// it like a middleware
wrappedHandler := otelhttp.NewHandler(http.HandlerFunc(httpHandler), "http-server")
mux.Handle("/", wrappedHandler)
// start server
port := os.Getenv("PORT")
log.Debug().Msg("starting server at http://localhost:" + port)
if err := http.ListenAndServe(":"+port, mux); err != nil {
log.Panic().Err(err).Msg("server error")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment