-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (38 loc) · 990 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
"go.opentelemetry.io/otel"
"go-opentelemetry-example/handler"
"go-opentelemetry-example/infrastructure/opentelemetry"
"go-opentelemetry-example/repository"
"go-opentelemetry-example/usecase"
)
const (
PORT = 8080
DefaultAppName = ""
)
func main() {
shutdownTracer := opentelemetry.NewTracer()
defer shutdownTracer()
r := mux.NewRouter()
r.Use(otelmux.Middleware(DefaultAppName))
tracer := otel.Tracer(DefaultAppName)
createUserHandler := handler.NewCreateUser(
usecase.NewCreateAccount(
repository.NewCreateAccount(tracer),
tracer,
),
tracer,
)
r.HandleFunc("/users", createUserHandler.Handle).Methods(http.MethodPost)
log.Print("Start server in port:", PORT)
err := http.ListenAndServe(fmt.Sprintf(":%d", PORT), r)
if err != nil {
log.Fatalln("Error start server", err)
return
}
}