Skip to content

Commit 5d6b8d2

Browse files
committed
feat: add entropy http client and db metrics
1 parent 6e6a6fb commit 5d6b8d2

File tree

11 files changed

+202
-64
lines changed

11 files changed

+202
-64
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ entropy*.dev.yml
2929
test_*.yml
3030
test_*.json
3131
requests.http
32-
entropy.yaml
32+
entropy.yaml
33+
.DS_Store

core/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (svc *Service) handleSync(ctx context.Context, res resource.Resource) (*res
133133

134134
func setupCounter(meter metric.Meter, countername SyncStatus) (metric.Int64Counter, error) {
135135
return meter.Int64Counter(
136-
fmt.Sprintf("%s_counter", countername),
136+
fmt.Sprintf("entropy_%s_counter", countername),
137137
metric.WithDescription(fmt.Sprintf("Total number of %s performed", countername)),
138138
metric.WithUnit("1"),
139139
)

docker-compose.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3"
2-
31
services:
42
pg14:
53
image: "postgres:14-alpine"
@@ -9,11 +7,15 @@ services:
97
- "5432:5432"
108
volumes:
119
- pgdata:/var/lib/postgresql/data
12-
environment:
13-
- PUID=1000
14-
- PGID=1000
1510
restart: unless-stopped
1611
container_name: pg14
17-
12+
otel-collector:
13+
image: otel/opentelemetry-collector-contrib:0.123.0
14+
command: [ "--config=/etc/otel/otel-collector-config.yaml" ]
15+
volumes:
16+
- ./docker:/etc/otel
17+
ports:
18+
- "4317:4317" # Otel grpc port`
19+
- "4318:4318" # Otel http port`
1820
volumes:
1921
pgdata:

docker/otel-collector-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
endpoint: :4317
6+
http:
7+
endpoint: :4318
8+
9+
exporters:
10+
debug:
11+
verbosity: detailed
12+
13+
extensions:
14+
health_check: {}
15+
processors:
16+
batch: {}
17+
# If set to null, will be overridden with values based on k8s resource limits
18+
memory_limiter:
19+
check_interval: 1s
20+
limit_percentage: 50
21+
service:
22+
telemetry:
23+
metrics:
24+
address: 0.0.0.0:8888
25+
extensions:
26+
- health_check
27+
pipelines:
28+
logs:
29+
exporters:
30+
- debug
31+
processors:
32+
- memory_limiter
33+
- batch
34+
receivers:
35+
- otlp
36+
metrics:
37+
exporters:
38+
- debug
39+
processors:
40+
- memory_limiter
41+
- batch
42+
receivers:
43+
- otlp

entropy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ telemetry:
6363
newrelic_api_key: ""
6464

6565
# enable_otel_agent enables the OpenTelemetry Exporter for both traces and views.
66-
enable_otel_agent: false
66+
enable_otel_agent: true
6767

6868
# otel_agent_addr is the addr of OpenTelemetry Collector/Agent. This is where the
6969
# opene-telemetry exporter will publish the collected traces/views to.
70-
otel_agent_addr: "localhost:8088"
70+
otel_agent_addr: "localhost:4317"

go.mod

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/Masterminds/squirrel v1.5.4
1010
github.com/ghodss/yaml v1.0.0
1111
github.com/go-playground/validator/v10 v10.15.4
12-
github.com/google/go-cmp v0.6.0
12+
github.com/google/go-cmp v0.7.0
1313
github.com/gorilla/mux v1.8.0
1414
github.com/goto/salt v0.3.7
1515
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
@@ -25,13 +25,15 @@ require (
2525
github.com/spf13/cobra v1.7.0
2626
github.com/stretchr/testify v1.10.0
2727
github.com/xeipuuv/gojsonschema v1.2.0
28+
go.nhat.io/otelsql v0.15.0
2829
go.opencensus.io v0.24.0
29-
go.opentelemetry.io/otel v1.34.0
30+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0
31+
go.opentelemetry.io/otel v1.35.0
3032
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.45.0
3133
go.opentelemetry.io/otel/exporters/prometheus v0.56.0
32-
go.opentelemetry.io/otel/metric v1.34.0
33-
go.opentelemetry.io/otel/sdk v1.34.0
34-
go.opentelemetry.io/otel/sdk/metric v1.34.0
34+
go.opentelemetry.io/otel/metric v1.35.0
35+
go.opentelemetry.io/otel/sdk v1.35.0
36+
go.opentelemetry.io/otel/sdk/metric v1.35.0
3537
go.uber.org/zap v1.26.0
3638
google.golang.org/api v0.141.0
3739
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97
@@ -46,6 +48,8 @@ require (
4648
sigs.k8s.io/kind v0.23.0
4749
)
4850

51+
require github.com/felixge/httpsnoop v1.0.4 // indirect
52+
4953
require (
5054
github.com/Microsoft/go-winio v0.6.1 // indirect
5155
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
@@ -91,7 +95,7 @@ require (
9195
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
9296
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
9397
github.com/fatih/color v1.15.0 // indirect
94-
github.com/fsnotify/fsnotify v1.6.0 // indirect
98+
github.com/fsnotify/fsnotify v1.7.0 // indirect
9599
github.com/go-errors/errors v1.5.0 // indirect
96100
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
97101
github.com/go-logr/logr v1.4.2 // indirect
@@ -123,7 +127,7 @@ require (
123127
github.com/magiconair/properties v1.8.7 // indirect
124128
github.com/mailru/easyjson v0.7.7 // indirect
125129
github.com/mattn/go-colorable v0.1.13 // indirect
126-
github.com/mattn/go-isatty v0.0.19 // indirect
130+
github.com/mattn/go-isatty v0.0.20 // indirect
127131
github.com/mattn/go-runewidth v0.0.15 // indirect
128132
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
129133
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
@@ -176,7 +180,7 @@ require (
176180
golang.org/x/net v0.32.0 // indirect
177181
golang.org/x/oauth2 v0.24.0
178182
golang.org/x/sync v0.10.0
179-
golang.org/x/sys v0.29.0 // indirect
183+
golang.org/x/sys v0.30.0 // indirect
180184
golang.org/x/term v0.27.0 // indirect
181185
golang.org/x/text v0.21.0 // indirect
182186
golang.org/x/time v0.3.0 // indirect
@@ -228,7 +232,7 @@ require (
228232
github.com/valyala/fasthttp v1.50.0 // indirect
229233
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
230234
go.opentelemetry.io/contrib/instrumentation/runtime v0.59.0
231-
go.opentelemetry.io/otel/trace v1.34.0 // indirect
235+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
232236
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
233237
golang.org/x/arch v0.5.0 // indirect
234238
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect

0 commit comments

Comments
 (0)