From 5625239d6dae7b65b1110e6a3d306f17743e25f2 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Sat, 14 Sep 2024 16:49:56 +0300 Subject: [PATCH] feat: add code-attributes profile for recording go code attributes --- cli/cmd/resources/odiglet.go | 12 +++++++++++- cli/cmd/resources/profiles.go | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cli/cmd/resources/odiglet.go b/cli/cmd/resources/odiglet.go index 5c962e8a7b..50fd3a8f13 100644 --- a/cli/cmd/resources/odiglet.go +++ b/cli/cmd/resources/odiglet.go @@ -2,6 +2,7 @@ package resources import ( "context" + "slices" "k8s.io/apimachinery/pkg/api/resource" @@ -709,9 +710,18 @@ func (a *odigletResourceManager) InstallFromScratch(ctx context.Context) error { resources = append(resources, NewResourceQuota(a.ns)) } + // temporary hack - check if the profiles named "code-attributes" or "kratos" are enabled. + // in the future, the go code attribute collection should be handled on an otel-sdk level + // instead of setting a global environment variable. + // once this is done, we can remove this check. + goAutoIncludeCodeAttributes := a.config.GoAutoIncludeCodeAttributes + if slices.Contains(a.config.Profiles, "code-attributes") || slices.Contains(a.config.Profiles, "kratos") { + goAutoIncludeCodeAttributes = true + } + // before creating the daemonset, we need to create the service account, cluster role and cluster role binding resources = append(resources, - NewOdigletDaemonSet(a.ns, a.odigosVersion, a.config.ImagePrefix, odigletImage, a.odigosTier, a.config.OpenshiftEnabled, a.config.GoAutoIncludeCodeAttributes)) + NewOdigletDaemonSet(a.ns, a.odigosVersion, a.config.ImagePrefix, odigletImage, a.odigosTier, a.config.OpenshiftEnabled, goAutoIncludeCodeAttributes)) return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources) } diff --git a/cli/cmd/resources/profiles.go b/cli/cmd/resources/profiles.go index 3c999e1b5c..9675cc7f6b 100644 --- a/cli/cmd/resources/profiles.go +++ b/cli/cmd/resources/profiles.go @@ -46,6 +46,10 @@ var ( ShortDescription: "Populate the spans resource `host.name` attribute with value of `k8s.pod.name`", ClientObject: &odigosv1alpha1.Processor{}, } + codeAttributesProfile = Profile{ + ProfileName: common.ProfileName("code-attributes"), + ShortDescription: "Record span attributes in 'code' namespace where supported", + } kratosProfile = Profile{ ProfileName: common.ProfileName("kratos"), @@ -82,6 +86,7 @@ func GetResourcesForProfileName(profileName common.ProfileName, tier common.Odig } return allResources, nil } + return nil, nil // a profile might not be implemented as a resource necessarily } }