Skip to content

Commit cf9887c

Browse files
committed
added tracing
1 parent 0b9a3a0 commit cf9887c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

server/application/application.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/argoproj/gitops-engine/pkg/health"
16+
"go.opentelemetry.io/otel"
1617

1718
cacheutil "github.com/argoproj/argo-cd/v3/util/cache"
1819

@@ -412,6 +413,9 @@ func (s *Server) queryRepoServer(ctx context.Context, proj *v1alpha1.AppProject,
412413
enabledSourceTypes map[string]bool,
413414
) error,
414415
) error {
416+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "queryRepoServer")
417+
defer span.End()
418+
415419
closer, client, err := s.repoClientset.NewRepoServerClient()
416420
if err != nil {
417421
return fmt.Errorf("error creating repo server client: %w", err)
@@ -448,6 +452,9 @@ func (s *Server) queryRepoServer(ctx context.Context, proj *v1alpha1.AppProject,
448452

449453
// GetManifests returns application manifests
450454
func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationManifestQuery) (*apiclient.ManifestResponse, error) {
455+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "Server.GetManifests")
456+
defer span.End()
457+
451458
if q.Name == nil || *q.Name == "" {
452459
return nil, errors.New("invalid request: application name is missing")
453460
}
@@ -485,7 +492,9 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan
485492
}
486493
serverVersion := ci.ServerVersion
487494

495+
_, kubectlSpan := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "kubectl.GetAPIResources")
488496
apiResources, err := s.kubectl.GetAPIResources(config, false, kubecache.NewNoopSettings())
497+
kubectlSpan.End()
489498
if err != nil {
490499
return fmt.Errorf("error getting API resources: %w", err)
491500
}
@@ -1364,6 +1373,9 @@ func (s *Server) getCachedAppState(ctx context.Context, a *v1alpha1.Application,
13641373
}
13651374

13661375
func (s *Server) getAppResources(ctx context.Context, a *v1alpha1.Application) (*v1alpha1.ApplicationTree, error) {
1376+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "Server.getAppResources")
1377+
defer span.End()
1378+
13671379
var tree v1alpha1.ApplicationTree
13681380
err := s.getCachedAppState(ctx, a, func() error {
13691381
return s.cache.GetAppResourcesTree(a.InstanceName(s.ns), &tree)
@@ -1378,6 +1390,9 @@ func (s *Server) getAppResources(ctx context.Context, a *v1alpha1.Application) (
13781390
}
13791391

13801392
func (s *Server) getAppLiveResource(ctx context.Context, action string, q *application.ApplicationResourceRequest) (*v1alpha1.ResourceNode, *rest.Config, *v1alpha1.Application, error) {
1393+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "Server.getAppLiveResource")
1394+
defer span.End()
1395+
13811396
fineGrainedInheritanceDisabled, err := s.settingsMgr.ApplicationFineGrainedRBACInheritanceDisabled()
13821397
if err != nil {
13831398
return nil, nil, nil, err
@@ -1412,6 +1427,9 @@ func (s *Server) getAppLiveResource(ctx context.Context, action string, q *appli
14121427
}
14131428

14141429
func (s *Server) GetResource(ctx context.Context, q *application.ApplicationResourceRequest) (*application.ApplicationResourceResponse, error) {
1430+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "Server.GetResource")
1431+
defer span.End()
1432+
14151433
res, config, _, err := s.getAppLiveResource(ctx, rbac.ActionGet, q)
14161434
if err != nil {
14171435
return nil, err
@@ -1421,7 +1439,10 @@ func (s *Server) GetResource(ctx context.Context, q *application.ApplicationReso
14211439
if q.GetVersion() != "" {
14221440
res.Version = q.GetVersion()
14231441
}
1442+
1443+
_, kubectlSpan := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "kbuectl.GetResource")
14241444
obj, err := s.kubectl.GetResource(ctx, config, res.GroupKindVersion(), res.Name, res.Namespace)
1445+
kubectlSpan.End()
14251446
if err != nil {
14261447
return nil, fmt.Errorf("error getting resource: %w", err)
14271448
}

util/argo/argo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/argoproj/gitops-engine/pkg/utils/kube"
1616
"github.com/r3labs/diff/v3"
1717
log "github.com/sirupsen/logrus"
18+
"go.opentelemetry.io/otel"
1819
"google.golang.org/grpc/codes"
1920
"google.golang.org/grpc/status"
2021
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -457,6 +458,9 @@ func validateRepo(ctx context.Context,
457458
// This function also validates the references use allowed characters and does not define the same ref key more than
458459
// once (which would lead to ambiguous references).
459460
func GetRefSources(ctx context.Context, sources argoappv1.ApplicationSources, project string, getRepository func(ctx context.Context, url string, project string) (*argoappv1.Repository, error), revisions []string, isRollback bool) (argoappv1.RefTargetRevisionMapping, error) {
461+
ctx, span := otel.GetTracerProvider().Tracer("argocd-server").Start(ctx, "GetRefSources")
462+
defer span.End()
463+
460464
refSources := make(argoappv1.RefTargetRevisionMapping)
461465
if len(sources) > 1 {
462466
// Validate first to avoid unnecessary DB calls.

0 commit comments

Comments
 (0)