From 417f10e01515694907bfbe129f7206bb75fe60f1 Mon Sep 17 00:00:00 2001 From: Femi Novia Lina <77434812+FemiNoviaLina@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:00:06 +0700 Subject: [PATCH] feat: enable opentelemetry for worker (#108) --- cli/worker.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/worker.go b/cli/worker.go index 57fb9c7..7c79114 100644 --- a/cli/worker.go +++ b/cli/worker.go @@ -8,7 +8,10 @@ import ( "github.com/goto/entropy/core" "github.com/goto/entropy/core/module" "github.com/goto/entropy/pkg/logger" + "github.com/goto/entropy/pkg/telemetry" + "github.com/newrelic/go-agent/v3/newrelic" "github.com/spf13/cobra" + "go.uber.org/zap" "golang.org/x/sync/errgroup" ) @@ -35,7 +38,18 @@ func cmdWorker() *cobra.Command { return err } - return StartWorkers(cmd.Context(), cfg) + ctx := cmd.Context() + + telemetry.Init(ctx, cfg.Telemetry) + _, err = newrelic.NewApplication( + newrelic.ConfigAppName(cfg.Telemetry.ServiceName), + newrelic.ConfigLicense(cfg.Telemetry.NewRelicAPIKey), + ) + if err != nil { + zap.L().Error("error initializing opentelemetry", zap.Error(err)) + } + + return StartWorkers(ctx, cfg) }) return cmd