Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/spf13/cobra…
Browse files Browse the repository at this point in the history
…-1.8.1
  • Loading branch information
ramin committed Jun 20, 2024
2 parents d136496 + d46b9ad commit 7e97411
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
# Dockerfile Linting
hadolint:
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.4.2 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.4.3 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: celestiaorg/.github/.github/actions/yamllint@v0.4.2
- uses: celestiaorg/.github/.github/actions/yamllint@v0.4.3

markdown-lint:
name: Markdown Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release_tracking_epic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [released]
jobs:
trigger_issue:
uses: celestiaorg/.github/.github/workflows/reusable_create_release_tracking_epic.yml@v0.4.2
uses: celestiaorg/.github/.github/workflows/reusable_create_release_tracking_epic.yml@v0.4.3
secrets: inherit
with:
release-repo: ${{ github.repository }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.2 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.3 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
secrets: inherit
5 changes: 2 additions & 3 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
with:
args: --timeout 10m
version: v1.59
skip-pkg-cache: true
skip-build-cache: true
skip-cache: true

go_mod_tidy_check:
needs: [setup]
Expand Down Expand Up @@ -98,7 +97,7 @@ jobs:
retention-days: 5

- name: upload coverage
uses: codecov/codecov-action@v4.4.1
uses: codecov/codecov-action@v4.5.0
with:
env_vars: OS
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
28 changes: 20 additions & 8 deletions nodebuilder/p2p/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,47 @@ import (
"net/http"
"time"

"github.com/libp2p/go-libp2p/core/peer"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/fx"

"github.com/celestiaorg/celestia-node/nodebuilder/node"
)

// WithMetrics option sets up native libp2p metrics up.
func WithMetrics() fx.Option {
return fx.Options(
fx.Provide(resourceManagerOpt(traceReporter)),
fx.Provide(prometheusRegisterer),
fx.Invoke(prometheusMetrics),
)
}

const (
promAgentEndpoint = "/metrics"
promAgentPort = "8890"

networkLabel = "network"
nodeTypeLabel = "node_type"
peerIDLabel = "peer_id"
)

// prometheusMetrics option sets up native libp2p metrics up
func prometheusMetrics(lifecycle fx.Lifecycle, registerer prometheus.Registerer) error {
registry := registerer.(*prometheus.Registry)
func prometheusMetrics(lifecycle fx.Lifecycle,
peerID peer.ID,
nodeType node.Type,
network Network,
) error {
reg := prometheus.NewRegistry()
labels := prometheus.Labels{
networkLabel: network.String(),
nodeTypeLabel: nodeType.String(),
peerIDLabel: peerID.String(),
}
wrapped := prometheus.WrapRegistererWith(labels, reg)

mux := http.NewServeMux()
handler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{Registry: registerer})
handler := promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: wrapped})
mux.Handle(promAgentEndpoint, handler)

// TODO(@Wondertan): Unify all the servers into one (See #2007)
Expand All @@ -57,7 +73,3 @@ func prometheusMetrics(lifecycle fx.Lifecycle, registerer prometheus.Registerer)
})
return nil
}

func prometheusRegisterer() prometheus.Registerer {
return prometheus.NewRegistry()
}

0 comments on commit 7e97411

Please sign in to comment.