diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 5799cba..f969d77 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -7,7 +7,6 @@ import ( "github.com/airbytehq/abctl/internal/cmd/local" "github.com/airbytehq/abctl/internal/cmd/local/k8s" "github.com/airbytehq/abctl/internal/cmd/version" - "github.com/airbytehq/abctl/internal/telemetry" "github.com/alecthomas/kong" "github.com/pterm/pterm" ) @@ -28,6 +27,5 @@ type Cmd struct { func (c *Cmd) BeforeApply(ctx context.Context, kCtx *kong.Context) error { kCtx.BindTo(k8s.DefaultProvider, (*k8s.Provider)(nil)) - kCtx.BindTo(telemetry.Get(), (*telemetry.Client)(nil)) return nil } diff --git a/internal/cmd/local/local/install_test.go b/internal/cmd/local/local/install_test.go index 26353e8..4f005e2 100644 --- a/internal/cmd/local/local/install_test.go +++ b/internal/cmd/local/local/install_test.go @@ -164,7 +164,7 @@ func TestCommand_Install(t *testing.T) { } installOpts := &InstallOpts{ - HelmValuesYaml: valuesYaml, + HelmValuesYaml: valuesYaml, AirbyteChartLoc: testAirbyteChartLoc, } if err := c.Install(context.Background(), installOpts); err != nil { diff --git a/internal/trace/trace.go b/internal/trace/trace.go index 5f73045..491cbcf 100644 --- a/internal/trace/trace.go +++ b/internal/trace/trace.go @@ -77,7 +77,7 @@ func CaptureError(ctx context.Context, err error) error { type Shutdown func() // Init initializes the otel framework. -func Init(ctx context.Context) ([]Shutdown, error) { +func Init(ctx context.Context, userId string) ([]Shutdown, error) { dsn := "https://9e0748223d5bc43e873f811a849e982e@o1009025.ingest.us.sentry.io/4507177762357248" // TODO: combine telemetry and trace packages? if telemetry.DNT() { @@ -112,6 +112,10 @@ func Init(ctx context.Context) ([]Shutdown, error) { ), ) + sentry.ConfigureScope(func(scope *sentry.Scope) { + scope.SetUser(sentry.User{ID: userId}) + }) + tracerProvider := sdktrace.NewTracerProvider( sdktrace.WithSpanProcessor(sentryotel.NewSentrySpanProcessor()), sdktrace.WithResource(r), diff --git a/main.go b/main.go index 1d45c06..0e1b506 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/airbytehq/abctl/internal/build" "github.com/airbytehq/abctl/internal/cmd" "github.com/airbytehq/abctl/internal/cmd/local/localerr" + "github.com/airbytehq/abctl/internal/telemetry" "github.com/airbytehq/abctl/internal/trace" "github.com/airbytehq/abctl/internal/update" "github.com/alecthomas/kong" @@ -31,12 +32,12 @@ func run() int { defer stop() printUpdateMsg := checkForNewerAbctlVersion(ctx) - shutdowns, err := trace.Init(ctx) + telClient := telemetry.Get() + + shutdowns, err := trace.Init(ctx, telClient.User()) if err != nil { pterm.Debug.Printf(fmt.Sprintf("Trace disabled: %s", err)) } - //ctx, span := trace.NewSpan(ctx, "run") - //defer span.End() defer func() { for _, shutdown := range shutdowns { shutdown() @@ -51,6 +52,7 @@ func run() int { kong.Description("Airbyte's command line tool for managing a local Airbyte installation."), kong.UsageOnError(), kong.BindToProvider(bindCtx(ctx)), + kong.BindTo(telClient, (*telemetry.Client)(nil)), ) if err != nil { return err