Skip to content

Commit

Permalink
otel refactoring [stagingdeploy]
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
  • Loading branch information
jsign committed Oct 12, 2022
1 parent 3bb2653 commit 940f939
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 83 deletions.
5 changes: 3 additions & 2 deletions cmd/api/main.go
Expand Up @@ -54,7 +54,7 @@ func main() {
logging.SetupLogger(buildinfo.GitCommit, config.Log.Debug, config.Log.Human)

// Validator instrumentation configuration.
if err := metrics.SetupInstrumentation(":" + config.Metrics.Port); err != nil {
if err := metrics.SetupInstrumentation(":"+config.Metrics.Port, "tableland:api"); err != nil {
log.Fatal().
Err(err).
Str("port", config.Metrics.Port).
Expand Down Expand Up @@ -108,9 +108,10 @@ func main() {
log.Fatal().Err(err).Msg("creating executors db")
}
executorsDB.SetMaxOpenConns(1)
attrs := append([]attribute.KeyValue{attribute.String("name", "executors")}, metrics.BaseAttrs...)
if err := otelsql.RegisterDBStatsMetrics(
executorsDB,
otelsql.WithAttributes(attribute.String("name", "executors"))); err != nil {
otelsql.WithAttributes(attrs...)); err != nil {
log.Fatal().Err(err).Msg("registering executors db stats")
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/healthbot/counterprobe/metrics.go
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"fmt"

"github.com/textileio/go-tableland/pkg/metrics"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/metric/instrument"
)

func (cp *CounterProbe) initMetrics(chainName string) error {
meter := global.MeterProvider().Meter("tableland")
cp.mBaseLabels = []attribute.KeyValue{attribute.String("chain_name", chainName)}
cp.mBaseLabels = append([]attribute.KeyValue{attribute.String("chain_name", chainName)}, metrics.BaseAttrs...)

latencyHistogram, err := meter.SyncInt64().Histogram(metricPrefix + ".latency")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/healthbot/main.go
Expand Up @@ -18,7 +18,7 @@ import (
func main() {
cfg := setupConfig()
logging.SetupLogger(buildinfo.GitCommit, cfg.Log.Debug, cfg.Log.Human)
if err := metrics.SetupInstrumentation(":" + cfg.Metrics.Port); err != nil {
if err := metrics.SetupInstrumentation(":"+cfg.Metrics.Port, "tableland:healthbot"); err != nil {
log.Fatal().Err(err).Str("port", cfg.Metrics.Port).Msg("could not setup instrumentation")
}

Expand Down
2 changes: 0 additions & 2 deletions docker/deployed/docker-compose.healthbot.yml
Expand Up @@ -4,8 +4,6 @@ services:
context: ..
dockerfile: ./cmd/healthbot/Dockerfile
platform: linux/${PLATFORM}
environment:
- OTEL_SERVICE_NAME=tableland:healthbot # this is just to the unknown_service from the metrics label
env_file:
- ${PWD}/${ENVIRONMENT}/healthbot/.env_healthbot
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Expand Up @@ -6,13 +6,13 @@ services:
dockerfile: ./cmd/api/Dockerfile
platform: linux/${PLATFORM}
environment:
- OTEL_SERVICE_NAME=tableland:api # this is just to the unknown_service from the metrics label
- BOOTSTRAP_BACKUP_URL=${BOOTSTRAP_BACKUP_URL}
env_file:
- ${PWD}/${ENVIRONMENT}/api/.env_validator
ports:
- "0.0.0.0:8080:8080"
- "0.0.0.0:443:443"
- "0.0.0.0:9090:9090"
volumes:
- ${PWD}/${ENVIRONMENT}/api:/root/.tableland
security_opt:
Expand Down
Expand Up @@ -664,6 +664,65 @@
"title": "Last Hash Calculation Elapsed Time",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 3,
"x": 10,
"y": 15
},
"id": 85,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "9.0.1",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"expr": "runtime_uptime",
"refId": "A"
}
],
"title": "Uptime",
"type": "stat"
},
{
"collapsed": false,
"datasource": {
Expand Down Expand Up @@ -2813,13 +2872,13 @@
"list": []
},
"time": {
"from": "now-6h",
"from": "now-5m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Validator",
"uid": "2Le7qt_7z",
"version": 13,
"version": 14,
"weekStart": ""
}
21 changes: 10 additions & 11 deletions go.mod
Expand Up @@ -12,10 +12,11 @@ require (
github.com/gorilla/mux v1.8.0
github.com/hetiansu5/urlquery v1.2.7
github.com/json-iterator/go v1.1.12
github.com/klauspost/compress v1.15.10
github.com/klauspost/compress v1.15.11
github.com/mattn/go-sqlite3 v1.14.15
github.com/omeid/uconfig v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.13.0
github.com/rs/zerolog v1.28.0
github.com/sethvargo/go-limiter v0.7.2
github.com/spf13/cobra v1.5.0
Expand All @@ -24,11 +25,10 @@ require (
github.com/tablelandnetwork/sqlparser v0.0.0-20220923130758-1b39431a2fea
github.com/textileio/cli v1.0.2
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.36.0
go.opentelemetry.io/otel v1.10.0
go.opentelemetry.io/otel/exporters/prometheus v0.31.0
go.opentelemetry.io/otel/metric v0.32.0
go.opentelemetry.io/otel/sdk/metric v0.31.0
go.opentelemetry.io/otel/exporters/prometheus v0.32.2
go.opentelemetry.io/otel/metric v0.32.2
go.opentelemetry.io/otel/sdk/metric v0.32.2
go.uber.org/atomic v1.10.0
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
)
Expand Down Expand Up @@ -77,10 +77,9 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/relvacode/iso8601 v1.1.0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
Expand All @@ -97,21 +96,21 @@ require (
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/otel/sdk v1.9.0 // indirect
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.0 // indirect
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e // indirect
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb // indirect
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/api v0.84.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down

0 comments on commit 940f939

Please sign in to comment.