• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 14358372723

09 Apr 2025 01:26PM UTC coverage: 56.696% (-12.3%) from 69.037%
14358372723

Pull #9696

github

web-flow
Merge e2837e400 into 867d27d68
Pull Request #9696: Add `development_guidelines.md` for both human and machine

107055 of 188823 relevant lines covered (56.7%)

22721.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lncfg/pprof.go
1
package lncfg
2

3
import (
4
        "net"
5
        "strconv"
6
)
7

8
// Pprof holds the configuration options for LND's built-in pprof server.
9
//
10
//nolint:ll
11
type Pprof struct {
12
        CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
13

14
        Profile string `long:"profile" description:"Enable HTTP profiling on either a port or host:port"`
15

16
        BlockingProfile int `long:"blockingprofile" description:"Used to enable a blocking profile to be served on the profiling port. This takes a value from 0 to 1, with 1 including every blocking event, and 0 including no events."`
17

18
        MutexProfile int `long:"mutexprofile" description:"Used to Enable a mutex profile to be served on the profiling port. This takes a value from 0 to 1, with 1 including every mutex event, and 0 including no events."`
19
}
20

21
// Validate checks the values configured for the profiler.
22
func (p *Pprof) Validate() error {
×
23
        if p.BlockingProfile > 0 {
×
24
                log.Warn("Blocking profile enabled only useful for " +
×
25
                        "debugging because of significant performance impact")
×
26
        }
×
27

28
        if p.MutexProfile > 0 {
×
29
                log.Warn("Mutex profile enabled only useful for " +
×
30
                        "debugging because of significant performance impact")
×
31
        }
×
32

33
        if p.CPUProfile != "" {
×
34
                log.Warn("CPU profile enabled only useful for " +
×
35
                        "debugging because of significant performance impact")
×
36
        }
×
37

38
        if p.Profile != "" {
×
39
                str := "%v: The profile port must be between 1024 and 65535"
×
40

×
41
                // Try to parse Profile as a host:port.
×
42
                _, hostPort, err := net.SplitHostPort(p.Profile)
×
43
                if err == nil {
×
44
                        // Determine if the port is valid.
×
45
                        profilePort, err := strconv.Atoi(hostPort)
×
46

×
47
                        if err != nil || profilePort < 1024 ||
×
48
                                profilePort > 65535 {
×
49

×
50
                                return &UsageError{Err: mkErr(str, hostPort)}
×
51
                        }
×
52
                } else {
×
53
                        // Try to parse Profile as a port.
×
54
                        profilePort, err := strconv.Atoi(p.Profile)
×
55
                        if err != nil || profilePort < 1024 ||
×
56
                                profilePort > 65535 {
×
57

×
58
                                return &UsageError{Err: mkErr(str, p.Profile)}
×
59
                        }
×
60

61
                        // Since the user just set a port, we will serve
62
                        // debugging information over localhost.
63
                        p.Profile = net.JoinHostPort("127.0.0.1", p.Profile)
×
64
                }
65
        }
66

67
        return nil
×
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc