From d33b97afaaf481a3f73f6327a34514563146daee Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Wed, 5 Jul 2023 17:58:19 +0200 Subject: [PATCH 1/4] Extract tracer to its own package Add OpenTracing Bridge Signed-off-by: Kemal Akkoyun --- README.md | 4 +- go.mod | 13 ++- go.sum | 18 +++++ pkg/parca/parca.go | 143 +++++++++++++++++++------------- pkg/tracer/tracer.go | 188 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 304 insertions(+), 62 deletions(-) create mode 100644 pkg/tracer/tracer.go diff --git a/README.md b/README.md index 42640ce8c80..c11585f0699 100644 --- a/README.md +++ b/README.md @@ -93,10 +93,10 @@ Flags: --log-level="info" Log level. --log-format="logfmt" Configure if structured logging as JSON or as logfmt + --otlp-address=STRING The endpoint to send OTLP traces to. + --otlp-exporter="grpc" The OTLP exporter to use. --cors-allowed-origins=CORS-ALLOWED-ORIGINS,... Allowed CORS origins. - --otlp-address=STRING OpenTelemetry collector address to send traces - to. --version Show application version. --path-prefix="" Path prefix for the UI --mutex-profile-fraction=0 diff --git a/go.mod b/go.mod index 4d6cfcecea6..c05f2105947 100644 --- a/go.mod +++ b/go.mod @@ -28,6 +28,7 @@ require ( github.com/klauspost/compress v1.16.7 github.com/nanmu42/limitio v1.0.0 github.com/oklog/run v1.1.0 + github.com/opentracing/opentracing-go v1.2.0 github.com/polarsignals/frostdb v0.0.0-20230626160949-575a3f643680 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 @@ -37,8 +38,13 @@ require ( github.com/thanos-io/objstore v0.0.0-20230522103316-23ebe2eacadd go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 + go.opentelemetry.io/contrib/propagators/autoprop v0.42.0 go.opentelemetry.io/otel v1.16.0 + go.opentelemetry.io/otel/bridge/opentracing v1.16.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.16.0 + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 go.opentelemetry.io/otel/sdk v1.16.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/atomic v1.11.0 @@ -192,7 +198,6 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/oracle/oci-go-sdk/v65 v65.13.0 // indirect github.com/ovh/go-ovh v1.4.1 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect @@ -215,11 +220,15 @@ require ( github.com/zeebo/xxh3 v1.0.2 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/propagators/aws v1.17.0 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.17.0 // indirect + go.opentelemetry.io/contrib/propagators/jaeger v1.17.0 // indirect + go.opentelemetry.io/contrib/propagators/ot v1.17.0 // indirect go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/goleak v1.2.1 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/sys v0.10.0 // indirect diff --git a/go.sum b/go.sum index 956b9e8cb92..b693d53eef9 100644 --- a/go.sum +++ b/go.sum @@ -933,14 +933,30 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0/go.mod h1:5z+/ZWJQKXa9YT34fQNx5K8Hd1EoIhvtUygUQPqEOgQ= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 h1:0vzgiFDsCh/jxRCR1xcRrtMoeCu2itXz/PsXst5P8rI= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0/go.mod h1:y0vOY2OKFMOTvwxKfurStPayUUKGHlNeVqNneHmFXr0= +go.opentelemetry.io/contrib/propagators/autoprop v0.42.0 h1:s2RzYOAqHVgG23q8fPWYChobUoZM6rJZ98EnylJr66w= +go.opentelemetry.io/contrib/propagators/autoprop v0.42.0/go.mod h1:Mv/tWNtZn+NbALDb2XcItP0OM3lWWZjAfSroINxfW+Y= +go.opentelemetry.io/contrib/propagators/aws v1.17.0 h1:IX8d7l2uRw61BlmZBOTQFaK+y22j6vytMVTs9wFrO+c= +go.opentelemetry.io/contrib/propagators/aws v1.17.0/go.mod h1:pAlCYRWff4uGqRXOVn3WP8pDZ5E0K56bEoG7a1VSL4k= +go.opentelemetry.io/contrib/propagators/b3 v1.17.0 h1:ImOVvHnku8jijXqkwCSyYKRDt2YrnGXD4BbhcpfbfJo= +go.opentelemetry.io/contrib/propagators/b3 v1.17.0/go.mod h1:IkfUfMpKWmynvvE0264trz0sf32NRTZL4nuAN9AbWRc= +go.opentelemetry.io/contrib/propagators/jaeger v1.17.0 h1:Zbpbmwav32Ea5jSotpmkWEl3a6Xvd4tw/3xxGO1i05Y= +go.opentelemetry.io/contrib/propagators/jaeger v1.17.0/go.mod h1:tcTUAlmO8nuInPDSBVfG+CP6Mzjy5+gNV4mPxMbL0IA= +go.opentelemetry.io/contrib/propagators/ot v1.17.0 h1:ufo2Vsz8l76eI47jFjuVyjyB3Ae2DmfiCV/o6Vc8ii0= +go.opentelemetry.io/contrib/propagators/ot v1.17.0/go.mod h1:SbKPj5XGp8K/sGm05XblaIABgMgw2jDczP8gGeuaVLk= 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/bridge/opentracing v1.16.0 h1:Bgwi7P5NCV3bv2T13bwG0WfsxaT4SjQ1rDdmFc5P7do= +go.opentelemetry.io/otel/bridge/opentracing v1.16.0/go.mod h1:X2Y6v3RnoiBGtVFd4KoHy/ftHiCJKJXzlv6W2gPsN1Q= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0/go.mod h1:vLarbg68dH2Wa77g71zmKQqlQ8+8Rq3GRG31uc0WcWI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 h1:cbsD4cUcviQGXdw8+bo5x2wazq10SKz8hEbtCRPcU78= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0/go.mod h1:JgXSGah17croqhJfhByOLVY719k1emAXC8MVhCIJlRs= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 h1:TVQp/bboR4mhZSav+MdgXB8FaRho1RC8UwVn3T0vjVc= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0/go.mod h1:I33vtIe0sR96wfrUcilIzLoA3mLHhRmz9S9Te0S3gDo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.16.0 h1:iqjq9LAB8aK++sKVcELezzn655JnBNdsDhghU4G/So8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.16.0/go.mod h1:hGXzO5bhhSHZnKvrDaXB82Y9DRFour0Nz/KrBh7reWw= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 h1:+XWJd3jf75RXJq29mxbuXhCXFDG3S3R4vBUeSI2P7tE= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0/go.mod h1:hqgzBPTf4yONMFgdZvL/bK42R/iinTyVQtiWihs3SZc= 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= @@ -965,6 +981,8 @@ go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= diff --git a/pkg/parca/parca.go b/pkg/parca/parca.go index f1acf835136..5244125e523 100644 --- a/pkg/parca/parca.go +++ b/pkg/parca/parca.go @@ -34,6 +34,7 @@ import ( grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/oklog/run" + "github.com/opentracing/opentracing-go" "github.com/polarsignals/frostdb" "github.com/polarsignals/frostdb/dynparquet" "github.com/polarsignals/frostdb/query" @@ -43,12 +44,8 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/thanos-io/objstore" "github.com/thanos-io/objstore/client" - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + tracing "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/sdk/resource" - sdktrace "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.4.0" "go.opentelemetry.io/otel/trace" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -71,6 +68,7 @@ import ( "github.com/parca-dev/parca/pkg/server" "github.com/parca-dev/parca/pkg/signedrequests" "github.com/parca-dev/parca/pkg/symbolizer" + "github.com/parca-dev/parca/pkg/tracer" ) const ( @@ -86,9 +84,9 @@ type Flags struct { Port string `default:"" help:"(DEPRECATED) Use http-address instead."` Logs FlagsLogs `embed:"" prefix:"log-"` + OTLP FlagsOTLP `embed:"" prefix:"otlp-"` CORSAllowedOrigins []string `help:"Allowed CORS origins."` - OTLPAddress string `help:"OpenTelemetry collector address to send traces to."` Version bool `help:"Show application version."` PathPrefix string `default:"" help:"Path prefix for the UI"` @@ -125,6 +123,12 @@ type FlagsLogs struct { Format string `enum:"logfmt,json" default:"logfmt" help:"Configure if structured logging as JSON or as logfmt"` } +// FlagsOTLP provides OTLP configuration flags. +type FlagsOTLP struct { + Address string `help:"The endpoint to send OTLP traces to."` + Exporter string `default:"grpc" enum:"grpc,http,stdout" help:"The OTLP exporter to use."` +} + type FlagsStorage struct { GranuleSize int64 `default:"26265625" help:"Granule size in bytes for storage."` ActiveMemory int64 `default:"536870912" help:"Amount of memory to use for active storage. Defaults to 512MB."` @@ -163,16 +167,23 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags goruntime.SetBlockProfileRate(flags.BlockProfileRate) goruntime.SetMutexProfileFraction(flags.MutexProfileFraction) - tracerProvider := trace.NewNoopTracerProvider() - if flags.OTLPAddress != "" { - var closer func() + // Initialize tracing. + var ( + exporter tracer.Exporter + tracerProvider = trace.NewNoopTracerProvider() + ) + if flags.OTLP.Address != "" { var err error - tracerProvider, closer, err = initTracer(logger, flags.OTLPAddress) + + exporter, err = tracer.NewExporter(flags.OTLP.Exporter, flags.OTLP.Address) if err != nil { - level.Error(logger).Log("msg", "failed to initialize tracing", "err", err) - return err + level.Error(logger).Log("msg", "failed to create tracing exporter", "err", err) + } + // NewExporter always returns a non-nil exporter and non-nil error. + tracerProvider, err = tracer.NewProvider(ctx, version, exporter) + if err != nil { + level.Error(logger).Log("msg", "failed to create tracing provider", "err", err) } - defer closer() } // Enable arrow ingestion @@ -208,6 +219,11 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags return err } + bridgeTracer, wrappedTracerProvider := tracer.Bridge(tracerProvider, tracerProvider.Tracer("objstore_bucket")) + // There is no way to pass the tracer to the object storage client, so we set it as global tracer. + opentracing.SetGlobalTracer(bridgeTracer) + tracerProvider = wrappedTracerProvider + bucket, err := client.NewBucket(logger, bucketCfg, reg, "parca") if err != nil { level.Error(logger).Log("msg", "failed to initialize object storage bucket", "err", err) @@ -317,7 +333,6 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags level.Error(logger).Log("msg", "schema from definition", "err", err) return err } - s := profilestore.NewProfileColumnStore( logger, tracerProvider.Tracer("profilestore"), @@ -326,7 +341,24 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags schema, flags.Hidden.DebugNormalizeAddresses, ) - conn, err := grpc.Dial(flags.ProfileShareServer, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) + + propagators := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}) + opts := []grpc.DialOption{ + grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), + grpc.WithChainUnaryInterceptor( + tracing.UnaryClientInterceptor( + tracing.WithTracerProvider(tracerProvider), + tracing.WithPropagators(propagators), + ), + ), + grpc.WithChainStreamInterceptor( + tracing.StreamClientInterceptor( + tracing.WithTracerProvider(tracerProvider), + tracing.WithPropagators(propagators), + ), + ), + } + conn, err := grpc.Dial(flags.ProfileShareServer, opts...) if err != nil { return fmt.Errorf("failed to create gRPC connection to ProfileShareServer: %s, %w", flags.ProfileShareServer, err) } @@ -417,6 +449,30 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags var gr run.Group gr.Add(run.SignalHandler(ctx, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)) + + // Run group of OTL exporter. + if exporter != nil { + logger := log.With(logger, "group", "otlp_exporter") + ctx, cancel := context.WithCancel(ctx) + gr.Add(func() error { + if err := exporter.Start(ctx); err != nil { + return fmt.Errorf("failed to start exporter: %w", err) + } + <-ctx.Done() + return nil + }, func(error) { + level.Debug(logger).Log("msg", "shutting down otlp exporter") + cancel() + + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + if err := exporter.Shutdown(ctx); err != nil { + level.Error(logger).Log("msg", "failed to stop exporter", "err", err) + } + }) + } + { s := symbolizer.New( logger, @@ -585,9 +641,22 @@ func runScraper( ) reg.MustRegister(metrics) + propagators := propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}) + opts := []grpc.DialOption{ - grpc.WithUnaryInterceptor( + grpc.WithChainUnaryInterceptor( metrics.UnaryClientInterceptor(), + tracing.UnaryClientInterceptor( + tracing.WithTracerProvider(tracer), + tracing.WithPropagators(propagators), + ), + ), + grpc.WithChainStreamInterceptor( + metrics.StreamClientInterceptor(), + tracing.StreamClientInterceptor( + tracing.WithTracerProvider(tracer), + tracing.WithPropagators(propagators), + ), ), } if flags.Insecure { @@ -762,45 +831,3 @@ func getDiscoveryConfigs(cfgs []*config.ScrapeConfig) map[string]discovery.Confi } return c } - -func initTracer(logger log.Logger, otlpAddress string) (trace.TracerProvider, func(), error) { - ctx := context.Background() - - res, err := resource.New(ctx, - resource.WithAttributes( - semconv.ServiceNameKey.String("parca"), - ), - ) - if err != nil { - return nil, nil, fmt.Errorf("failed to create resource: %w", err) - } - - // Set up a trace exporter - exporter, err := otlptracegrpc.New(ctx, - otlptracegrpc.WithInsecure(), - otlptracegrpc.WithEndpoint(otlpAddress), - ) - if err != nil { - return nil, nil, fmt.Errorf("failed to create trace exporter: %w", err) - } - - // Register the trace exporter with a TracerProvider, using a batch - // span processor to aggregate spans before export. - bsp := sdktrace.NewBatchSpanProcessor(exporter) - provider := sdktrace.NewTracerProvider( - sdktrace.WithSampler(sdktrace.AlwaysSample()), - sdktrace.WithResource(res), - sdktrace.WithSpanProcessor(bsp), - ) - - // set global propagator to tracecontext (the default is no-op). - otel.SetTextMapPropagator(propagation.TraceContext{}) - otel.SetTracerProvider(provider) - - return provider, func() { - err := exporter.Shutdown(context.Background()) - if err != nil { - level.Error(logger).Log("msg", "failed to stop exporter", "err", err) - } - }, nil -} diff --git a/pkg/tracer/tracer.go b/pkg/tracer/tracer.go new file mode 100644 index 00000000000..c510c2af632 --- /dev/null +++ b/pkg/tracer/tracer.go @@ -0,0 +1,188 @@ +// Copyright 2022-2023 The Parca Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +package tracer + +import ( + "context" + "fmt" + "io" + "os" + "strings" + + "github.com/opentracing/opentracing-go" + "go.opentelemetry.io/contrib/propagators/autoprop" + "go.opentelemetry.io/otel" + bridge "go.opentelemetry.io/otel/bridge/opentracing" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" + "go.opentelemetry.io/otel/propagation" + "go.opentelemetry.io/otel/sdk/resource" + sdktrace "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.20.0" + "go.opentelemetry.io/otel/trace" +) + +type ( + ExporterType string + SamplerType string +) + +const ( + ExporterTypeGRPC ExporterType = "grpc" + ExporterTypeHTTP ExporterType = "http" + ExporterTypeStdio ExporterType = "stdout" + + SamplerTypeAlways SamplerType = "always" + SamplerTypeNever SamplerType = "never" + SamplerTypeRatioBased SamplerType = "ratio_based" +) + +type NoopExporter struct{} + +func (n NoopExporter) ExportSpans(_ context.Context, _ []sdktrace.ReadOnlySpan) error { + return nil +} + +func (n NoopExporter) MarshalLog() interface{} { + return nil +} + +func (n NoopExporter) Shutdown(_ context.Context) error { + return nil +} + +func (n NoopExporter) Start(_ context.Context) error { + return nil +} + +func NewNoopExporter() *NoopExporter { + return &NoopExporter{} +} + +type Exporter interface { + sdktrace.SpanExporter + + Start(context.Context) error +} + +// NewProvider returns an OTLP exporter based tracer. +func NewProvider(ctx context.Context, version string, exporter sdktrace.SpanExporter, opts ...sdktrace.TracerProviderOption) (trace.TracerProvider, error) { + if exporter == nil { + return trace.NewNoopTracerProvider(), nil + } + + res, err := resources(ctx, version) + if err != nil { + return nil, fmt.Errorf("failed to create resource: %w", err) + } + + // Register the trace exporter with a TracerProvider, using a batch + // span processor to aggregate spans before export. + provider := sdktrace.NewTracerProvider( + // Sampler options: + // - sdktrace.NeverSample() + // - sdktrace.TraceIDRatioBased(0.01) + sdktrace.WithSampler(sdktrace.AlwaysSample()), + sdktrace.WithResource(res), + sdktrace.WithSpanProcessor(sdktrace.NewBatchSpanProcessor(exporter)), + ) + + // Set global propagator to tracecontext (the default is no-op). + otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) + otel.SetTracerProvider(provider) + + return provider, nil +} + +func NewExporter(exType, otlpAddress string) (Exporter, error) { + switch strings.ToLower(exType) { + case string(ExporterTypeGRPC): + return NewGRPCExporter(otlpAddress) + case string(ExporterTypeHTTP): + return NewHTTPExporter(otlpAddress) + case string(ExporterTypeStdio): + return NewConsoleExporter(os.Stdout) + default: + return NewNoopExporter(), fmt.Errorf("unknown exporter type: %s", exType) + } +} + +type consoleExporter struct { + *stdouttrace.Exporter +} + +func (c *consoleExporter) Start(_ context.Context) error { + return nil +} + +// NewConsoleExporter returns a console exporter. +func NewConsoleExporter(w io.Writer) (Exporter, error) { + exp, err := stdouttrace.New( + stdouttrace.WithWriter(w), + // Use human-readable output. + stdouttrace.WithPrettyPrint(), + // Do not print timestamps for the demo. + stdouttrace.WithoutTimestamps(), + ) + if err != nil { + return nil, err + } + return &consoleExporter{exp}, nil +} + +// NewGRPCExporter returns a gRPC exporter. +func NewGRPCExporter(otlpAddress string) (Exporter, error) { + return otlptracegrpc.NewUnstarted( + otlptracegrpc.WithInsecure(), + otlptracegrpc.WithEndpoint(otlpAddress), + ), nil +} + +// NewHTTPExporter returns a HTTP exporter. +func NewHTTPExporter(otlpAddress string) (Exporter, error) { + return otlptrace.NewUnstarted(otlptracehttp.NewClient( + otlptracehttp.WithInsecure(), + otlptracehttp.WithEndpoint(otlpAddress), + )), nil +} + +func resources(ctx context.Context, version string) (*resource.Resource, error) { + res, err := resource.New(ctx, + resource.WithAttributes( + semconv.ServiceNameKey.String("parca"), + semconv.ServiceVersionKey.String(version), + ), + resource.WithFromEnv(), // pull attributes from OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables + resource.WithProcess(), // This option configures a set of Detectors that discover process information + resource.WithOS(), // This option configures a set of Detectors that discover OS information + resource.WithContainer(), // This option configures a set of Detectors that discover container information + resource.WithHost(), // This option configures a set of Detectors that discover host information + ) + if err != nil { + return nil, fmt.Errorf("failed to create resource: %w", err) + } + return res, nil +} + +// Bridge is a bringe between OpenTelemetry and OpenTracing. +func Bridge(tp trace.TracerProvider, otelTracer trace.Tracer) (opentracing.Tracer, trace.TracerProvider) { + bridgeTracer, wrappedTracerProvider := bridge.NewTracerPair(otelTracer) + bridgeTracer.SetTextMapPropagator(autoprop.NewTextMapPropagator()) + return bridgeTracer, wrappedTracerProvider +} From bcc1257b4b45e3a19a413ef994f3db37d84c205b Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Thu, 6 Jul 2023 09:40:56 +0200 Subject: [PATCH 2/4] Add tracing bucket Signed-off-by: Kemal Akkoyun --- go.mod | 11 +- go.sum | 14 -- pkg/objectstore/bucket.go | 260 ++++++++++++++++++++++++++++++++++++++ pkg/parca/parca.go | 10 +- pkg/tracer/tracer.go | 11 -- 5 files changed, 264 insertions(+), 42 deletions(-) create mode 100644 pkg/objectstore/bucket.go diff --git a/go.mod b/go.mod index c05f2105947..c7dfc1f99a6 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,6 @@ require ( github.com/klauspost/compress v1.16.7 github.com/nanmu42/limitio v1.0.0 github.com/oklog/run v1.1.0 - github.com/opentracing/opentracing-go v1.2.0 github.com/polarsignals/frostdb v0.0.0-20230626160949-575a3f643680 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 @@ -38,9 +37,7 @@ require ( github.com/thanos-io/objstore v0.0.0-20230522103316-23ebe2eacadd go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 - go.opentelemetry.io/contrib/propagators/autoprop v0.42.0 go.opentelemetry.io/otel v1.16.0 - go.opentelemetry.io/otel/bridge/opentracing v1.16.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.16.0 @@ -58,6 +55,7 @@ require ( google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 gopkg.in/dnaeon/go-vcr.v3 v3.1.2 + gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -198,6 +196,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/oracle/oci-go-sdk/v65 v65.13.0 // indirect github.com/ovh/go-ovh v1.4.1 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect @@ -220,15 +219,10 @@ require ( github.com/zeebo/xxh3 v1.0.2 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/propagators/aws v1.17.0 // indirect - go.opentelemetry.io/contrib/propagators/b3 v1.17.0 // indirect - go.opentelemetry.io/contrib/propagators/jaeger v1.17.0 // indirect - go.opentelemetry.io/contrib/propagators/ot v1.17.0 // indirect go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/goleak v1.2.1 // indirect - go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/sys v0.10.0 // indirect @@ -242,7 +236,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gotest.tools/v3 v3.2.0 // indirect k8s.io/api v0.26.2 // indirect k8s.io/apimachinery v0.26.2 // indirect diff --git a/go.sum b/go.sum index b693d53eef9..af570c32caf 100644 --- a/go.sum +++ b/go.sum @@ -933,20 +933,8 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0/go.mod h1:5z+/ZWJQKXa9YT34fQNx5K8Hd1EoIhvtUygUQPqEOgQ= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 h1:0vzgiFDsCh/jxRCR1xcRrtMoeCu2itXz/PsXst5P8rI= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0/go.mod h1:y0vOY2OKFMOTvwxKfurStPayUUKGHlNeVqNneHmFXr0= -go.opentelemetry.io/contrib/propagators/autoprop v0.42.0 h1:s2RzYOAqHVgG23q8fPWYChobUoZM6rJZ98EnylJr66w= -go.opentelemetry.io/contrib/propagators/autoprop v0.42.0/go.mod h1:Mv/tWNtZn+NbALDb2XcItP0OM3lWWZjAfSroINxfW+Y= -go.opentelemetry.io/contrib/propagators/aws v1.17.0 h1:IX8d7l2uRw61BlmZBOTQFaK+y22j6vytMVTs9wFrO+c= -go.opentelemetry.io/contrib/propagators/aws v1.17.0/go.mod h1:pAlCYRWff4uGqRXOVn3WP8pDZ5E0K56bEoG7a1VSL4k= -go.opentelemetry.io/contrib/propagators/b3 v1.17.0 h1:ImOVvHnku8jijXqkwCSyYKRDt2YrnGXD4BbhcpfbfJo= -go.opentelemetry.io/contrib/propagators/b3 v1.17.0/go.mod h1:IkfUfMpKWmynvvE0264trz0sf32NRTZL4nuAN9AbWRc= -go.opentelemetry.io/contrib/propagators/jaeger v1.17.0 h1:Zbpbmwav32Ea5jSotpmkWEl3a6Xvd4tw/3xxGO1i05Y= -go.opentelemetry.io/contrib/propagators/jaeger v1.17.0/go.mod h1:tcTUAlmO8nuInPDSBVfG+CP6Mzjy5+gNV4mPxMbL0IA= -go.opentelemetry.io/contrib/propagators/ot v1.17.0 h1:ufo2Vsz8l76eI47jFjuVyjyB3Ae2DmfiCV/o6Vc8ii0= -go.opentelemetry.io/contrib/propagators/ot v1.17.0/go.mod h1:SbKPj5XGp8K/sGm05XblaIABgMgw2jDczP8gGeuaVLk= 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/bridge/opentracing v1.16.0 h1:Bgwi7P5NCV3bv2T13bwG0WfsxaT4SjQ1rDdmFc5P7do= -go.opentelemetry.io/otel/bridge/opentracing v1.16.0/go.mod h1:X2Y6v3RnoiBGtVFd4KoHy/ftHiCJKJXzlv6W2gPsN1Q= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0/go.mod h1:vLarbg68dH2Wa77g71zmKQqlQ8+8Rq3GRG31uc0WcWI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 h1:cbsD4cUcviQGXdw8+bo5x2wazq10SKz8hEbtCRPcU78= @@ -981,8 +969,6 @@ go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= diff --git a/pkg/objectstore/bucket.go b/pkg/objectstore/bucket.go new file mode 100644 index 00000000000..70e4c9cf2cd --- /dev/null +++ b/pkg/objectstore/bucket.go @@ -0,0 +1,260 @@ +// Copyright 2022-2023 The Parca Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +//nolint:nonamedreturn +package objectstore + +import ( + "context" + "fmt" + "io" + "strings" + + "github.com/go-kit/log" + "github.com/go-kit/log/level" + "github.com/prometheus/client_golang/prometheus" + "github.com/thanos-io/objstore" + "github.com/thanos-io/objstore/client" + "github.com/thanos-io/objstore/providers/azure" + "github.com/thanos-io/objstore/providers/bos" + "github.com/thanos-io/objstore/providers/cos" + "github.com/thanos-io/objstore/providers/filesystem" + "github.com/thanos-io/objstore/providers/gcs" + "github.com/thanos-io/objstore/providers/obs" + "github.com/thanos-io/objstore/providers/oci" + "github.com/thanos-io/objstore/providers/oss" + "github.com/thanos-io/objstore/providers/s3" + "github.com/thanos-io/objstore/providers/swift" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" + "gopkg.in/yaml.v2" +) + +func NewBucket(tracer trace.Tracer, logger log.Logger, confContentYaml []byte, reg prometheus.Registerer, component string) (objstore.InstrumentedBucket, error) { + level.Info(logger).Log("msg", "loading bucket configuration") + bucketConf := &client.BucketConfig{} + if err := yaml.UnmarshalStrict(confContentYaml, bucketConf); err != nil { + return nil, fmt.Errorf("parsing config YAML file: %w", err) + } + + config, err := yaml.Marshal(bucketConf.Config) + if err != nil { + return nil, fmt.Errorf("marshal content of bucket configuration: %w", err) + } + + var bucket objstore.Bucket + switch strings.ToUpper(string(bucketConf.Type)) { + case string(client.GCS): + bucket, err = gcs.NewBucket(context.Background(), logger, config, component) + case string(client.S3): + bucket, err = s3.NewBucket(logger, config, component) + case string(client.AZURE): + bucket, err = azure.NewBucket(logger, config, component) + case string(client.SWIFT): + bucket, err = swift.NewContainer(logger, config) + case string(client.COS): + bucket, err = cos.NewBucket(logger, config, component) + case string(client.ALIYUNOSS): + bucket, err = oss.NewBucket(logger, config, component) + case string(client.FILESYSTEM): + bucket, err = filesystem.NewBucketFromConfig(config) + case string(client.BOS): + bucket, err = bos.NewBucket(logger, config, component) + case string(client.OCI): + bucket, err = oci.NewBucket(logger, config) + case string(client.OBS): + bucket, err = obs.NewBucket(logger, config) + default: + return nil, fmt.Errorf("bucket with type %s is not supported", bucketConf.Type) + } + if err != nil { + return nil, fmt.Errorf("create %s client", bucketConf.Type) + } + + return NewTracingBucket(tracer, objstore.BucketWithMetrics(bucket.Name(), objstore.NewPrefixedBucket(bucket, bucketConf.Prefix), reg)), nil +} + +// TracingBucket is a wrapper around objstore.Bucket that adds tracing to all operations using OpenTelemetry. +type TracingBucket struct { + tracer trace.Tracer + bkt objstore.Bucket +} + +func NewTracingBucket(tracer trace.Tracer, bkt objstore.Bucket) objstore.InstrumentedBucket { + return TracingBucket{tracer: tracer, bkt: bkt} +} + +func (t TracingBucket) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) (err error) { + ctx, span := t.tracer.Start(ctx, "bucket_iter") + defer span.End() + span.SetAttributes(attribute.String("dir", dir)) + + defer func() { + if err != nil { + span.RecordError(err) + } + }() + return t.bkt.Iter(ctx, dir, f, options...) +} + +func (t TracingBucket) Get(ctx context.Context, name string) (io.ReadCloser, error) { + ctx, span := t.tracer.Start(ctx, "bucket_get") + defer span.End() + span.SetAttributes(attribute.String("name", name)) + + r, err := t.bkt.Get(ctx, name) + if err != nil { + span.RecordError(err) + return nil, err + } + + return newTracingReadCloser(r, span), nil +} + +func (t TracingBucket) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) { + ctx, span := t.tracer.Start(ctx, "bucket_getrange") + defer span.End() + span.SetAttributes(attribute.String("name", name), attribute.Int64("offset", off), attribute.Int64("length", length)) + + r, err := t.bkt.GetRange(ctx, name, off, length) + if err != nil { + span.RecordError(err) + return nil, err + } + + return newTracingReadCloser(r, span), nil +} + +func (t TracingBucket) Exists(ctx context.Context, name string) (_ bool, err error) { + ctx, span := t.tracer.Start(ctx, "bucket_exists") + defer span.End() + span.SetAttributes(attribute.String("name", name)) + + defer func() { + if err != nil { + span.RecordError(err) + } + }() + return t.bkt.Exists(ctx, name) +} + +func (t TracingBucket) Attributes(ctx context.Context, name string) (_ objstore.ObjectAttributes, err error) { + ctx, span := t.tracer.Start(ctx, "bucket_attributes") + defer span.End() + span.SetAttributes(attribute.String("name", name)) + + defer func() { + if err != nil { + span.RecordError(err) + } + }() + return t.bkt.Attributes(ctx, name) +} + +func (t TracingBucket) Upload(ctx context.Context, name string, r io.Reader) (err error) { + ctx, span := t.tracer.Start(ctx, "bucket_upload") + defer span.End() + span.SetAttributes(attribute.String("name", name)) + + defer func() { + if err != nil { + span.RecordError(err) + } + }() + return t.bkt.Upload(ctx, name, r) +} + +func (t TracingBucket) Delete(ctx context.Context, name string) (err error) { + ctx, span := t.tracer.Start(ctx, "bucket_delete") + defer span.End() + span.SetAttributes(attribute.String("name", name)) + + defer func() { + if err != nil { + span.RecordError(err) + } + }() + return t.bkt.Delete(ctx, name) +} + +func (t TracingBucket) Name() string { + return "tracing: " + t.bkt.Name() +} + +func (t TracingBucket) Close() error { + return t.bkt.Close() +} + +func (t TracingBucket) IsObjNotFoundErr(err error) bool { + return t.bkt.IsObjNotFoundErr(err) +} + +func (t TracingBucket) WithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.Bucket { + if ib, ok := t.bkt.(objstore.InstrumentedBucket); ok { + return TracingBucket{tracer: t.tracer, bkt: ib.WithExpectedErrs(expectedFunc)} + } + return t +} + +func (t TracingBucket) ReaderWithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.BucketReader { + return t.WithExpectedErrs(expectedFunc) +} + +type tracingReadCloser struct { + r io.ReadCloser + s trace.Span + + objSize int64 + objSizeErr error + + read int +} + +func newTracingReadCloser(r io.ReadCloser, span trace.Span) io.ReadCloser { + // Since TryToGetSize can only reliably return size before doing any read calls, + // we call during "construction" and remember the results. + objSize, objSizeErr := objstore.TryToGetSize(r) + + return &tracingReadCloser{r: r, s: span, objSize: objSize, objSizeErr: objSizeErr} +} + +func (t *tracingReadCloser) ObjectSize() (int64, error) { + return t.objSize, t.objSizeErr +} + +func (t *tracingReadCloser) Read(p []byte) (int, error) { + n, err := t.r.Read(p) + if n > 0 { + t.read += n + } + if err != nil && err != io.EOF && t.s != nil { + t.s.RecordError(err) + } + return n, err +} + +func (t *tracingReadCloser) Close() error { + err := t.r.Close() + if t.s != nil { + t.s.SetAttributes(attribute.Int64("read", int64(t.read))) + if err != nil { + t.s.SetAttributes(attribute.String("close_err", err.Error())) + } + t.s.End() + t.s = nil + } + return err +} diff --git a/pkg/parca/parca.go b/pkg/parca/parca.go index 5244125e523..a2075fff6eb 100644 --- a/pkg/parca/parca.go +++ b/pkg/parca/parca.go @@ -34,7 +34,6 @@ import ( grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/oklog/run" - "github.com/opentracing/opentracing-go" "github.com/polarsignals/frostdb" "github.com/polarsignals/frostdb/dynparquet" "github.com/polarsignals/frostdb/query" @@ -43,7 +42,6 @@ import ( "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/model/labels" "github.com/thanos-io/objstore" - "github.com/thanos-io/objstore/client" tracing "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" @@ -61,6 +59,7 @@ import ( "github.com/parca-dev/parca/pkg/config" "github.com/parca-dev/parca/pkg/debuginfo" "github.com/parca-dev/parca/pkg/metastore" + "github.com/parca-dev/parca/pkg/objectstore" "github.com/parca-dev/parca/pkg/parcacol" "github.com/parca-dev/parca/pkg/profilestore" queryservice "github.com/parca-dev/parca/pkg/query" @@ -219,12 +218,7 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags return err } - bridgeTracer, wrappedTracerProvider := tracer.Bridge(tracerProvider, tracerProvider.Tracer("objstore_bucket")) - // There is no way to pass the tracer to the object storage client, so we set it as global tracer. - opentracing.SetGlobalTracer(bridgeTracer) - tracerProvider = wrappedTracerProvider - - bucket, err := client.NewBucket(logger, bucketCfg, reg, "parca") + bucket, err := objectstore.NewBucket(tracerProvider.Tracer("objstore_bucket"), logger, bucketCfg, reg, "parca") if err != nil { level.Error(logger).Log("msg", "failed to initialize object storage bucket", "err", err) return err diff --git a/pkg/tracer/tracer.go b/pkg/tracer/tracer.go index c510c2af632..c3461f3bddc 100644 --- a/pkg/tracer/tracer.go +++ b/pkg/tracer/tracer.go @@ -23,10 +23,7 @@ import ( "os" "strings" - "github.com/opentracing/opentracing-go" - "go.opentelemetry.io/contrib/propagators/autoprop" "go.opentelemetry.io/otel" - bridge "go.opentelemetry.io/otel/bridge/opentracing" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" @@ -102,7 +99,6 @@ func NewProvider(ctx context.Context, version string, exporter sdktrace.SpanExpo sdktrace.WithResource(res), sdktrace.WithSpanProcessor(sdktrace.NewBatchSpanProcessor(exporter)), ) - // Set global propagator to tracecontext (the default is no-op). otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) otel.SetTracerProvider(provider) @@ -179,10 +175,3 @@ func resources(ctx context.Context, version string) (*resource.Resource, error) } return res, nil } - -// Bridge is a bringe between OpenTelemetry and OpenTracing. -func Bridge(tp trace.TracerProvider, otelTracer trace.Tracer) (opentracing.Tracer, trace.TracerProvider) { - bridgeTracer, wrappedTracerProvider := bridge.NewTracerPair(otelTracer) - bridgeTracer.SetTextMapPropagator(autoprop.NewTextMapPropagator()) - return bridgeTracer, wrappedTracerProvider -} From 26130d6d5488492fd56fd15e23c3f7c5a5c53906 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Thu, 6 Jul 2023 14:16:39 +0200 Subject: [PATCH 3/4] Upgrade objstore Signed-off-by: Kemal Akkoyun --- go.mod | 7 +- go.sum | 9 +- pkg/debuginfo/metadata_test.go | 3 +- pkg/objectstore/bucket.go | 260 ------------------------------ pkg/parca/parca.go | 7 +- pkg/symbolizer/symbolizer_test.go | 2 +- 6 files changed, 14 insertions(+), 274 deletions(-) delete mode 100644 pkg/objectstore/bucket.go diff --git a/go.mod b/go.mod index c7dfc1f99a6..9d8f19ed179 100644 --- a/go.mod +++ b/go.mod @@ -28,13 +28,13 @@ require ( github.com/klauspost/compress v1.16.7 github.com/nanmu42/limitio v1.0.0 github.com/oklog/run v1.1.0 - github.com/polarsignals/frostdb v0.0.0-20230626160949-575a3f643680 + github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 github.com/prometheus/prometheus v0.45.0 github.com/segmentio/parquet-go v0.0.0-20230622230624-510764ae9e80 github.com/stretchr/testify v1.8.4 - github.com/thanos-io/objstore v0.0.0-20230522103316-23ebe2eacadd + github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 go.opentelemetry.io/otel v1.16.0 @@ -55,7 +55,6 @@ require ( google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 gopkg.in/dnaeon/go-vcr.v3 v3.1.2 - gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -196,7 +195,6 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/oracle/oci-go-sdk/v65 v65.13.0 // indirect github.com/ovh/go-ovh v1.4.1 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect @@ -236,6 +234,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gotest.tools/v3 v3.2.0 // indirect k8s.io/api v0.26.2 // indirect k8s.io/apimachinery v0.26.2 // indirect diff --git a/go.sum b/go.sum index af570c32caf..bbed6c622ec 100644 --- a/go.sum +++ b/go.sum @@ -733,7 +733,6 @@ github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKw github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= @@ -764,8 +763,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarsignals/frostdb v0.0.0-20230626160949-575a3f643680 h1:Z7pITXeG2iHHCeLaLFWpkyd2VE4f9FqktY+lUVgwvEk= -github.com/polarsignals/frostdb v0.0.0-20230626160949-575a3f643680/go.mod h1:k0z+Ox9NB3+1vozRALvIX1So/4DPFJ8J1VbITQfIpZM= +github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2 h1:wk490COZdp84iRUivWERzziHWUpcSxocWmxPxP2hAYI= +github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2/go.mod h1:+98odC+kowAidfNj6nWKILyry/D2cYThaquvfuadlYQ= github.com/polarsignals/wal v0.0.0-20230509073041-6731e243de20 h1:YverywcwPHYj5iQq1/Zy/EihWVyw2F0S7j52FvGWK4w= github.com/polarsignals/wal v0.0.0-20230509073041-6731e243de20/go.mod h1:EVDHAAe+7GQ33A1/x+/gE+sBPN4toQ0XG5RoLD49xr8= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -889,8 +888,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4= github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4O8IB2ozzxM= github.com/tencentyun/cos-go-sdk-v5 v0.7.40/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw= -github.com/thanos-io/objstore v0.0.0-20230522103316-23ebe2eacadd h1:asQ0HomkaUXZuR3J7daBEusMS++3hkYsYM6u8gpmPWM= -github.com/thanos-io/objstore v0.0.0-20230522103316-23ebe2eacadd/go.mod h1:5V7lzXuaxwt6XFQoA/zJrhdnQrxq1+r0bwQ1iYOq3gM= +github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33 h1:qasMv1FKHDhdYiF3M2RLCcrOyMXxqkDNdtsZG9ii6ZE= +github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33/go.mod h1:Vc+D0zxX8fT7VOe8Gj0J6vzw0kcTrMCEgE140wCz1c0= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= diff --git a/pkg/debuginfo/metadata_test.go b/pkg/debuginfo/metadata_test.go index 964983f436b..5b5f9c2ce8d 100644 --- a/pkg/debuginfo/metadata_test.go +++ b/pkg/debuginfo/metadata_test.go @@ -20,7 +20,6 @@ import ( "time" "github.com/go-kit/log" - "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" "github.com/thanos-io/objstore/client" "github.com/thanos-io/objstore/providers/filesystem" @@ -52,7 +51,7 @@ func TestMetadata(t *testing.T) { }) require.NoError(t, err) - bucket, err := client.NewBucket(logger, cfg, prometheus.NewRegistry(), "parca/store") + bucket, err := client.NewBucket(logger, cfg, "parca/store") require.NoError(t, err) store, err := NewStore( diff --git a/pkg/objectstore/bucket.go b/pkg/objectstore/bucket.go deleted file mode 100644 index 70e4c9cf2cd..00000000000 --- a/pkg/objectstore/bucket.go +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2022-2023 The Parca Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Copyright (c) The Thanos Authors. -// Licensed under the Apache License 2.0. - -//nolint:nonamedreturn -package objectstore - -import ( - "context" - "fmt" - "io" - "strings" - - "github.com/go-kit/log" - "github.com/go-kit/log/level" - "github.com/prometheus/client_golang/prometheus" - "github.com/thanos-io/objstore" - "github.com/thanos-io/objstore/client" - "github.com/thanos-io/objstore/providers/azure" - "github.com/thanos-io/objstore/providers/bos" - "github.com/thanos-io/objstore/providers/cos" - "github.com/thanos-io/objstore/providers/filesystem" - "github.com/thanos-io/objstore/providers/gcs" - "github.com/thanos-io/objstore/providers/obs" - "github.com/thanos-io/objstore/providers/oci" - "github.com/thanos-io/objstore/providers/oss" - "github.com/thanos-io/objstore/providers/s3" - "github.com/thanos-io/objstore/providers/swift" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/trace" - "gopkg.in/yaml.v2" -) - -func NewBucket(tracer trace.Tracer, logger log.Logger, confContentYaml []byte, reg prometheus.Registerer, component string) (objstore.InstrumentedBucket, error) { - level.Info(logger).Log("msg", "loading bucket configuration") - bucketConf := &client.BucketConfig{} - if err := yaml.UnmarshalStrict(confContentYaml, bucketConf); err != nil { - return nil, fmt.Errorf("parsing config YAML file: %w", err) - } - - config, err := yaml.Marshal(bucketConf.Config) - if err != nil { - return nil, fmt.Errorf("marshal content of bucket configuration: %w", err) - } - - var bucket objstore.Bucket - switch strings.ToUpper(string(bucketConf.Type)) { - case string(client.GCS): - bucket, err = gcs.NewBucket(context.Background(), logger, config, component) - case string(client.S3): - bucket, err = s3.NewBucket(logger, config, component) - case string(client.AZURE): - bucket, err = azure.NewBucket(logger, config, component) - case string(client.SWIFT): - bucket, err = swift.NewContainer(logger, config) - case string(client.COS): - bucket, err = cos.NewBucket(logger, config, component) - case string(client.ALIYUNOSS): - bucket, err = oss.NewBucket(logger, config, component) - case string(client.FILESYSTEM): - bucket, err = filesystem.NewBucketFromConfig(config) - case string(client.BOS): - bucket, err = bos.NewBucket(logger, config, component) - case string(client.OCI): - bucket, err = oci.NewBucket(logger, config) - case string(client.OBS): - bucket, err = obs.NewBucket(logger, config) - default: - return nil, fmt.Errorf("bucket with type %s is not supported", bucketConf.Type) - } - if err != nil { - return nil, fmt.Errorf("create %s client", bucketConf.Type) - } - - return NewTracingBucket(tracer, objstore.BucketWithMetrics(bucket.Name(), objstore.NewPrefixedBucket(bucket, bucketConf.Prefix), reg)), nil -} - -// TracingBucket is a wrapper around objstore.Bucket that adds tracing to all operations using OpenTelemetry. -type TracingBucket struct { - tracer trace.Tracer - bkt objstore.Bucket -} - -func NewTracingBucket(tracer trace.Tracer, bkt objstore.Bucket) objstore.InstrumentedBucket { - return TracingBucket{tracer: tracer, bkt: bkt} -} - -func (t TracingBucket) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) (err error) { - ctx, span := t.tracer.Start(ctx, "bucket_iter") - defer span.End() - span.SetAttributes(attribute.String("dir", dir)) - - defer func() { - if err != nil { - span.RecordError(err) - } - }() - return t.bkt.Iter(ctx, dir, f, options...) -} - -func (t TracingBucket) Get(ctx context.Context, name string) (io.ReadCloser, error) { - ctx, span := t.tracer.Start(ctx, "bucket_get") - defer span.End() - span.SetAttributes(attribute.String("name", name)) - - r, err := t.bkt.Get(ctx, name) - if err != nil { - span.RecordError(err) - return nil, err - } - - return newTracingReadCloser(r, span), nil -} - -func (t TracingBucket) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) { - ctx, span := t.tracer.Start(ctx, "bucket_getrange") - defer span.End() - span.SetAttributes(attribute.String("name", name), attribute.Int64("offset", off), attribute.Int64("length", length)) - - r, err := t.bkt.GetRange(ctx, name, off, length) - if err != nil { - span.RecordError(err) - return nil, err - } - - return newTracingReadCloser(r, span), nil -} - -func (t TracingBucket) Exists(ctx context.Context, name string) (_ bool, err error) { - ctx, span := t.tracer.Start(ctx, "bucket_exists") - defer span.End() - span.SetAttributes(attribute.String("name", name)) - - defer func() { - if err != nil { - span.RecordError(err) - } - }() - return t.bkt.Exists(ctx, name) -} - -func (t TracingBucket) Attributes(ctx context.Context, name string) (_ objstore.ObjectAttributes, err error) { - ctx, span := t.tracer.Start(ctx, "bucket_attributes") - defer span.End() - span.SetAttributes(attribute.String("name", name)) - - defer func() { - if err != nil { - span.RecordError(err) - } - }() - return t.bkt.Attributes(ctx, name) -} - -func (t TracingBucket) Upload(ctx context.Context, name string, r io.Reader) (err error) { - ctx, span := t.tracer.Start(ctx, "bucket_upload") - defer span.End() - span.SetAttributes(attribute.String("name", name)) - - defer func() { - if err != nil { - span.RecordError(err) - } - }() - return t.bkt.Upload(ctx, name, r) -} - -func (t TracingBucket) Delete(ctx context.Context, name string) (err error) { - ctx, span := t.tracer.Start(ctx, "bucket_delete") - defer span.End() - span.SetAttributes(attribute.String("name", name)) - - defer func() { - if err != nil { - span.RecordError(err) - } - }() - return t.bkt.Delete(ctx, name) -} - -func (t TracingBucket) Name() string { - return "tracing: " + t.bkt.Name() -} - -func (t TracingBucket) Close() error { - return t.bkt.Close() -} - -func (t TracingBucket) IsObjNotFoundErr(err error) bool { - return t.bkt.IsObjNotFoundErr(err) -} - -func (t TracingBucket) WithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.Bucket { - if ib, ok := t.bkt.(objstore.InstrumentedBucket); ok { - return TracingBucket{tracer: t.tracer, bkt: ib.WithExpectedErrs(expectedFunc)} - } - return t -} - -func (t TracingBucket) ReaderWithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.BucketReader { - return t.WithExpectedErrs(expectedFunc) -} - -type tracingReadCloser struct { - r io.ReadCloser - s trace.Span - - objSize int64 - objSizeErr error - - read int -} - -func newTracingReadCloser(r io.ReadCloser, span trace.Span) io.ReadCloser { - // Since TryToGetSize can only reliably return size before doing any read calls, - // we call during "construction" and remember the results. - objSize, objSizeErr := objstore.TryToGetSize(r) - - return &tracingReadCloser{r: r, s: span, objSize: objSize, objSizeErr: objSizeErr} -} - -func (t *tracingReadCloser) ObjectSize() (int64, error) { - return t.objSize, t.objSizeErr -} - -func (t *tracingReadCloser) Read(p []byte) (int, error) { - n, err := t.r.Read(p) - if n > 0 { - t.read += n - } - if err != nil && err != io.EOF && t.s != nil { - t.s.RecordError(err) - } - return n, err -} - -func (t *tracingReadCloser) Close() error { - err := t.r.Close() - if t.s != nil { - t.s.SetAttributes(attribute.Int64("read", int64(t.read))) - if err != nil { - t.s.SetAttributes(attribute.String("close_err", err.Error())) - } - t.s.End() - t.s = nil - } - return err -} diff --git a/pkg/parca/parca.go b/pkg/parca/parca.go index a2075fff6eb..a4ba23077b2 100644 --- a/pkg/parca/parca.go +++ b/pkg/parca/parca.go @@ -42,6 +42,8 @@ import ( "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/model/labels" "github.com/thanos-io/objstore" + "github.com/thanos-io/objstore/client" + objstoretracing "github.com/thanos-io/objstore/tracing/opentelemetry" tracing "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" @@ -59,7 +61,6 @@ import ( "github.com/parca-dev/parca/pkg/config" "github.com/parca-dev/parca/pkg/debuginfo" "github.com/parca-dev/parca/pkg/metastore" - "github.com/parca-dev/parca/pkg/objectstore" "github.com/parca-dev/parca/pkg/parcacol" "github.com/parca-dev/parca/pkg/profilestore" queryservice "github.com/parca-dev/parca/pkg/query" @@ -218,11 +219,13 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags return err } - bucket, err := objectstore.NewBucket(tracerProvider.Tracer("objstore_bucket"), logger, bucketCfg, reg, "parca") + bucket, err := client.NewBucket(logger, bucketCfg, "parca") if err != nil { level.Error(logger).Log("msg", "failed to initialize object storage bucket", "err", err) return err } + bucket = client.NewInstrumentedBucket(reg, bucket) + bucket = objstoretracing.NewTracingBucket(tracerProvider.Tracer("objstore_bucket"), bucket) var signedRequestsClient signedrequests.Client if flags.Debuginfo.UploadsSignedURL { diff --git a/pkg/symbolizer/symbolizer_test.go b/pkg/symbolizer/symbolizer_test.go index f69d767fda6..1b1c2d12d5b 100644 --- a/pkg/symbolizer/symbolizer_test.go +++ b/pkg/symbolizer/symbolizer_test.go @@ -441,7 +441,7 @@ func setup(t *testing.T) (*grpc.ClientConn, pb.MetastoreServiceClient, *Symboliz }) require.NoError(t, err) - bucket, err := client.NewBucket(logger, cfg, prometheus.NewRegistry(), "parca/store") + bucket, err := client.NewBucket(logger, cfg, "parca/store") require.NoError(t, err) metadata := debuginfo.NewObjectStoreMetadata(logger, bucket) From 93fd023119c5909d91d7c646b25ae462aa333c93 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Thu, 13 Jul 2023 15:57:25 +0200 Subject: [PATCH 4/4] Upgrade to latest APIs Signed-off-by: Kemal Akkoyun --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- pkg/parca/parca.go | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 9d8f19ed179..c375828d9fe 100644 --- a/go.mod +++ b/go.mod @@ -28,13 +28,13 @@ require ( github.com/klauspost/compress v1.16.7 github.com/nanmu42/limitio v1.0.0 github.com/oklog/run v1.1.0 - github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2 + github.com/polarsignals/frostdb v0.0.0-20230713135300-a7f96ef74c0e github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 github.com/prometheus/prometheus v0.45.0 github.com/segmentio/parquet-go v0.0.0-20230622230624-510764ae9e80 github.com/stretchr/testify v1.8.4 - github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33 + github.com/thanos-io/objstore v0.0.0-20230713070940-eb01c83b89a4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.42.0 go.opentelemetry.io/otel v1.16.0 @@ -115,7 +115,7 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/efficientgo/core v1.0.0-rc.0.0.20221201130417-ba593f67d2a4 // indirect + github.com/efficientgo/core v1.0.0-rc.2 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/envoyproxy/go-control-plane v0.11.1-0.20230524094728-9239064ad72f // indirect github.com/envoyproxy/protoc-gen-validate v1.0.1 // indirect @@ -203,7 +203,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polarsignals/wal v0.0.0-20230509073041-6731e243de20 // indirect github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect + github.com/prometheus/procfs v0.11.0 // indirect github.com/rivo/uniseg v0.3.4 // indirect github.com/rs/cors v1.8.0 // indirect github.com/rs/xid v1.4.0 // indirect diff --git a/go.sum b/go.sum index bbed6c622ec..b498379df3e 100644 --- a/go.sum +++ b/go.sum @@ -252,8 +252,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/efficientgo/core v1.0.0-rc.0.0.20221201130417-ba593f67d2a4 h1:rydBwnBoywKQMjWF0z8SriYtQ+uUcaFsxuijMjJr5PI= -github.com/efficientgo/core v1.0.0-rc.0.0.20221201130417-ba593f67d2a4/go.mod h1:kQa0V74HNYMfuJH6jiPiwNdpWXl4xd/K4tzlrcvYDQI= +github.com/efficientgo/core v1.0.0-rc.2 h1:7j62qHLnrZqO3V3UA0AqOGd5d5aXV3AX6m/NZBHp78I= +github.com/efficientgo/core v1.0.0-rc.2/go.mod h1:FfGdkzWarkuzOlY04VY+bGfb1lWrjaL6x/GLcQ4vJps= github.com/efficientgo/e2e v0.13.1-0.20220922081603-45de9fc588a8 h1:UFLc39BcUXahSNCLUrKjNGZABMUZaS4M74EZvTRnq3k= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= @@ -763,8 +763,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2 h1:wk490COZdp84iRUivWERzziHWUpcSxocWmxPxP2hAYI= -github.com/polarsignals/frostdb v0.0.0-20230706122805-ab6f1543ccd2/go.mod h1:+98odC+kowAidfNj6nWKILyry/D2cYThaquvfuadlYQ= +github.com/polarsignals/frostdb v0.0.0-20230713135300-a7f96ef74c0e h1:JjUHkY4TOMEPn1M2YfBtQJYnnniAcuMwx+CFGA7aJVA= +github.com/polarsignals/frostdb v0.0.0-20230713135300-a7f96ef74c0e/go.mod h1:skEfKtwq5jcJmClheFeyJijV5T9WddUnXKzYKtmShuM= github.com/polarsignals/wal v0.0.0-20230509073041-6731e243de20 h1:YverywcwPHYj5iQq1/Zy/EihWVyw2F0S7j52FvGWK4w= github.com/polarsignals/wal v0.0.0-20230509073041-6731e243de20/go.mod h1:EVDHAAe+7GQ33A1/x+/gE+sBPN4toQ0XG5RoLD49xr8= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -805,8 +805,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -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/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/prometheus v0.45.0 h1:O/uG+Nw4kNxx/jDPxmjsSDd+9Ohql6E7ZSY1x5x/0KI= github.com/prometheus/prometheus v0.45.0/go.mod h1:jC5hyO8ItJBnDWGecbEucMyXjzxGv9cxsxsjS9u5s1w= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -888,8 +888,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4= github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4O8IB2ozzxM= github.com/tencentyun/cos-go-sdk-v5 v0.7.40/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw= -github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33 h1:qasMv1FKHDhdYiF3M2RLCcrOyMXxqkDNdtsZG9ii6ZE= -github.com/thanos-io/objstore v0.0.0-20230706112411-e16e78ffbf33/go.mod h1:Vc+D0zxX8fT7VOe8Gj0J6vzw0kcTrMCEgE140wCz1c0= +github.com/thanos-io/objstore v0.0.0-20230713070940-eb01c83b89a4 h1:SYs56N3zGaE8wwkU+QAfqeAC9SMjGWQORzrYSs58NAQ= +github.com/thanos-io/objstore v0.0.0-20230713070940-eb01c83b89a4/go.mod h1:Vc+D0zxX8fT7VOe8Gj0J6vzw0kcTrMCEgE140wCz1c0= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= diff --git a/pkg/parca/parca.go b/pkg/parca/parca.go index a4ba23077b2..57bd699b349 100644 --- a/pkg/parca/parca.go +++ b/pkg/parca/parca.go @@ -224,8 +224,8 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags level.Error(logger).Log("msg", "failed to initialize object storage bucket", "err", err) return err } - bucket = client.NewInstrumentedBucket(reg, bucket) - bucket = objstoretracing.NewTracingBucket(tracerProvider.Tracer("objstore_bucket"), bucket) + bucket = objstore.WrapWithMetrics(bucket, reg, bucket.Name()) + bucket = objstoretracing.WrapWithTraces(bucket, tracerProvider.Tracer("objstore_bucket")) var signedRequestsClient signedrequests.Client if flags.Debuginfo.UploadsSignedURL {