Skip to content
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

feat: Added profefe.com/service annotation #20

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/cmd/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func writeProfiles(ctx context.Context, pClient *profefe.Client, profiles map[pp
// if the profefe client is not null the profile needs to be pushed to
// profefe server, otherwise it is written into a file locally
if pClient != nil {
saved, err := pClient.SavePprof(ctx, profefe.SavePprofRequest{
req := profefe.SavePprofRequest{
Profile: profile,
Service: target.Name,
InstanceID: target.Status.HostIP,
Expand All @@ -186,7 +186,12 @@ func writeProfiles(ctx context.Context, pClient *profefe.Client, profiles map[pp
"namespace": target.Namespace,
"from": "kube-profefe",
},
})
}
if serviceName, ok := target.Annotations["profefe.com/service"]; ok && serviceName != "" {
req.Service = serviceName
req.Labels["pod"] = target.Name
}
saved, err := pClient.SavePprof(context.Background(), req)
if err != nil {
println(fmt.Sprintf("%s type=%s profile_type=%s", err.Error(), profefeType, profile.PeriodType.Type))
} else {
Expand Down
9 changes: 7 additions & 2 deletions pkg/cmd/kprofefe.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func do(ctx context.Context, l *zap.Logger, pClient *profefe.Client, target core
logger.Warn("Unknown profile type it can not be sent to profefe. Skip this profile")
continue
}
saved, err := pClient.SavePprof(context.Background(), profefe.SavePprofRequest{
req := profefe.SavePprofRequest{
Profile: profile,
Service: target.Name,
InstanceID: target.Status.HostIP,
Expand All @@ -172,7 +172,12 @@ func do(ctx context.Context, l *zap.Logger, pClient *profefe.Client, target core
"namespace": target.Namespace,
"from": "kube-profefe",
},
})
}
if serviceName, ok := target.Annotations["profefe.com/service"]; ok && serviceName != "" {
req.Service = serviceName
req.Labels["pod"] = target.Name
}
saved, err := pClient.SavePprof(context.Background(), req)
if err != nil {
logger.Warn("Unknown profile type it can not be sent to profefe. Skip this profile", zap.Error(err))
} else {
Expand Down