Skip to content

Conversation

@PaddyMc
Copy link
Collaborator

@PaddyMc PaddyMc commented Nov 28, 2025

Add DD profiler:

2025/11/28 10:00:35 Datadog Tracer v2.4.0 INFO: Profiler configuration: {"agentless":false,"block_profile_enabled":true,"block_profile_rate":100000000,"cpu_duration":"1m0s","cpu_profile_enabled":true,"cpu_profile_rate":0,"custom_profiler_label_keys":null,"date":"2025-11-28T10:00:35Z","debug_compression_settings":"zstd","delta_profiles":true,"enabled":true,"endpoint_count_enabled":false,"env":"","execution_trace_enabled":true,"execution_trace_period":"15m0s","execution_trace_size_limit":5242880,"flush_on_exit":false,"goroutine_profile_enabled":true,"goroutine_wait_profile_enabled":false,"heap_profile_enabled":true,"hostname":"ghost","lang":"Go","lang_version":"go1.24.10","max_goroutines_wait":1000,"mutex_profile_enabled":true,"mutex_profile_fraction":10,"num_custom_profiler_label_keys":0,"os_name":"Ubuntu","os_version":"22.04.5 LTS (Jammy Jellyfish)","profile_period":"1m0s","service":"osmosis-dd-profiler","tags":["process_id:3704468","git.commit.sha:7937a60811454ca7c94c65dcd78ab3ca388600eb","go_path:github.com/osmosis-labs/osmosis/v31/cmd/osmosisd","profiler_version:v2.4.0","runtime_version:1.24.10","runtime_compiler:gc","runtime_arch:amd64","runtime_os:linux","runtime-id:7076f421-9373-47e3-a368-435644d5ef16"],"target_url":"http://localhost:8126/profiling/v1/input","upload_timeout":"10s","version":"v2.4.0"}
2025/11/28 10:00:35 Datadog Tracer v2.4.0 WARN: appsec: error while flushing SCA Security Data: Post "http://localhost:8126/telemetry/proxy/api/v2/apmtelemetry": dial tcp 127.0.0.1:8126: connect: connection refused
10:00AM INF Overwriting config.toml and app.toml values with some recommended defaults. To prevent this, set the --reject-config-defaults flag to true. module=server
2025/11/28 10:00:36 Datadog Tracer v2.4.0 INFO: Profiling stopped
2025/11/28 10:00:36 Datadog Tracer v2.4.0 INFO: Profiler configuration: {"agentless":false,"block_profile_enabled":true,"block_profile_rate":100000000,"cpu_duration":"1m0s","cpu_profile_enabled":true,"cpu_profile_rate":0,"custom_profiler_label_keys":null,"date":"2025-11-28T10:00:36Z","debug_compression_settings":"zstd","delta_profiles":true,"enabled":true,"endpoint_count_enabled":false,"env":"","execution_trace_enabled":true,"execution_trace_period":"15m0s","execution_trace_size_limit":5242880,"flush_on_exit":false,"goroutine_profile_enabled":true,"goroutine_wait_profile_enabled":false,"heap_profile_enabled":true,"hostname":"ghost","lang":"Go","lang_version":"go1.24.10","max_goroutines_wait":1000,"mutex_profile_enabled":true,"mutex_profile_fraction":10,"num_custom_profiler_label_keys":0,"os_name":"Ubuntu","os_version":"22.04.5 LTS (Jammy Jellyfish)","profile_period":"1m0s","service":"osmosis-dd-profiler","tags":["process_id:3704468","git.commit.sha:7937a60811454ca7c94c65dcd78ab3ca388600eb","go_path:github.com/osmosis-labs/osmosis/v31/cmd/osmosisd","profiler_version:v2.4.0","runtime_version:1.24.10","runtime_compiler:gc","runtime_arch:amd64","runtime_os:linux","runtime-id:7076f421-9373-47e3-a368-435644d5ef16"],"target_url":"http://localhost:8126/profiling/v1/input","upload_timeout":"10s","version":"v2.4.0"}

mergify bot and others added 2 commits October 23, 2025 22:18
(cherry picked from commit 9b6aafb)

Co-authored-by: Dev Ojha <[email protected]>
Signed-off-by: PaddyMc <[email protected]>
@github-actions github-actions bot added C:x/txfees C:app-wiring Changes to the app folder labels Nov 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

Adds DataDog profiler startup to the app initialization, changes two fee globals to use cloned copies of ConsensusMinFee, and tweaks the Go linker flags in the Dockerfile build step.

Changes

Cohort / File(s) Summary
DataDog Profiler Integration
app/app.go
Imports the Datadog profiler and calls profiler.Start(...) with profile types CPU, Heap, Block, Mutex, and Goroutine during app startup; panics on start error. Executed after OTEL tracer initialization.
Fee Base Initialization
x/txfees/keeper/mempool-1559/code.go
Changes initialization of DefaultBaseFee and MinBaseFee from direct assignment of types.ConsensusMinFee to types.ConsensusMinFee.Clone(), creating independent copies.
Build/linker flags
Dockerfile
Adjusts linker flags in the go build step: fixes quoting and adds -checklinkname=0 to the -ldflags invocation while retaining other flags (e.g., -w, -s, -linkmode=external, -extldflags with -Wl,-z,muldefs -static).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review usages of DefaultBaseFee and MinBaseFee across the codebase to ensure Clone() semantics are correct and do not alter expected comparisons or mutations.
  • Confirm DataDog profiler choice of profile types and that panicking on profiler start is acceptable for startup failure semantics.
  • Verify Dockerfile linker flag change (-checklinkname=0) does not introduce build/linker regressions on CI or target platforms.

Pre-merge checks and finishing touches

❌ Failed checks (2 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix/profiler v31' is vague and doesn't clearly convey the primary change (adding DataDog profiler integration). Revise the title to be more descriptive, e.g., 'Add DataDog profiler integration to OsmosisApp startup' to clearly communicate the main purpose of the PR.
Description check ❓ Inconclusive The description lacks the required template structure; it only shows profiler configuration logs without addressing purpose, testing, documentation, or changelog sections. Follow the PR description template by adding 'What is the purpose of the change' section, specifying testing approach, and confirming changelog and documentation status.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/profiler-v31

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c0744a and 8d007d0.

📒 Files selected for processing (1)
  • Dockerfile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: push-docker-images
  • GitHub Check: e2e
  • GitHub Check: go-split-test-files
  • GitHub Check: osmosisd-linux-amd64
  • GitHub Check: osmosisd-linux-arm64
  • GitHub Check: check-proto
  • GitHub Check: Run golangci-lint
  • GitHub Check: Summary
🔇 Additional comments (1)
Dockerfile (1)

55-56: Based on my verification, I can now provide the rewritten review comment:


The -checklinkname=0 flag syntax is correct, but verify the actual source of the linker error.

The flag syntax follows Go 1.23+ documentation correctly (accepts 0 to allow all //go:linkname usage). However, the underlying assumption is inaccurate: Datadog's Go profiler does not specifically require this flag.

The commit message ("Supress linker error") indicates this is a generic workaround for a linker name resolution issue, likely from a transitive dependency using //go:linkname internally (not the Datadog profiler itself). Confirm which dependency actually requires this flag and document it in the commit message or code comments for future maintainers.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
x/txfees/keeper/mempool-1559/code.go (1)

34-37: Decoupling base‑fee globals from ConsensusMinFee via Clone() looks good; update doc comment

Using types.ConsensusMinFee.Clone() for both DefaultBaseFee and MinBaseFee is a good change: it avoids aliasing the shared ConsensusMinFee value and keeps future mutations of these globals from accidentally affecting the constant.

The block comment above still documents different initial numeric values for DefaultBaseFee and MinBaseFee, which no longer matches reality (both now start from the same ConsensusMinFee). It’d be good to update that comment (and any related docs) to reflect the actual defaults so operators aren’t misled.

Also applies to: 49-50

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 713611e and 3c0744a.

⛔ Files ignored due to path filters (3)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
  • go.work is excluded by !**/*.work, !**/*.work
📒 Files selected for processing (2)
  • app/app.go (2 hunks)
  • x/txfees/keeper/mempool-1559/code.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
x/txfees/keeper/mempool-1559/code.go (1)
x/txfees/types/constants.go (1)
  • ConsensusMinFee (13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: e2e
  • GitHub Check: go-split-test-files
  • GitHub Check: osmosisd-darwin-arm64
  • GitHub Check: osmosisd-darwin-amd64
  • GitHub Check: osmosisd-linux-amd64
  • GitHub Check: osmosisd-linux-arm64
  • GitHub Check: test
  • GitHub Check: check-proto
  • GitHub Check: Run golangci-lint
  • GitHub Check: Summary

semconv "go.opentelemetry.io/otel/semconv/v1.4.0"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/DataDog/dd-trace-go/v2/profiler"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's locate and examine app/app.go
fd -type f -name "app.go" | head -20

Repository: osmosis-labs/osmosis

Length of output: 234


🏁 Script executed:

#!/bin/bash
# Locate app/app.go
find . -name "app.go" -path "*/app/*" | head -5

Repository: osmosis-labs/osmosis

Length of output: 76


🏁 Script executed:

#!/bin/bash
# Get file info and read around the import line
wc -l ./app/app.go
echo "=== Lines 1-30 (import section) ==="
head -30 ./app/app.go | cat -n

Repository: osmosis-labs/osmosis

Length of output: 1127


🏁 Script executed:

#!/bin/bash
# Read the NewOsmosisApp function area where profiler.Start is called
sed -n '280,310p' ./app/app.go | cat -n

Repository: osmosis-labs/osmosis

Length of output: 1072


🏁 Script executed:

#!/bin/bash
# Search for profiler.Stop and any profiler config
echo "=== Searching for profiler.Stop() ==="
rg -n "profiler\.Stop" ./app/app.go

echo -e "\n=== Searching for profiler config/flag patterns ==="
rg -n -i "profiler.*config\|config.*profiler\|profiler.*flag" ./app/app.go

echo -e "\n=== Checking function signature of Start call context ==="
sed -n '200,230p' ./app/app.go | cat -n

Repository: osmosis-labs/osmosis

Length of output: 1653


🏁 Script executed:

#!/bin/bash
# Find NewOsmosisApp function
echo "=== Finding NewOsmosisApp function ==="
rg -n "^func.*NewOsmosisApp" ./app/app.go

echo -e "\n=== Searching entire repo for profiler.Stop ==="
rg -r "profiler\.Stop" .

echo -e "\n=== Looking for main.go or cmd files ==="
find . -name "main.go" -o -name "cmd" -type d | head -10

Repository: osmosis-labs/osmosis

Length of output: 50533


🏁 Script executed:

#!/bin/bash
# Search for profiler in Go files only
echo "=== Searching for profiler in Go files ==="
rg -n "profiler" --type=go ./app/app.go

echo -e "\n=== Looking for cmd/main.go ==="
find . -path "*/cmd/*" -name "main.go" | head -5

echo -e "\n=== Checking if Stop is called elsewhere in Go codebase ==="
rg -n "\.Stop\(\)" --type=go . | grep -i profiler | head -20

Repository: osmosis-labs/osmosis

Length of output: 771


🏁 Script executed:

#!/bin/bash
# Read the full profiler block in app/app.go (lines 289-310)
echo "=== Full profiler block in app/app.go ==="
sed -n '289,310p' ./app/app.go | cat -n

echo -e "\n=== Check cmd/osmosisd/main.go for profiler Stop and shutdown ==="
grep -n "profiler" ./cmd/osmosisd/main.go
grep -n -i "shutdown\|deferred\|defer" ./cmd/osmosisd/main.go | head -10

Repository: osmosis-labs/osmosis

Length of output: 1023


🏁 Script executed:

#!/bin/bash
# Read cmd/osmosisd/main.go to see structure
wc -l ./cmd/osmosisd/main.go
head -50 ./cmd/osmosisd/main.go | cat -n

Repository: osmosis-labs/osmosis

Length of output: 642


🌐 Web query:

Datadog Go profiler BlockProfile MutexProfile GoroutineProfile default disabled

💡 Result:

Short answer: Datadog’s Go profiler enables only CPU and heap profiles by default; BlockProfile, MutexProfile and GoroutineProfile are disabled and must be explicitly enabled via profiler.WithProfileTypes (or equivalent config). [1][2]

Sources:

  • Datadog Go profiler docs (shows Block/Mutex/Goroutine commented out / disabled by default). [1]
  • Go runtime/pprof docs (notes block and mutex profiles are not enabled by default). [2]

🏁 Script executed:

#!/bin/bash
# Search for any config/flag handling related to profiler
echo "=== Search for config or flags related to profiler ==="
rg -n -i "config.*profiler\|profiler.*config\|profiler.*flag\|flag.*profiler" --type=go .

echo -e "\n=== Check if NewOsmosisApp takes any config parameter ==="
sed -n '258,270p' ./app/app.go | cat -n

Repository: osmosis-labs/osmosis

Length of output: 592


Excellent. I have verified all the key claims in the review comment. Let me now generate the final rewritten review comment:


Make Datadog profiler startup best‑effort (don't panic) and reassess enabled profile types

The Datadog profiler starts unconditionally in NewOsmosisApp (line 290) and panics the entire process if startup fails. Since profiling is an optional observability feature, treating it as fatal makes node availability dependent on profiler configuration and environment (API key / agent / hostname, etc.).

Additionally, you're enabling all five profile types: CPU, Heap, Block, Mutex, and Goroutine. Datadog's documentation explicitly keeps Block, Mutex, and Goroutine disabled by default "to keep overhead low", and recommends enabling them only as needed. For a validator or full‑node, this overhead could be non‑trivial if turned on by default across the fleet.

Concrete suggestions:

  • Handle profiler.Start errors as non‑fatal: log and continue instead of panic (line 304).
  • Optionally gate profiler startup behind a dedicated config flag (e.g., using appOpts) so operators can enable it only where desired.
  • Reconsider whether Block/Mutex/Goroutine profiles should be enabled by default, or make those configurable.
  • Ensure profiler.Stop() is called once on clean shutdown (wire this in the daemon's entry point, likely via a defer or shutdown hook), so final profiles are flushed.

Example minimal change for error handling:

-	// Initialize DataDog profiler if enabled
-	err := profiler.Start(
+	// Initialize Datadog profiler (best-effort; do not fail app on error).
+	if err := profiler.Start(
 		profiler.WithService("osmosis-dd-profiler"),
@@
-	)
-	if err != nil {
-		panic(err)
-	}
+	); err != nil {
+		logger.Error("failed to start Datadog profiler", "err", err)
+	}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In app/app.go around lines 290-304, the Datadog profiler is started
unconditionally and panics on error and enables all profile types; change this
so profiler.Start errors are handled as non-fatal (log the error and continue
instead of panic), add an opt-in config flag (e.g., via appOpts) to gate
profiler startup, disable Block/Mutex/Goroutine by default (or make those
profile types configurable), and ensure profiler.Stop() is invoked exactly once
on clean shutdown (wire into the daemon shutdown hook or use defer in the
main/entrypoint).

@pablin-10 pablin-10 requested a review from a team as a code owner November 28, 2025 22:03
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!

@github-actions github-actions bot added the Stale label Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants