Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit ebc770b

Browse files
committed
Opentel change port number
1 parent f715baa commit ebc770b

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ run: ## run dicedb with the default configuration
7474
go run main.go --engine ironhawk --log-level debug
7575

7676
run-docker: ## run dicedb in a Docker container
77-
docker run -p 7379:7379 dicedb/dicedb:latest
77+
docker run -p 7379:7379 -p 8050:8050 dicedb/dicedb:latest
7878

7979
format: ## format the code using go fmt
8080
go fmt ./...

internal/diceotel/diceotel.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
const (
1616
meterName = "dicedb-otel"
17-
diceOtelPort = "9090"
17+
diceOtelPort = "8050"
1818
)
1919

2020
type (
@@ -78,6 +78,7 @@ func (dotel *DiceOtel) Run() (err error) {
7878
func (dotel *DiceOtel) serveMetrics() (err error) {
7979
http.Handle("/metrics", promhttp.Handler())
8080
if err = http.ListenAndServe(":"+diceOtelPort, nil); err != nil {
81+
log.Println("Error starting Diceotel server", err)
8182
return
8283
}
8384
return

internal/diceotel/metrics.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ import (
77
var (
88
// Counters
99
DiceStartCounter api.Int64Counter
10+
11+
// Histograms
12+
DiceCmdLatencyInMsHistogram api.Int64Histogram
1013
)
1114

1215
func (dotel *DiceOtel) register() (err error) {
13-
DiceStartCounter, _ = dotel.Meter.Int64Counter("dicedb_start", api.WithDescription("A counter for the start of the DiceDB server"))
14-
// Add other metrics here
16+
DiceStartCounter, _ = dotel.Meter.Int64Counter("dicedb.start.count", api.WithDescription("A counter for the start of the DiceDB server"))
17+
DiceCmdLatencyInMsHistogram, _ = dotel.Meter.Int64Histogram("dicedb.command_exec.latency", api.WithUnit("ms"))
18+
// Add new metrics here
1519
return
1620
}

internal/diceotel/prometheus-grafana/docker-compose.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# docker-compose.yml
2-
3-
version: '3.8'
4-
51
services:
62
prometheus:
73
image: prom/prometheus
@@ -25,16 +21,5 @@ services:
2521
- GF_SECURITY_ADMIN_PASSWORD=grafana
2622
volumes:
2723
- ./grafana:/etc/grafana/provisioning/datasources
28-
generate_prom_metrics:
29-
build:
30-
context: .
31-
dockerfile: Dockerfile
32-
container_name: generate_prom_metrics
33-
command: 'python app/tests/test_prom_scraping.py'
34-
volumes:
35-
- .:/app
36-
ports:
37-
- 8050:8050
38-
restart: unless-stopped
3924
volumes:
4025
prom_data:

internal/server/ironhawk/iothread.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import (
77
"context"
88
"log/slog"
99
"strings"
10+
"time"
1011

1112
"github.com/dicedb/dice/internal/auth"
1213
"github.com/dicedb/dice/internal/cmd"
14+
"github.com/dicedb/dice/internal/diceotel"
15+
"go.opentelemetry.io/otel/attribute"
16+
"go.opentelemetry.io/otel/metric"
1317
)
1418

1519
type IOThread struct {
@@ -42,10 +46,20 @@ func (t *IOThread) StartSync(ctx context.Context, shardManager *ShardManager, wa
4246
_c.ClientID = t.ClientID
4347
_c.Mode = t.Mode
4448

49+
execStartTime := time.Now()
4550
res, err := shardManager.Execute(_c)
4651
if err != nil {
4752
res.R.Err = err.Error()
4853
}
54+
diceotel.DiceCmdLatencyInMsHistogram.Record(
55+
ctx,
56+
time.Since(execStartTime).Milliseconds(),
57+
metric.WithAttributeSet(
58+
attribute.NewSet(
59+
attribute.String("cmd", c.Cmd),
60+
),
61+
),
62+
)
4963
// TODO: Optimize this. We are doing this for all command execution
5064
// Also, we are allowing people to override the client ID.
5165
// Also, CLientID is duplicated in command and io-thread.

0 commit comments

Comments
 (0)