diff --git a/_examples/opentelemetry-custom-provider/main.go b/_examples/opentelemetry-custom-provider/main.go index 51f63ba2f..f77f3abc2 100644 --- a/_examples/opentelemetry-custom-provider/main.go +++ b/_examples/opentelemetry-custom-provider/main.go @@ -8,9 +8,9 @@ import ( console "github.com/asynkron/goconsole" "github.com/asynkron/protoactor-go/actor" + "go.opentelemetry.io/otel" stdout "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/global" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" @@ -62,7 +62,7 @@ func stdoutExporter(ctx context.Context) metric.MeterProvider { if err := provider.Start(ctx); err != nil { log.Fatalf("could not start push controller: %v", err) } - global.SetMeterProvider(provider) + otel.SetMeterProvider(provider) return provider } diff --git a/actor/actor_context.go b/actor/actor_context.go index 0e4de9ce6..16babf194 100644 --- a/actor/actor_context.go +++ b/actor/actor_context.go @@ -12,6 +12,7 @@ import ( "github.com/asynkron/protoactor-go/metrics" "github.com/emirpasic/gods/stacks/linkedliststack" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" ) const ( @@ -428,7 +429,7 @@ func (ctx *actorContext) Stop(pid *PID) { if ok && metricsSystem.enabled { _ctx := context.Background() if instruments := metricsSystem.metrics.Get(metrics.InternalActorMetrics); instruments != nil { - instruments.ActorStoppedCount.Add(_ctx, 1, metricsSystem.CommonLabels(ctx)...) + instruments.ActorStoppedCount.Add(_ctx, 1, metric.WithAttributes(metricsSystem.CommonLabels(ctx)...)) } } } @@ -497,7 +498,7 @@ func (ctx *actorContext) InvokeUserMessage(md interface{}) { systemMetrics.CommonLabels(ctx), attribute.String("messagetype", fmt.Sprintf("%T", md)), ) - histogram.Record(_ctx, delta.Seconds(), labels...) + histogram.Record(_ctx, delta.Seconds(), metric.WithAttributes(labels...)) } } else { ctx.processMessage(md) @@ -534,7 +535,8 @@ func (ctx *actorContext) incarnateActor() { if ok && metricsSystem.enabled { _ctx := context.Background() if instruments := metricsSystem.metrics.Get(metrics.InternalActorMetrics); instruments != nil { - instruments.ActorSpawnCount.Add(_ctx, 1, metricsSystem.CommonLabels(ctx)...) } + instruments.ActorSpawnCount.Add(_ctx, 1, metric.WithAttributes(metricsSystem.CommonLabels(ctx)...)) + } } } @@ -597,7 +599,7 @@ func (ctx *actorContext) handleRestart() { if ok && metricsSystem.enabled { _ctx := context.Background() if instruments := metricsSystem.metrics.Get(metrics.InternalActorMetrics); instruments != nil { - instruments.ActorRestartedCount.Add(_ctx, 1, metricsSystem.CommonLabels(ctx)...) + instruments.ActorRestartedCount.Add(_ctx, 1, metric.WithAttributes(metricsSystem.CommonLabels(ctx)...)) } } } @@ -709,7 +711,7 @@ func (ctx *actorContext) EscalateFailure(reason interface{}, message interface{} if ok && metricsSystem.enabled { _ctx := context.Background() if instruments := metricsSystem.metrics.Get(metrics.InternalActorMetrics); instruments != nil { - instruments.ActorFailureCount.Add(_ctx, 1, metricsSystem.CommonLabels(ctx)...) + instruments.ActorFailureCount.Add(_ctx, 1, metric.WithAttributes(metricsSystem.CommonLabels(ctx)...)) } } diff --git a/actor/config.go b/actor/config.go index b0f139794..265b93bcf 100644 --- a/actor/config.go +++ b/actor/config.go @@ -6,9 +6,9 @@ import ( "time" "github.com/asynkron/protoactor-go/log" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/prometheus" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/global" sdkmetric "go.opentelemetry.io/otel/sdk/metric" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -46,7 +46,7 @@ func defaultPrometheusProvider(port int) metric.MeterProvider { } provider := sdkmetric.NewMeterProvider(sdkmetric.WithReader(exporter.Reader)) - global.SetMeterProvider(provider) + otel.SetMeterProvider(provider) http.Handle("/", promhttp.Handler()) _port := fmt.Sprintf(":%d", port) diff --git a/actor/deadletter.go b/actor/deadletter.go index 8d9727eff..107ecbc65 100644 --- a/actor/deadletter.go +++ b/actor/deadletter.go @@ -8,6 +8,7 @@ import ( "github.com/asynkron/protoactor-go/log" "github.com/asynkron/protoactor-go/metrics" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" ) type deadLetterProcess struct { @@ -82,7 +83,7 @@ func (dp *deadLetterProcess) SendUserMessage(pid *PID, message interface{}) { attribute.String("messagetype", strings.Replace(fmt.Sprintf("%T", message), "*", "", 1)), } - instruments.DeadLetterCount.Add(ctx, 1, labels...) + instruments.DeadLetterCount.Add(ctx, 1, metric.WithAttributes(labels...)) } } _, msg, sender := UnwrapEnvelope(message) diff --git a/actor/future.go b/actor/future.go index 923a8c2e4..edb97dada 100644 --- a/actor/future.go +++ b/actor/future.go @@ -11,6 +11,7 @@ import ( "github.com/asynkron/protoactor-go/log" "github.com/asynkron/protoactor-go/metrics" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" ) // ErrTimeout is the error used when a future times out before receiving a result. @@ -37,7 +38,7 @@ func NewFuture(actorSystem *ActorSystem, d time.Duration) *Future { attribute.String("address", ref.actorSystem.Address()), } - instruments.FuturesStartedCount.Add(ctx, 1, labels...) + instruments.FuturesStartedCount.Add(ctx, 1, metric.WithAttributes(labels...)) } } @@ -180,9 +181,9 @@ func (ref *futureProcess) instrument() { instruments := sysMetrics.metrics.Get(metrics.InternalActorMetrics) if instruments != nil { if ref.err == nil { - instruments.FuturesCompletedCount.Add(ctx, 1, labels...) + instruments.FuturesCompletedCount.Add(ctx, 1, metric.WithAttributes(labels...)) } else { - instruments.FuturesTimedOutCount.Add(ctx, 1, labels...) + instruments.FuturesTimedOutCount.Add(ctx, 1, metric.WithAttributes(labels...)) } } } diff --git a/actor/metrics.go b/actor/metrics.go index 9ad5d9c33..6fbbce7f0 100644 --- a/actor/metrics.go +++ b/actor/metrics.go @@ -10,11 +10,9 @@ import ( "github.com/asynkron/protoactor-go/extensions" "github.com/asynkron/protoactor-go/metrics" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/global" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/unit" ) var extensionId = extensions.NextExtensionID() @@ -46,10 +44,10 @@ func NewMetrics(provider metric.MeterProvider) *Metrics { } func (m *Metrics) PrepareMailboxLengthGauge() { - meter := global.Meter(metrics.LibName) + meter := otel.Meter(metrics.LibName) gauge, err := meter.Int64ObservableGauge("protoactor_actor_mailbox_length", - instrument.WithDescription("Actor's Mailbox Length"), - instrument.WithUnit(unit.Dimensionless)) + metric.WithDescription("Actor's Mailbox Length"), + metric.WithUnit("1")) if err != nil { err = fmt.Errorf("failed to create ActorMailBoxLength instrument, %w", err) plog.Error(err.Error(), log.Error(err)) diff --git a/actor/props.go b/actor/props.go index aaa5d97f8..699aeab6f 100644 --- a/actor/props.go +++ b/actor/props.go @@ -7,8 +7,8 @@ import ( "github.com/asynkron/protoactor-go/log" "github.com/asynkron/protoactor-go/metrics" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/global" ) type ( @@ -33,10 +33,10 @@ var ( if ok && sysMetrics.enabled { if instruments := sysMetrics.metrics.Get(metrics.InternalActorMetrics); instruments != nil { sysMetrics.PrepareMailboxLengthGauge() - meter := global.Meter(metrics.LibName) + meter := otel.Meter(metrics.LibName) if _, err := meter.RegisterCallback(func(_ context.Context, o metric.Observer) error { - o.ObserveInt64(instruments.ActorMailboxLength,int64(mb.UserMessageCount()), sysMetrics.CommonLabels(ctx)... ) + o.ObserveInt64(instruments.ActorMailboxLength, int64(mb.UserMessageCount()), metric.WithAttributes(sysMetrics.CommonLabels(ctx)...)) return nil }); err != nil { err = fmt.Errorf("failed to instrument Actor Mailbox, %w", err) diff --git a/go.mod b/go.mod index b1a736588..bd2cd1fe9 100644 --- a/go.mod +++ b/go.mod @@ -14,13 +14,14 @@ require ( github.com/opentracing/opentracing-go v1.2.0 github.com/orcaman/concurrent-map v1.0.0 github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b - github.com/stretchr/testify v1.8.2 - go.opentelemetry.io/otel v1.15.1 - go.opentelemetry.io/otel/exporters/prometheus v0.35.0 - go.opentelemetry.io/otel/metric v0.35.0 + github.com/stretchr/testify v1.8.4 + go.opentelemetry.io/otel v1.16.0 + go.opentelemetry.io/otel/exporters/prometheus v0.39.0 + go.opentelemetry.io/otel/metric v1.16.0 + go.opentelemetry.io/otel/sdk/metric v0.39.0 golang.org/x/net v0.8.0 google.golang.org/grpc v1.55.0 - google.golang.org/protobuf v1.30.0 + google.golang.org/protobuf v1.31.0 ) require ( @@ -30,9 +31,8 @@ require ( github.com/lithammer/shortuuid/v4 v4.0.0 github.com/twmb/murmur3 v1.1.6 go.etcd.io/etcd/client/v3 v3.5.7 - go.opentelemetry.io/otel/sdk/metric v0.35.0 golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf - golang.org/x/sync v0.1.0 + golang.org/x/sync v0.2.0 k8s.io/api v0.26.1 k8s.io/apimachinery v0.26.1 k8s.io/client-go v0.26.1 @@ -77,23 +77,24 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.14.0 - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/client_golang v1.16.0 + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.42.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect go.etcd.io/etcd/api/v3 v3.5.7 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect - go.opentelemetry.io/otel/sdk v1.12.0 // indirect - go.opentelemetry.io/otel/trace v1.15.1 // indirect + go.opentelemetry.io/otel/sdk v1.16.0 // indirect + go.opentelemetry.io/otel/trace v1.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.6.0 // indirect + golang.org/x/sys v0.10.0 // indirect golang.org/x/term v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect diff --git a/go.sum b/go.sum index 5b5e5b873..02e95da59 100644 --- a/go.sum +++ b/go.sum @@ -97,7 +97,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -189,8 +188,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -267,24 +266,26 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= @@ -309,8 +310,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -332,18 +333,18 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.7 h1:y3kf5Gbp4e4q7egZdn5T7W9TSHUvkClN6u+Rq9mE go.etcd.io/etcd/client/pkg/v3 v3.5.7/go.mod h1:o0Abi1MK86iad3YrWhgUsbGx1pmTS+hrORWc2CamuhY= go.etcd.io/etcd/client/v3 v3.5.7 h1:u/OhpiuCgYY8awOHlhIhmGIGpxfBU/GZBUP3m/3/Iz4= go.etcd.io/etcd/client/v3 v3.5.7/go.mod h1:sOWmj9DZUMyAngS7QQwCyAXXAL6WhgTOPLNS/NabQgw= -go.opentelemetry.io/otel v1.15.1 h1:3Iwq3lfRByPaws0f6bU3naAqOR1n5IeDWd9390kWHa8= -go.opentelemetry.io/otel v1.15.1/go.mod h1:mHHGEHVDLal6YrKMmk9LqC4a3sF5g+fHfrttQIB1NTc= -go.opentelemetry.io/otel/exporters/prometheus v0.35.0 h1:OCWu7Z5W9wNis5aViq+MqRFj2PEFmFhvIHOk32TABM0= -go.opentelemetry.io/otel/exporters/prometheus v0.35.0/go.mod h1:U0tqTnN6hnGiNKKGNN5uPOuhb/3C7gcZuh23d2k9bXc= -go.opentelemetry.io/otel/metric v0.35.0 h1:aPT5jk/w7F9zW51L7WgRqNKDElBdyRLGuBtI5MX34e8= -go.opentelemetry.io/otel/metric v0.35.0/go.mod h1:qAcbhaTRFU6uG8QM7dDo7XvFsWcugziq/5YI065TokQ= -go.opentelemetry.io/otel/sdk v1.12.0 h1:8npliVYV7qc0t1FKdpU08eMnOjgPFMnriPhn0HH4q3o= -go.opentelemetry.io/otel/sdk v1.12.0/go.mod h1:WYcvtgquYvgODEvxOry5owO2y9MyciW7JqMz6cpXShE= -go.opentelemetry.io/otel/sdk/metric v0.35.0 h1:gryV4W5GzpOhKK48/lZb8ldyWIs3DRugSVlQZmCwELA= -go.opentelemetry.io/otel/sdk/metric v0.35.0/go.mod h1:eDyp1GxSiwV98kr7w4pzrszQh/eze9MqBqPd2bCPmyE= -go.opentelemetry.io/otel/trace v1.15.1 h1:uXLo6iHJEzDfrNC0L0mNjItIp06SyaBQxu5t3xMlngY= -go.opentelemetry.io/otel/trace v1.15.1/go.mod h1:IWdQG/5N1x7f6YUlmdLeJvH9yxtuJAfc4VW5Agv9r/8= +go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= +go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel/exporters/prometheus v0.39.0 h1:whAaiHxOatgtKd+w0dOi//1KUxj3KoPINZdtDaDj3IA= +go.opentelemetry.io/otel/exporters/prometheus v0.39.0/go.mod h1:4jo5Q4CROlCpSPsXLhymi+LYrDXd2ObU5wbKayfZs7Y= +go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= +go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= +go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= +go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= +go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI= +go.opentelemetry.io/otel/sdk/metric v0.39.0/go.mod h1:piDIRgjcK7u0HCL5pCA4e74qpK/jk3NiUoAHATVAmiI= +go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= +go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -404,8 +405,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -433,8 +434,8 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= @@ -494,8 +495,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/metrics/actor_metrics.go b/metrics/actor_metrics.go index 2c4863726..54d1eea52 100644 --- a/metrics/actor_metrics.go +++ b/metrics/actor_metrics.go @@ -7,9 +7,8 @@ import ( "sync" "github.com/asynkron/protoactor-go/log" - "go.opentelemetry.io/otel/metric/global" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/unit" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/metric" ) const LibName string = "protoactor" @@ -22,23 +21,23 @@ type ActorMetrics struct { ID string // Actors - ActorFailureCount instrument.Int64Counter - ActorMailboxLength instrument.Int64ObservableGauge - ActorMessageReceiveHistogram instrument.Float64Histogram - ActorRestartedCount instrument.Int64Counter - ActorSpawnCount instrument.Int64Counter - ActorStoppedCount instrument.Int64Counter + ActorFailureCount metric.Int64Counter + ActorMailboxLength metric.Int64ObservableGauge + ActorMessageReceiveHistogram metric.Float64Histogram + ActorRestartedCount metric.Int64Counter + ActorSpawnCount metric.Int64Counter + ActorStoppedCount metric.Int64Counter // Deadletters - DeadLetterCount instrument.Int64Counter - + DeadLetterCount metric.Int64Counter + // Futures - FuturesStartedCount instrument.Int64Counter - FuturesCompletedCount instrument.Int64Counter - FuturesTimedOutCount instrument.Int64Counter + FuturesStartedCount metric.Int64Counter + FuturesCompletedCount metric.Int64Counter + FuturesTimedOutCount metric.Int64Counter // Threadpool - ThreadPoolLatency instrument.Int64Histogram + ThreadPoolLatency metric.Int64Histogram } // NewActorMetrics creates a new ActorMetrics value and returns a pointer to it @@ -50,15 +49,15 @@ func NewActorMetrics() *ActorMetrics { // newInstruments will create instruments using a meter from // the given provider p func newInstruments() *ActorMetrics { - meter := global.Meter(LibName) + meter := otel.Meter(LibName) instruments := ActorMetrics{mu: &sync.Mutex{}} var err error if instruments.ActorFailureCount, err = meter.Int64Counter( "protoactor_actor_failure_count", - instrument.WithDescription("Number of actor failures"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of actor failures"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create ActorFailureCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -66,7 +65,7 @@ func newInstruments() *ActorMetrics { if instruments.ActorMessageReceiveHistogram, err = meter.Float64Histogram( "protoactor_actor_message_receive_duration_seconds", - instrument.WithDescription("Actor's messages received duration in seconds"), + metric.WithDescription("Actor's messages received duration in seconds"), ); err != nil { err = fmt.Errorf("failed to create ActorMessageReceiveHistogram instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -74,8 +73,8 @@ func newInstruments() *ActorMetrics { if instruments.ActorRestartedCount, err = meter.Int64Counter( "protoactor_actor_restarted_count", - instrument.WithDescription("Number of actors restarts"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of actors restarts"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create ActorRestartedCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -83,8 +82,8 @@ func newInstruments() *ActorMetrics { if instruments.ActorStoppedCount, err = meter.Int64Counter( "protoactor_actor_stopped_count", - instrument.WithDescription("Number of actors stopped"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of actors stopped"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create ActorStoppedCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -92,8 +91,8 @@ func newInstruments() *ActorMetrics { if instruments.ActorSpawnCount, err = meter.Int64Counter( "protoactor_actor_spawn_count", - instrument.WithDescription("Number of actors spawn"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of actors spawn"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create ActorSpawnCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -101,8 +100,8 @@ func newInstruments() *ActorMetrics { if instruments.DeadLetterCount, err = meter.Int64Counter( "protoactor_deadletter_count", - instrument.WithDescription("Number of deadletters"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of deadletters"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create DeadLetterCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -110,8 +109,8 @@ func newInstruments() *ActorMetrics { if instruments.FuturesCompletedCount, err = meter.Int64Counter( "protoactor_futures_completed_count", - instrument.WithDescription("Number of futures completed"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of futures completed"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create FuturesCompletedCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -119,8 +118,8 @@ func newInstruments() *ActorMetrics { if instruments.FuturesStartedCount, err = meter.Int64Counter( "protoactor_futures_started_count", - instrument.WithDescription("Number of futures started"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of futures started"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create FuturesStartedCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -128,8 +127,8 @@ func newInstruments() *ActorMetrics { if instruments.FuturesTimedOutCount, err = meter.Int64Counter( "protoactor_futures_timed_out_count", - instrument.WithDescription("Number of futures timed out"), - instrument.WithUnit(unit.Dimensionless), + metric.WithDescription("Number of futures timed out"), + metric.WithUnit("1"), ); err != nil { err = fmt.Errorf("failed to create FuturesTimedOutCount instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -137,8 +136,8 @@ func newInstruments() *ActorMetrics { if instruments.ThreadPoolLatency, err = meter.Int64Histogram( "protoactor_thread_pool_latency_duration_seconds", - instrument.WithDescription("History of latency in second"), - instrument.WithUnit(unit.Milliseconds), + metric.WithDescription("History of latency in second"), + metric.WithUnit("ms"), ); err != nil { err = fmt.Errorf("failed to create ThreadPoolLatency instrument, %w", err) plog.Error(err.Error(), log.Error(err)) @@ -148,7 +147,7 @@ func newInstruments() *ActorMetrics { } // SetActorMailboxLengthGauge makes sure access to ActorMailboxLength is sequenced -func (am *ActorMetrics) SetActorMailboxLengthGauge(gauge instrument.Int64ObservableGauge) { +func (am *ActorMetrics) SetActorMailboxLengthGauge(gauge metric.Int64ObservableGauge) { // lock our mutex am.mu.Lock() defer am.mu.Unlock()