Skip to content

Commit

Permalink
feat: add code-attributes profile for recording attributes from semco…
Browse files Browse the repository at this point in the history
…nv 'code' ns (#1500)

This profile replaces the need to modify `odigos-config` to enable go
code attributes collection.

It is a bit patchy, and should be replaced in the future with
configuration per otel-sdk via config providers, instead of a global env
to the odiglet.
  • Loading branch information
blumamir authored Sep 14, 2024
1 parent 228f166 commit 1532011
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cli/cmd/resources/odiglet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resources

import (
"context"
"slices"

"k8s.io/apimachinery/pkg/api/resource"

Expand Down Expand Up @@ -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)
}
9 changes: 7 additions & 2 deletions cli/cmd/resources/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ var (
ShortDescription: "Instrument Java applications using native instrumentation and eBPF enterprise processing",
ClientObject: &odigosv1alpha1.InstrumentationRule{},
}
codeAttributesProfile = Profile{
ProfileName: common.ProfileName("code-attributes"),
ShortDescription: "Record span attributes in 'code' namespace where supported",
}

kratosProfile = Profile{
ProfileName: common.ProfileName("kratos"),
ShortDescription: "Bundle profile that includes full-payload-collection, semconv, category-attributes, copy-scope, hostname-as-podname, java-native-instrumentations",
Dependencies: []common.ProfileName{"full-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations"},
ShortDescription: "Bundle profile that includes full-payload-collection, semconv, category-attributes, copy-scope, hostname-as-podname, java-native-instrumentations, code-attributes",
Dependencies: []common.ProfileName{"full-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations", "code-attributes"},
}
)

Expand Down Expand Up @@ -87,6 +91,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
}
}

Expand Down

0 comments on commit 1532011

Please sign in to comment.