From bc4db6b182c0ca8224cfb161dd4edb1e3b5f2034 Mon Sep 17 00:00:00 2001 From: tamirdavid1 Date: Mon, 16 Dec 2024 13:57:17 +0200 Subject: [PATCH 1/4] feat: add pprof extension to datacollection --- autoscaler/controllers/datacollection/configmap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoscaler/controllers/datacollection/configmap.go b/autoscaler/controllers/datacollection/configmap.go index 060f817f2..d1b318c96 100644 --- a/autoscaler/controllers/datacollection/configmap.go +++ b/autoscaler/controllers/datacollection/configmap.go @@ -239,6 +239,7 @@ func calculateConfigMapData(nodeCG *odigosv1.CollectorsGroup, apps *odigosv1.Ins "health_check": config.GenericMap{ "endpoint": "0.0.0.0:13133", }, + "pprof": config.GenericMap{}, }, Service: config.Service{ Pipelines: map[string]config.Pipeline{ @@ -248,7 +249,7 @@ func calculateConfigMapData(nodeCG *odigosv1.CollectorsGroup, apps *odigosv1.Ins Exporters: []string{"otlp/odigos-own-telemetry-ui"}, }, }, - Extensions: []string{"health_check"}, + Extensions: []string{"health_check", "pprof"}, Telemetry: config.Telemetry{ Metrics: config.GenericMap{ "address": fmt.Sprintf("0.0.0.0:%d", ownMetricsPort), From 8ec3823c15d2cab343037768d7d1d3d1562d9cbd Mon Sep 17 00:00:00 2001 From: tamirdavid1 Date: Mon, 16 Dec 2024 14:29:05 +0200 Subject: [PATCH 2/4] feat: add short guide about collecting these profiles --- development.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 development.md diff --git a/development.md b/development.md new file mode 100644 index 000000000..0ac8ac087 --- /dev/null +++ b/development.md @@ -0,0 +1,43 @@ +# Development Guide + +This guide provides advanced instructions for contributors and maintainers, covering topics such as debugging specific components, analyzing performance profiles, and working with internal tools. It complements the `CONTRIBUTING.md` by offering insights into advanced development workflows and optimization techniques. + +--- + +## CPU and Memory Profiling for the Collectors + +### Step 1: Port Forward the Gateway or Data Collection Pod +Forward the relevant pod to your local machine to enable profiling access: + +kubectl port-forward pod/ -n odigos-system 1777:1777 + + +### Step 2: Collect Profiling Data + +- **CPU Profile** + Captures data about the amount of time your application spends executing functions. Use this profile to identify performance bottlenecks, optimize CPU-intensive operations, and analyze which parts of the code consume the most CPU resources. + + ``` bash + curl -o cpu_profile.prof http://localhost:1777/debug/pprof/profile?seconds=30 + ``` + +- **Heap Memory Profile** + Captures a snapshot of memory currently in use by your application after the latest garbage collection. Use this profile to identify memory leaks, track high memory usage, and analyze memory consumption by specific parts of the code. + ``` bash + curl -o heap.out http://localhost:1777/debug/pprof/heap + ``` + +- **Historical Memory Allocation** + Provides insights into all memory allocations made by the program since it started running, including memory that has already been freed by the garbage collector (GC). This is useful for understanding memory allocation patterns and optimizing allocation behavior. + ``` bash + curl -o allocs.out http://localhost:1777/debug/pprof/allocs + ``` + +### Step 3: Analyze the Profiles +After collecting the profiling data, use the `go tool pprof` command to analyze the profiles visually in your web browser. Replace `` with the appropriate file (`cpu_profile.prof`, `heap.out`, or `allocs.out`): +``` bash +go tool pprof -http=:8080 +``` +This opens an interactive interface in your browser where you can: +- **Visualize Hotspots**: View flame graphs or directed graphs for easy identification of bottlenecks. +- **Drill Down**: Explore specific functions or memory allocations for detailed insights. \ No newline at end of file From 896450fab67a7666414ca86f032cb5ea8d05ac93 Mon Sep 17 00:00:00 2001 From: tamirdavid1 Date: Mon, 16 Dec 2024 14:32:33 +0200 Subject: [PATCH 3/4] cleanup --- development.md | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 development.md diff --git a/development.md b/development.md deleted file mode 100644 index 0ac8ac087..000000000 --- a/development.md +++ /dev/null @@ -1,43 +0,0 @@ -# Development Guide - -This guide provides advanced instructions for contributors and maintainers, covering topics such as debugging specific components, analyzing performance profiles, and working with internal tools. It complements the `CONTRIBUTING.md` by offering insights into advanced development workflows and optimization techniques. - ---- - -## CPU and Memory Profiling for the Collectors - -### Step 1: Port Forward the Gateway or Data Collection Pod -Forward the relevant pod to your local machine to enable profiling access: - -kubectl port-forward pod/ -n odigos-system 1777:1777 - - -### Step 2: Collect Profiling Data - -- **CPU Profile** - Captures data about the amount of time your application spends executing functions. Use this profile to identify performance bottlenecks, optimize CPU-intensive operations, and analyze which parts of the code consume the most CPU resources. - - ``` bash - curl -o cpu_profile.prof http://localhost:1777/debug/pprof/profile?seconds=30 - ``` - -- **Heap Memory Profile** - Captures a snapshot of memory currently in use by your application after the latest garbage collection. Use this profile to identify memory leaks, track high memory usage, and analyze memory consumption by specific parts of the code. - ``` bash - curl -o heap.out http://localhost:1777/debug/pprof/heap - ``` - -- **Historical Memory Allocation** - Provides insights into all memory allocations made by the program since it started running, including memory that has already been freed by the garbage collector (GC). This is useful for understanding memory allocation patterns and optimizing allocation behavior. - ``` bash - curl -o allocs.out http://localhost:1777/debug/pprof/allocs - ``` - -### Step 3: Analyze the Profiles -After collecting the profiling data, use the `go tool pprof` command to analyze the profiles visually in your web browser. Replace `` with the appropriate file (`cpu_profile.prof`, `heap.out`, or `allocs.out`): -``` bash -go tool pprof -http=:8080 -``` -This opens an interactive interface in your browser where you can: -- **Visualize Hotspots**: View flame graphs or directed graphs for easy identification of bottlenecks. -- **Drill Down**: Explore specific functions or memory allocations for detailed insights. \ No newline at end of file From f18224774c16b3bc4de690d724cf0966e36a422f Mon Sep 17 00:00:00 2001 From: tamirdavid1 Date: Mon, 16 Dec 2024 14:32:58 +0200 Subject: [PATCH 4/4] fix: capital letter development.md --- DEVELOPMENT.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 000000000..0ac8ac087 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,43 @@ +# Development Guide + +This guide provides advanced instructions for contributors and maintainers, covering topics such as debugging specific components, analyzing performance profiles, and working with internal tools. It complements the `CONTRIBUTING.md` by offering insights into advanced development workflows and optimization techniques. + +--- + +## CPU and Memory Profiling for the Collectors + +### Step 1: Port Forward the Gateway or Data Collection Pod +Forward the relevant pod to your local machine to enable profiling access: + +kubectl port-forward pod/ -n odigos-system 1777:1777 + + +### Step 2: Collect Profiling Data + +- **CPU Profile** + Captures data about the amount of time your application spends executing functions. Use this profile to identify performance bottlenecks, optimize CPU-intensive operations, and analyze which parts of the code consume the most CPU resources. + + ``` bash + curl -o cpu_profile.prof http://localhost:1777/debug/pprof/profile?seconds=30 + ``` + +- **Heap Memory Profile** + Captures a snapshot of memory currently in use by your application after the latest garbage collection. Use this profile to identify memory leaks, track high memory usage, and analyze memory consumption by specific parts of the code. + ``` bash + curl -o heap.out http://localhost:1777/debug/pprof/heap + ``` + +- **Historical Memory Allocation** + Provides insights into all memory allocations made by the program since it started running, including memory that has already been freed by the garbage collector (GC). This is useful for understanding memory allocation patterns and optimizing allocation behavior. + ``` bash + curl -o allocs.out http://localhost:1777/debug/pprof/allocs + ``` + +### Step 3: Analyze the Profiles +After collecting the profiling data, use the `go tool pprof` command to analyze the profiles visually in your web browser. Replace `` with the appropriate file (`cpu_profile.prof`, `heap.out`, or `allocs.out`): +``` bash +go tool pprof -http=:8080 +``` +This opens an interactive interface in your browser where you can: +- **Visualize Hotspots**: View flame graphs or directed graphs for easy identification of bottlenecks. +- **Drill Down**: Explore specific functions or memory allocations for detailed insights. \ No newline at end of file