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

bump go.opentelemetry.io/otel #870

Merged
merged 2 commits into from
Jul 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _examples/opentelemetry-custom-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
12 changes: 7 additions & 5 deletions actor/actor_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)...))
}
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)...))
}
}
}

Expand Down Expand Up @@ -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)...))
}
}
}
Expand Down Expand Up @@ -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)...))
}
}

Expand Down
4 changes: 2 additions & 2 deletions actor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion actor/deadletter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions actor/future.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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...))
}
}

Expand Down Expand Up @@ -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...))
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions actor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions actor/props.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand Down
29 changes: 15 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading