Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge latest main into v0.1.x #20

Merged
merged 8 commits into from
Dec 9, 2024
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.2.0
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.6.0
with:
run-unit-tests: true
run-integration-tests: false
run-lint: true
run-build: true
run-gosec: true
gosec-args: "-no-fail ./..."

docker_pipeline:
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.2.0
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.6.0
secrets: inherit
with:
publish: false
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ on:
push:
branches:
- 'main'
- 'dev'
tags:
- '*'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.2.0
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.6.0
with:
run-unit-tests: true
run-integration-tests: false
run-lint: true

docker_pipeline:
needs: ["lint_test"]
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.2.0
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.6.0
secrets: inherit
with:
publish: true
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

Staking Expiry Checker repository follows the same contributing rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/CONTRIBUTING.md)
repository.
5 changes: 5 additions & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release Process

Staking Expiry Checker repository follows the same release process rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/RELEASE_PROCESS.md)
repository.
23 changes: 17 additions & 6 deletions internal/observability/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
type Outcome string

const (
Success Outcome = "success"
Error Outcome = "error"
Success Outcome = "success"
Error Outcome = "error"
MetricRequestTimeout time.Duration = 5 * time.Second
MetricRequestIdleTimeout time.Duration = 10 * time.Second
)

func (O Outcome) String() string {
Expand Down Expand Up @@ -47,12 +49,21 @@ func initMetricsRouter(metricsPort int) {
metricsRouter.Get("/metrics", func(w http.ResponseWriter, r *http.Request) {
promhttp.Handler().ServeHTTP(w, r)
})
// Create a custom server with timeout settings
metricsAddr := fmt.Sprintf(":%d", metricsPort)
server := &http.Server{
Addr: metricsAddr,
Handler: metricsRouter,
ReadTimeout: MetricRequestTimeout,
WriteTimeout: MetricRequestTimeout,
IdleTimeout: MetricRequestIdleTimeout,
}

// Start the server in a separate goroutine
go func() {
metricsAddr := fmt.Sprintf(":%d", metricsPort)
err := http.ListenAndServe(metricsAddr, metricsRouter)
if err != nil {
log.Fatal().Err(err).Msgf("error starting metrics server on %s", metricsAddr)
log.Printf("Starting metrics server on %s", metricsAddr)
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal().Err(err).Msgf("Error starting metrics server on %s", metricsAddr)
}
}()
}
Expand Down
Loading