Skip to content

Commit

Permalink
fix(metrics): bump opentelemetry dependencies
Browse files Browse the repository at this point in the history
These contain a breaking change we had to account for and it is usually
best to bump them together.
  • Loading branch information
Edholm committed Feb 6, 2023
1 parent 349b371 commit 2c7dae0
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 127 deletions.
17 changes: 8 additions & 9 deletions cloudmonitoring/metricmiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/metric/instrument"
"go.opentelemetry.io/otel/metric/instrument/syncint64"
"go.opentelemetry.io/otel/metric/unit"
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"google.golang.org/grpc"
Expand All @@ -32,31 +31,31 @@ const (
func NewMetricMiddleware() (MetricMiddleware, error) {
meter := global.MeterProvider().Meter("cloudrunner-go/cloudmonitoring")

serverRequestCount, err := meter.SyncInt64().Counter(
serverRequestCount, err := meter.Int64Counter(
serverRequestCountMetricName,
instrument.WithUnit(unit.Dimensionless),
instrument.WithDescription("Count of RPCs received by a gRPC server."),
)
if err != nil {
return MetricMiddleware{}, fmt.Errorf("create server request count counter: %w", err)
}
serverRequestDuration, err := meter.SyncInt64().Histogram(
serverRequestDuration, err := meter.Int64Histogram(
serverRequestDurationMetricName,
instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("Duration of RPCs received by a gRPC server."),
)
if err != nil {
return MetricMiddleware{}, fmt.Errorf("create server request duration histogram: %w", err)
}
clientRequestCount, err := meter.SyncInt64().Counter(
clientRequestCount, err := meter.Int64Counter(
clientRequestCountMetricName,
instrument.WithUnit(unit.Dimensionless),
instrument.WithDescription("Count of RPCs sent by a gRPC client."),
)
if err != nil {
return MetricMiddleware{}, fmt.Errorf("create client request count counter: %w", err)
}
clientRequestDuration, err := meter.SyncInt64().Histogram(
clientRequestDuration, err := meter.Int64Histogram(
clientRequestDurationMetricName,
instrument.WithUnit(unit.Milliseconds),
instrument.WithDescription("Duration of RPCs sent by a gRPC client."),
Expand All @@ -73,10 +72,10 @@ func NewMetricMiddleware() (MetricMiddleware, error) {
}

type MetricMiddleware struct {
serverRequestCount syncint64.Counter
serverRequestDuration syncint64.Histogram
clientRequestCount syncint64.Counter
clientRequestDuration syncint64.Histogram
serverRequestCount instrument.Int64Counter
serverRequestDuration instrument.Int64Histogram
clientRequestCount instrument.Int64Counter
clientRequestDuration instrument.Int64Histogram
}

// GRPCUnaryServerInterceptor implements grpc.UnaryServerInterceptor and
Expand Down
8 changes: 4 additions & 4 deletions cloudpubsub/httphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import (
"net/http"
"time"

"cloud.google.com/go/pubsub/apiv1/pubsubpb"
"go.einride.tech/cloudrunner/cloudrequestlog"
"go.einride.tech/cloudrunner/cloudstatus"
"go.einride.tech/cloudrunner/cloudzap"
"go.uber.org/zap"
"google.golang.org/genproto/googleapis/pubsub/v1"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

// HTTPHandler creates a new HTTP handler for Cloud Pub/Sub push messages.
// See: https://cloud.google.com/pubsub/docs/push
func HTTPHandler(fn func(context.Context, *pubsub.PubsubMessage) error) http.Handler {
func HTTPHandler(fn func(context.Context, *pubsubpb.PubsubMessage) error) http.Handler {
return httpHandlerFn(fn)
}

type httpHandlerFn func(ctx context.Context, message *pubsub.PubsubMessage) error
type httpHandlerFn func(ctx context.Context, message *pubsubpb.PubsubMessage) error

func (fn httpHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
Expand All @@ -45,7 +45,7 @@ func (fn httpHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
pubsubMessage := pubsub.PubsubMessage{
pubsubMessage := pubsubpb.PubsubMessage{
Data: payload.Message.Data,
Attributes: payload.Message.Attributes,
MessageId: payload.Message.MessageID,
Expand Down
8 changes: 4 additions & 4 deletions cloudpubsub/httphandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"google.golang.org/genproto/googleapis/pubsub/v1"
"cloud.google.com/go/pubsub/apiv1/pubsubpb"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/timestamppb"
"gotest.tools/v3/assert"
Expand All @@ -31,7 +31,7 @@ func TestNewHTTPHandler(t *testing.T) {
"subscription": "projects/myproject/subscriptions/mysubscription"
}
`
expectedMessage := &pubsub.PubsubMessage{
expectedMessage := &pubsubpb.PubsubMessage{
Data: []byte("Hello Cloud Pub/Sub! Here is my message!"),
Attributes: map[string]string{"key": "value"},
MessageId: "2070443601311540",
Expand All @@ -40,10 +40,10 @@ func TestNewHTTPHandler(t *testing.T) {
Nanos: 749000000,
},
}
var actualMessage *pubsub.PubsubMessage
var actualMessage *pubsubpb.PubsubMessage
var subscription string
var subscriptionOk bool
fn := func(ctx context.Context, message *pubsub.PubsubMessage) error {
fn := func(ctx context.Context, message *pubsubpb.PubsubMessage) error {
actualMessage = message
subscription, subscriptionOk = GetSubscription(ctx)
return nil
Expand Down
65 changes: 33 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,66 @@ module go.einride.tech/cloudrunner
go 1.18

require (
cloud.google.com/go/compute/metadata v0.2.1
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/profiler v0.3.1
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.34.2
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.10.1
github.com/GoogleCloudPlatform/opentelemetry-operations-go/propagator v0.0.0-20221104160235-e955c204f4f2
cloud.google.com/go/pubsub v1.27.1
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.35.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.11.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/propagator v0.35.0
github.com/google/go-cmp v0.5.9
github.com/soheilhy/cmux v0.1.5
go.einride.tech/protobuf-sensitive v0.3.0
go.opencensus.io v0.24.0
go.opentelemetry.io/contrib/detectors/gcp v1.11.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.36.4
go.opentelemetry.io/contrib/instrumentation/host v0.36.4
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.36.4
go.opentelemetry.io/contrib/instrumentation/runtime v0.36.4
go.opentelemetry.io/otel v1.11.1
go.opentelemetry.io/otel/bridge/opencensus v0.33.0
go.opentelemetry.io/otel/metric v0.33.0
go.opentelemetry.io/otel/sdk v1.11.1
go.opentelemetry.io/otel/sdk/metric v0.33.0
go.opentelemetry.io/contrib/detectors/gcp v1.13.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.38.0
go.opentelemetry.io/contrib/instrumentation/host v0.38.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.38.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.38.0
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel/bridge/opencensus v0.35.0
go.opentelemetry.io/otel/metric v0.35.0
go.opentelemetry.io/otel/sdk v1.12.0
go.opentelemetry.io/otel/sdk/metric v0.35.0
go.uber.org/zap v1.24.0
golang.org/x/oauth2 v0.4.0
golang.org/x/sync v0.1.0
google.golang.org/api v0.103.0
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c
google.golang.org/grpc v1.51.0
google.golang.org/api v0.109.0
google.golang.org/genproto v0.0.0-20230202175211-008b39050e57
google.golang.org/grpc v1.52.3
google.golang.org/grpc/examples v0.0.0-20220915225546-9c3e589d3ee6
google.golang.org/protobuf v1.28.1
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.4.0
)

require (
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.12.1 // indirect
cloud.google.com/go/monitoring v1.8.0 // indirect
cloud.google.com/go/trace v1.4.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v0.34.1 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.34.2 // indirect
cloud.google.com/go v0.109.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/monitoring v1.12.0 // indirect
cloud.google.com/go/trace v1.8.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.11.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.35.0 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/pprof v0.0.0-20221103000818-d260c55eee4c // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/google/pprof v0.0.0-20230131232505-5a9e8f65f08f // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/shirou/gopsutil/v3 v3.22.10 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/shirou/gopsutil/v3 v3.23.1 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opentelemetry.io/otel/trace v1.11.1 // indirect
go.opentelemetry.io/otel/trace v1.12.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
Expand Down
Loading

0 comments on commit 2c7dae0

Please sign in to comment.