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

debuginfo: Add traces #3396

Merged
merged 5 commits into from
Jul 14, 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ 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-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-20230522103316-23ebe2eacadd
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
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
Expand Down Expand Up @@ -112,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
Expand Down Expand Up @@ -192,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
Expand All @@ -201,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
Expand All @@ -216,7 +218,6 @@ require (
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.24.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
Expand Down
21 changes: 12 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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-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=
Expand Down Expand Up @@ -806,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=
Expand Down Expand Up @@ -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-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=
Expand Down Expand Up @@ -941,6 +940,10 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 h1:cbsD4cUcviQGXdw8+bo
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=
Expand Down
3 changes: 1 addition & 2 deletions pkg/debuginfo/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
142 changes: 83 additions & 59 deletions pkg/parca/parca.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ 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"
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/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"
Expand All @@ -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 (
Expand All @@ -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"`

Expand Down Expand Up @@ -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."`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -208,11 +219,13 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags
return err
}

bucket, err := client.NewBucket(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 = objstore.WrapWithMetrics(bucket, reg, bucket.Name())
bucket = objstoretracing.WrapWithTraces(bucket, tracerProvider.Tracer("objstore_bucket"))

var signedRequestsClient signedrequests.Client
if flags.Debuginfo.UploadsSignedURL {
Expand Down Expand Up @@ -317,7 +330,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"),
Expand All @@ -326,7 +338,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)
}
Expand Down Expand Up @@ -417,6 +446,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,
Expand Down Expand Up @@ -585,9 +638,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 {
Expand Down Expand Up @@ -762,45 +828,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
}
2 changes: 1 addition & 1 deletion pkg/symbolizer/symbolizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading