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

otel: update breaking changing apis #323

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
1 change: 0 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,68 @@
"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": 4,
"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"
},
"editorMode": "code",
"expr": "runtime_uptime",
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
],
"title": "Uptime",
"type": "stat"
},
{
"collapsed": false,
"datasource": {
Expand Down Expand Up @@ -2515,9 +2577,9 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "process_runtime_go_mem_heap_inuse{job=\"validator\"}",
"expr": "process_runtime_go_mem_heap_inuse",
"interval": "",
"legendFormat": "Heap in use",
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
Expand Down Expand Up @@ -2608,9 +2670,9 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "process_runtime_go_goroutines{job=\"validator\"}",
"expr": "process_runtime_go_goroutines",
"interval": "",
"legendFormat": "goroutines",
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
Expand Down Expand Up @@ -2701,9 +2763,9 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "rate(process_runtime_go_gc_count{job=\"validator\"}[5m])",
"expr": "rate(process_runtime_go_gc_count[5m])",
"interval": "",
"legendFormat": "gc/s",
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
Expand Down Expand Up @@ -2794,9 +2856,9 @@
},
"editorMode": "code",
"exemplar": true,
"expr": "avg_over_time(process_runtime_go_mem_live_objects{job=\"validator\"}[5m])",
"expr": "avg_over_time(process_runtime_go_mem_live_objects[5m])",
"interval": "",
"legendFormat": "objects",
"legendFormat": "{{job}}",
"range": true,
"refId": "A"
}
Expand All @@ -2813,13 +2875,13 @@
"list": []
},
"time": {
"from": "now-6h",
"from": "now-5m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Validator",
"uid": "2Le7qt_7z",
"version": 13,
"version": 18,
"weekStart": ""
}
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
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