Go HTTP Server with OTEL Template
This commit is contained in:
38
main.go
Normal file
38
main.go
Normal file
@ -0,0 +1,38 @@
|
||||
// This template contains a simple
|
||||
// app with OTEL bootstrap that will create an
|
||||
// HTTP server configured by environment that exports
|
||||
// spans and metrics to an OTEL collector if configured
|
||||
// to do so. Will also stand up a prometheus metrics
|
||||
// endpoint.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-http-server-with-otel/pkg/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cncl := signal.NotifyContext(context.Background(), os.Interrupt, unix.SIGTERM)
|
||||
defer cncl()
|
||||
|
||||
conf, err := config.LoadConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctx = conf.AddToCtx(ctx)
|
||||
|
||||
conf, err = config.FromCtx(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%#v\n", conf)
|
||||
}
|
||||
|
||||
func init() {}
|
Reference in New Issue
Block a user