-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add pyrocope continuous profiling to activator #82
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
Conversation
5f2b51e to
cb170d0
Compare
add dependencies stack-info: PR: #82, branch: yaseenisolated/stack/1
cb170d0 to
6fff72e
Compare
add dependencies stack-info: PR: #82, branch: yaseenisolated/stack/1
6fff72e to
70a1fe6
Compare
add dependencies stack-info: PR: #82, branch: yaseenisolated/stack/1
70a1fe6 to
ce5dc05
Compare
add dependencies stack-info: PR: #82, branch: yaseenisolated/stack/1
ce5dc05 to
3ea7267
Compare
3ea7267 to
6559b00
Compare
Pull Request Review: Pyroscope Continuous Profiling IntegrationThank you for adding continuous profiling support to the activator! This is a valuable observability feature. Below is my detailed review: ✅ Positive Aspects
🔍 Issues & Concerns1. Critical: Missing TestsSeverity: High The Recommendation: Add a test file func TestParsePyroscopeTags(t *testing.T) {
tests := []struct {
name string
input string
expected map[string]string
}{
{
name: "empty string",
input: "",
expected: map[string]string{},
},
{
name: "single tag",
input: "env=prod",
expected: map[string]string{"env": "prod"},
},
{
name: "multiple tags",
input: "env=prod;cluster=canary;region=us-west",
expected: map[string]string{"env": "prod", "cluster": "canary", "region": "us-west"},
},
{
name: "tags with spaces",
input: "env = prod ; cluster = canary",
expected: map[string]string{"env": "prod", "cluster": "canary"},
},
{
name: "empty tag segments",
input: "env=prod;;cluster=canary",
expected: map[string]string{"env": "prod", "cluster": "canary"},
},
{
name: "empty key ignored",
input: "=value;env=prod",
expected: map[string]string{"env": "prod"},
},
{
name: "missing value allowed",
input: "env=;cluster=canary",
expected: map[string]string{"env": "", "cluster": "canary"},
},
{
name: "no equals sign ignored",
input: "invalid;env=prod",
expected: map[string]string{"env": "prod"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := parsePyroscopeTags(tt.input)
if \!reflect.DeepEqual(result, tt.expected) {
t.Errorf("parsePyroscopeTags(%q) = %v, want %v", tt.input, result, tt.expected)
}
})
}
}2. Security: Credential Exposure in LogsSeverity: Medium Line 184 logs the server address when profiling starts: log.Printf("Pyroscope profiler started, sending to %s", env.PyroscopeServerAddress)If the Recommendation: Sanitize the URL before logging: // Parse and sanitize URL for logging
sanitizedAddr := env.PyroscopeServerAddress
if u, err := url.Parse(env.PyroscopeServerAddress); err == nil && u.User \!= nil {
u.User = nil
sanitizedAddr = u.String()
}
log.Printf("Pyroscope profiler started, sending to %s", sanitizedAddr)3. Performance: Profile Rate DefaultsSeverity: Low The default values for mutex and block profiling may have performance implications:
Context:
For the activator (a critical hot-path component handling all traffic), these defaults might introduce measurable overhead. Recommendation: Document the performance impact in comments and consider more conservative defaults: // MutexProfileRate controls mutex profiling sampling rate (1 = profile every event)
// Higher values reduce overhead. Recommended: 100-1000 for production
MutexProfileRate int `split_words:"true" default:"1000"`
// BlockProfileRate controls block profiling threshold in nanoseconds
// Only blocks longer than this value are profiled. Recommended: 100000+ for production
BlockProfileRate int `split_words:"true" default:"100000"`4. Code Quality: Missing Input ValidationSeverity: Low The Recommendation: Add reasonable limits: const (
maxTagStringLength = 4096 // Reasonable limit for tag string
maxTags = 50 // Reasonable limit for number of tags
)
func parsePyroscopeTags(tagsStr string) map[string]string {
tags := make(map[string]string)
if tagsStr == "" || len(tagsStr) > maxTagStringLength {
return tags
}
pairs := strings.Split(tagsStr, ";")
if len(pairs) > maxTags {
pairs = pairs[:maxTags] // Truncate to max
}
// ... rest of parsing logic
}5. Documentation: Missing Configuration ExamplesSeverity: Low The PR lacks documentation on how to configure Pyroscope in a Kubernetes deployment. Users need to know:
Recommendation: Add a comment block or update relevant documentation: # Example: Enable Pyroscope profiling for activator
# Add to config-deployment ConfigMap or activator deployment:
env:
- name: PYROSCOPE_SERVER_ADDRESS
value: "http://pyroscope.monitoring.svc.cluster.local:4040"
- name: PYROSCOPE_TAGS
value: "environment=production;cluster=us-west-2"
# Optional: Add basic auth
- name: PYROSCOPE_BASIC_AUTH_USER
valueFrom:
secretKeyRef:
name: pyroscope-creds
key: username
- name: PYROSCOPE_BASIC_AUTH_PASS
valueFrom:
secretKeyRef:
name: pyroscope-creds
key: password6. Minor: Inconsistent Error HandlingSeverity: Very Low Line 181 uses 📊 Performance Considerations
🔒 Security Assessment
📝 Recommendations SummaryMust Address Before Merge:
Should Address: Nice to Have: ✨ Overall AssessmentThis is a solid feature addition that will provide valuable production insights. The implementation is clean and follows good practices. With the addition of tests and minor security improvements, this will be ready to merge. Suggested Action: Address the test coverage issue (#1) before merging. Other issues can be addressed in follow-up PRs if needed. Great work on this feature! Let me know if you'd like help implementing any of these recommendations. |
6559b00 to
1286bf7
Compare
Code Review: Pyroscope Continuous Profiling IntegrationThank you for adding continuous profiling support to the activator! This is a valuable addition for production observability. Below is my detailed review: ✅ Strengths
🔍 Code Quality Issues1. Security: Credentials in Environment VariablesLocation: Issue: Storing credentials in environment variables is not ideal for production use. Recommendation: Consider using Kubernetes secrets mounted as files, or integrate with a secrets manager. Document this security consideration in comments: // SECURITY NOTE: For production use, consider using Kubernetes secrets
// or a secrets manager instead of environment variables for credentials
PyroscopeBasicAuthUser string `split_words:"true"`
PyroscopeBasicAuthPass string `split_words:"true"`2. Inconsistent LoggingLocation: Issue: Using Problem: The structured zap logger is created at line 166, but Pyroscope initialization at line 206 uses the standard Fix: if _, err := pyroscope.Start(pyroscopeConfig); err != nil {
logger.Warnw("Failed to start Pyroscope profiler", zap.Error(err))
} else {
logger.Infow("Pyroscope profiler started", zap.String("server", env.PyroscopeServerAddress))
}3. Missing Configuration ValidationLocation: Issue: No validation that Recommendation: Add URL validation: if env.PyroscopeServerAddress != "" {
if _, err := url.Parse(env.PyroscopeServerAddress); err != nil {
logger.Warnw("Invalid Pyroscope server address, profiling disabled",
zap.String("address", env.PyroscopeServerAddress),
zap.Error(err))
goto skipPyroscope
}
// ... rest of pyroscope setup
}
skipPyroscope:4. Default Profile Rates Not DocumentedLocation: Issue: Default values (100, 10000) are not explained. Recommendation: Add comments explaining the implications: // MutexProfileRate controls mutex profiling sampling rate (1 in N events)
// Higher = less overhead but less detail. Default 100 captures 1% of mutex events.
MutexProfileRate int `split_words:"true" default:"100"`
// BlockProfileRate sets the fraction of goroutine blocking events recorded (nanoseconds)
// Only events blocking >= this duration are recorded. Default 10000ns = 10µs.
BlockProfileRate int `split_words:"true" default:"10000"`
|
* go mod vendor stack-info: PR: #90, branch: yaseenisolated/stack/3 * feat: add pyrocope continuous profiling to activator (#82) add dependencies feat: add pyrocope continuous profiling to activator add dependencies stack-info: PR: #82, branch: yaseenisolated/stack/1 feat: Add feature gates for debug dashboard, event persistence, and r… (#78) feat: add command line args for pyroscope tags
Stacked PRs:
feat: add pyrocope continuous profiling to activator
add dependencies
feat: add pyrocope continuous profiling to activator
add dependencies
feat: Add feature gates for debug dashboard, event persistence, and r… (#78)
feat: add command line args for pyroscope tags