39 lines
746 B
Go
39 lines
746 B
Go
// 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() {}
|