-
Notifications
You must be signed in to change notification settings - Fork 48
/
profile.go
49 lines (38 loc) · 1.27 KB
/
profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sparta
import (
"fmt"
"path"
"path/filepath"
"github.com/rs/zerolog"
)
type profileLambdaDecorator func(stackName string, info *LambdaAWSInfo, S3Bucket string, logger *zerolog.Logger) error
var profileDecorator profileLambdaDecorator
const (
cpuProfileName = "cpu"
// Name of the stack, published as env var
envVarStackName = "SPARTA_STACK_NAME"
// Stack instance id, published as env var
envVarStackInstanceID = "SPARTA_STACK_INSTANCE_ID"
// Bucket to use to store profile snapshots, published as env var
envVarProfileBucketName = "SPARTA_PROFILE_BUCKET_NAME"
)
var profileTypes = []string{
cpuProfileName,
"goroutine",
"threadcreate",
"heap",
"block",
"mutex",
}
func profileSnapshotRootKeypath(stackName string) string {
return path.Join("sparta", "pprof", stackName, "profiles")
}
func profileSnapshotRootKeypathForType(profileType string, stackName string) string {
return path.Join(profileSnapshotRootKeypath(stackName), profileType)
}
func cacheDirectoryForProfileType(profileType string, stackName string) string {
return filepath.Join(ScratchDirectory, "profiles", stackName, profileType)
}
func cachedAggregatedProfilePath(profileType string) string {
return filepath.Join(ScratchDirectory, fmt.Sprintf("%s.consolidated.profile", profileType))
}