Skip to content

Commit f45fa21

Browse files
committed
feat: update otel
1 parent 007023a commit f45fa21

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ require (
1818
github.com/stretchr/testify v1.8.2
1919
github.com/uber-go/tally v3.4.3+incompatible
2020
go.etcd.io/bbolt v1.3.7
21-
go.opentelemetry.io/otel v1.14.0
22-
go.opentelemetry.io/otel/metric v0.37.0
23-
go.opentelemetry.io/otel/trace v1.14.0
21+
go.opentelemetry.io/otel v1.15.0
22+
go.opentelemetry.io/otel/metric v0.38.0
23+
go.opentelemetry.io/otel/trace v1.15.0
2424
go.uber.org/atomic v1.10.0
2525
go.uber.org/multierr v1.11.0
2626
go.uber.org/zap v1.24.0

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7U
9595
github.com/go-faster/xor v1.0.0 h1:2o8vTOgErSGHP3/7XwA5ib1FTtUsNtwCoLLBjl31X38=
9696
github.com/go-faster/xor v1.0.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ=
9797
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
98+
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
99+
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
98100
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
99101
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
100102
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
@@ -370,12 +372,12 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
370372
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
371373
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
372374
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
373-
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
374-
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
375-
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
376-
go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s=
377-
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
378-
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
375+
go.opentelemetry.io/otel v1.15.0 h1:NIl24d4eiLJPM0vKn4HjLYM+UZf6gSfi9Z+NmCxkWbk=
376+
go.opentelemetry.io/otel v1.15.0/go.mod h1:qfwLEbWhLPk5gyWrne4XnF0lC8wtywbuJbgfAE3zbek=
377+
go.opentelemetry.io/otel/metric v0.38.0 h1:vv/Nv/44S3GzMMmeUhaesBKsAenE6xLkTVWL+zuv30w=
378+
go.opentelemetry.io/otel/metric v0.38.0/go.mod h1:uAtxN5hl8aXh5irD8afBtSwQU5Zjg64WWSz6KheZxBg=
379+
go.opentelemetry.io/otel/trace v1.15.0 h1:5Fwje4O2ooOxkfyqI/kJwxWotggDLix4BSAvpE1wlpo=
380+
go.opentelemetry.io/otel/trace v1.15.0/go.mod h1:CUsmE2Ht1CRkvE8OsMESvraoZrrcgD1J2W8GV1ev0Y4=
379381
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
380382
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
381383
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=

oteltg/middleware.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func (m Middleware) Handle(next tg.Invoker) telegram.InvokeFunc {
4242

4343
ctx, span := m.tracer.Start(ctx, spanName, trace.WithAttributes(attrs...))
4444
defer span.End()
45-
m.count.Add(ctx, 1, attrs...)
45+
m.count.Add(ctx, 1, metric.WithAttributes(attrs...))
4646
start := time.Now()
4747

4848
// Call actual method.
4949
err := next.Invoke(ctx, input, output)
5050

5151
// Observe.
52-
m.duration.Record(ctx, time.Since(start).Seconds(), attrs...)
52+
m.duration.Record(ctx, time.Since(start).Seconds(), metric.WithAttributes(attrs...))
5353
if err != nil {
5454
var errAttrs []attribute.KeyValue
5555
if rpcErr, ok := tgerr.As(err); ok {
@@ -66,7 +66,7 @@ func (m Middleware) Handle(next tg.Invoker) telegram.InvokeFunc {
6666
}
6767
span.RecordError(err, trace.WithAttributes(errAttrs...))
6868
attrs = append(attrs, errAttrs...)
69-
m.failures.Add(ctx, 1, attrs...)
69+
m.failures.Add(ctx, 1, metric.WithAttributes(attrs...))
7070
} else {
7171
span.SetStatus(codes.Ok, "")
7272
}

oteltg/middleware_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/require"
8-
"go.opentelemetry.io/otel/metric"
8+
"go.opentelemetry.io/otel/metric/noop"
99
"go.opentelemetry.io/otel/trace"
1010

1111
"github.com/gotd/td/bin"
@@ -20,7 +20,7 @@ func (i invoker) Invoke(ctx context.Context, input bin.Encoder, output bin.Decod
2020
}
2121

2222
func TestMiddleware_Handle(t *testing.T) {
23-
m, err := New(metric.NewNoopMeterProvider(), trace.NewNoopTracerProvider())
23+
m, err := New(noop.NewMeterProvider(), trace.NewNoopTracerProvider())
2424
require.NoError(t, err)
2525

2626
okInvoker := invoker(func(ctx context.Context, input bin.Encoder, output bin.Decoder) error {

0 commit comments

Comments
 (0)