Skip to content

Commit

Permalink
feat: adding health check for go app
Browse files Browse the repository at this point in the history
Signed-off-by: mohamedasifs123 <asifabu272@gmail.com>
  • Loading branch information
mohamedasifs123 committed Dec 19, 2024
1 parent 32c2f20 commit 4c1842d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions config/demo-trace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ func main() {
fmt.Printf("Bdev: %s, BytesRead: %d, NumReadOps: %d\n",
bdev.Name, bdev.BytesRead, bdev.NumReadOps)
}
span.End()
time.Sleep(5 * time.Second)
// Health check endpoint
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "OK")
})

// Application logic
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, World!")
})

// Start server
http.ListenAndServe(":57400", nil)
}
span.End()
time.Sleep(5 * time.Second)
}
// Health check endpoint
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "OK")
})

// Application logic
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, World!")
})

// Start server
http.ListenAndServe(":57400", nil)
}
2 changes: 1 addition & 1 deletion config/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
receivers:
otlp:
protocols:
grpc: 0.0.0.0:4317
grpc:

hostmetrics:
collection_interval: 1m
Expand Down

0 comments on commit 4c1842d

Please sign in to comment.