Skip to content

Allow configurable resource requests and limits received by helm chart. #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func main() {
stringFlagOrEnv(&neuronMonitorImage, "neuron-monitor-image", "RELATED_IMAGE_NEURON_MONITOR", fmt.Sprintf("%s:%s", neuronMonitorImageRepository, v.NeuronMonitor), "The default Neuron monitor image. This image is used when no image is specified in the CustomResource.")
pflag.Parse()

// set instrumentation cpu and memory limits in environment variables to be used for default instrumentation
// set instrumentation cpu and memory limits in environment variables to be used for default instrumentation, which is received from the helm chart
autoInstrumentationConfig := map[string]map[string]map[string]string{"java": {"limits": {"cpu": "500m", "memory": "64Mi"}, "requests": {"cpu": "50m", "memory": "64Mi"}}, "python": {"limits": {"cpu": "500m", "memory": "32Mi"}, "requests": {"cpu": "50m", "memory": "32Mi"}}, "dotnet": {"limits": {"cpu": "500m", "memory": "128Mi"}, "requests": {"cpu": "50m", "memory": "128Mi"}}}
err := json.Unmarshal([]byte(autoInstrumentationConfigStr), &autoInstrumentationConfig)
if err != nil {
Expand Down
18 changes: 12 additions & 6 deletions pkg/instrumentation/defaultinstrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const (

http = "http"
https = "https"

java = "JAVA"
python = "PYTHON"
dotNet = "DOTNET"
limit = "LIMIT"
request = "REQUEST"
)

func getInstrumentationConfigForResource(langStr string, resourceStr string) corev1.ResourceList {
Expand Down Expand Up @@ -105,8 +111,8 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource("JAVA", "LIMIT"),
Requests: getInstrumentationConfigForResource("JAVA", "REQUEST"),
Limits: getInstrumentationConfigForResource(java, limit),
Requests: getInstrumentationConfigForResource(java, request),
},
},
Python: v1alpha1.Python{
Expand All @@ -126,8 +132,8 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource("PYTHON", "LIMIT"),
Requests: getInstrumentationConfigForResource("PYTHON", "REQUEST"),
Limits: getInstrumentationConfigForResource(python, limit),
Requests: getInstrumentationConfigForResource(python, request),
},
},
DotNet: v1alpha1.DotNet{
Expand All @@ -147,8 +153,8 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
{Name: "OTEL_DOTNET_AUTO_PLUGINS", Value: "AWS.Distro.OpenTelemetry.AutoInstrumentation.Plugin, AWS.Distro.OpenTelemetry.AutoInstrumentation"},
},
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource("DOTNET", "LIMIT"),
Requests: getInstrumentationConfigForResource("DOTNET", "REQUEST"),
Limits: getInstrumentationConfigForResource(dotNet, limit),
Requests: getInstrumentationConfigForResource(dotNet, request),
},
},
},
Expand Down
Loading