Skip to content

Commit

Permalink
Merge pull request #20 from profefe/feature/service_annotation
Browse files Browse the repository at this point in the history
feat: Added profefe.com/service annotation
  • Loading branch information
gianarb authored Jan 2, 2020
2 parents 11475be + 3863b97 commit 737bd33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit 737bd33

Please sign in to comment.