This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from libp2p/marco/50-obs
feat: Out of the box metrics for resource manager
- Loading branch information
Showing
8 changed files
with
2,318 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Ready to go Grafana Dashboard | ||
|
||
Here are some prebuilt dashboards that you can add to your Grafana instance. To | ||
import follow the Grafana docs [here](https://grafana.com/docs/grafana/latest/dashboards/export-import/#import-dashboard) | ||
|
||
## Setup | ||
|
||
To make sure you're emitting the correct metrics you'll have to hook up the | ||
Opencensus views that `stats.go` exports. For Prometheus this looks like: | ||
|
||
``` go | ||
import ( | ||
// ... | ||
ocprom "contrib.go.opencensus.io/exporter/prometheus" | ||
|
||
rcmgr "github.com/libp2p/go-libp2p-resource-manager" | ||
rcmgrObs "github.com/libp2p/go-libp2p-resource-manager/obs" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"go.opencensus.io/stats/view" | ||
) | ||
|
||
func SetupResourceManager() (network.ResourceManager, error) { | ||
// Hook up the trace reporter metrics | ||
view.Register(rcmgrObs.DefaultViews...) | ||
ocprom.NewExporter(ocprom.Options{ | ||
Registry: prometheus.DefaultRegisterer.(*prometheus.Registry), | ||
Namespace: "rcmgr_trace_metrics", | ||
}) | ||
|
||
str, err := rcmgrObs.NewStatsTraceReporter() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return rcmgr.NewResourceManager(limiter, rcmgr.WithTraceReporter(str)) | ||
} | ||
``` | ||
|
||
It should be fairly similar for other exporters. See the [OpenCensus | ||
docs](https://opencensus.io/exporters/supported-exporters/go/) to see how to | ||
export to another exporter. |
Oops, something went wrong.