From 075119db9877f94551295e267bc242382e24dc07 Mon Sep 17 00:00:00 2001 From: Denise Li Date: Fri, 26 Jul 2024 13:21:16 -0400 Subject: [PATCH 1/2] delete observability package from Go SDK --- go-runtime/ftl/observability/metrics.go | 114 ------------------------ go-runtime/ftl/observability/traces.go | 22 ----- 2 files changed, 136 deletions(-) delete mode 100644 go-runtime/ftl/observability/metrics.go delete mode 100644 go-runtime/ftl/observability/traces.go diff --git a/go-runtime/ftl/observability/metrics.go b/go-runtime/ftl/observability/metrics.go deleted file mode 100644 index 0076c4c3bd..0000000000 --- a/go-runtime/ftl/observability/metrics.go +++ /dev/null @@ -1,114 +0,0 @@ -package observability - -import ( - "context" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/metric" - - "github.com/TBD54566975/ftl/internal/rpc" -) - -func MeterWithVerb(ctx context.Context) metric.Meter { - verb, ok := rpc.VerbFromContext(ctx) - if !ok { - panic("traces: no verb in context") - } - return otel.GetMeterProvider().Meter(verb.Name) -} - -func Int64Counter(ctx context.Context, name string, options ...metric.Int64CounterOption) metric.Int64Counter { - counter, err := MeterWithVerb(ctx).Int64Counter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Int64UpDownCounter(ctx context.Context, name string, options ...metric.Int64UpDownCounterOption) metric.Int64UpDownCounter { - counter, err := MeterWithVerb(ctx).Int64UpDownCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Int64Histogram(ctx context.Context, name string, options ...metric.Int64HistogramOption) metric.Int64Histogram { - counter, err := MeterWithVerb(ctx).Int64Histogram(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Int64ObservableCounter(ctx context.Context, name string, options ...metric.Int64ObservableCounterOption) metric.Int64ObservableCounter { - counter, err := MeterWithVerb(ctx).Int64ObservableCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Int64ObservableUpDownCounter(ctx context.Context, name string, options ...metric.Int64ObservableUpDownCounterOption) metric.Int64ObservableUpDownCounter { - counter, err := MeterWithVerb(ctx).Int64ObservableUpDownCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Int64ObservableGauge(ctx context.Context, name string, options ...metric.Int64ObservableGaugeOption) metric.Int64ObservableGauge { - counter, err := MeterWithVerb(ctx).Int64ObservableGauge(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64Counter(ctx context.Context, name string, options ...metric.Float64CounterOption) metric.Float64Counter { - counter, err := MeterWithVerb(ctx).Float64Counter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64UpDownCounter(ctx context.Context, name string, options ...metric.Float64UpDownCounterOption) metric.Float64UpDownCounter { - counter, err := MeterWithVerb(ctx).Float64UpDownCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64Histogram(ctx context.Context, name string, options ...metric.Float64HistogramOption) metric.Float64Histogram { - counter, err := MeterWithVerb(ctx).Float64Histogram(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64ObservableCounter(ctx context.Context, name string, options ...metric.Float64ObservableCounterOption) metric.Float64ObservableCounter { - counter, err := MeterWithVerb(ctx).Float64ObservableCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64ObservableUpDownCounter(ctx context.Context, name string, options ...metric.Float64ObservableUpDownCounterOption) metric.Float64ObservableUpDownCounter { - counter, err := MeterWithVerb(ctx).Float64ObservableUpDownCounter(name, options...) - if err != nil { - panic(err) - } - return counter -} - -func Float64ObservableGauge(ctx context.Context, name string, options ...metric.Float64ObservableGaugeOption) metric.Float64ObservableGauge { - counter, err := MeterWithVerb(ctx).Float64ObservableGauge(name, options...) - if err != nil { - panic(err) - } - return counter -} diff --git a/go-runtime/ftl/observability/traces.go b/go-runtime/ftl/observability/traces.go deleted file mode 100644 index 96263bd190..0000000000 --- a/go-runtime/ftl/observability/traces.go +++ /dev/null @@ -1,22 +0,0 @@ -package observability - -import ( - "context" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/trace" - - "github.com/TBD54566975/ftl/internal/rpc" -) - -func TracerWithVerb(ctx context.Context) trace.Tracer { - verb, ok := rpc.VerbFromContext(ctx) - if !ok { - panic("traces: no verb in context") - } - return otel.GetTracerProvider().Tracer(verb.Name) -} - -func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) { - return TracerWithVerb(ctx).Start(ctx, name, opts...) //nolint:spancheck -} From 6a527eed3eac60f797f0c788d4b1e57965a61ffa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 26 Jul 2024 17:27:46 +0000 Subject: [PATCH 2/2] chore(autofmt): Automated formatting --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6b889fa076..4cbcf4fd75 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,6 @@ require ( go.opentelemetry.io/otel/metric v1.28.0 go.opentelemetry.io/otel/sdk v1.28.0 go.opentelemetry.io/otel/sdk/metric v1.28.0 - go.opentelemetry.io/otel/trace v1.28.0 go.uber.org/automaxprocs v1.5.3 golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 golang.org/x/mod v0.19.0 @@ -102,6 +101,7 @@ require ( github.com/stretchr/objx v0.5.2 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.26.0 // indirect + go.opentelemetry.io/otel/trace v1.28.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect golang.org/x/tools v0.22.0 // indirect gotest.tools/v3 v3.5.1 // indirect