Skip to content

Commit

Permalink
PatchEnvelopes: move PatchEnvelopeAppUsage from App to Metrics
Browse files Browse the repository at this point in the history
For API changes see lf-edge/eve-api#39

Signed-off-by: Pavel Abramov <uncle.decart@gmail.com>
  • Loading branch information
uncleDecart committed Dec 13, 2023
1 parent 31637d7 commit 6dcf486
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/pillar/cmd/zedagent/handlemetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ func publishMetrics(ctx *zedagentContext, iteration int) {
ReportAppMetric.Memory = new(metrics.MemoryMetric)
ReportAppMetric.AppName = aiStatus.DisplayName
ReportAppMetric.AppID = aiStatus.Key()
ReportAppMetric.PatchEnvelope = composePatchEnvelopeUsage(aiStatus.Key(), ctx)

if !aiStatus.BootTime.IsZero() && aiStatus.Activated {
elapsed := time.Since(aiStatus.BootTime)
uptime, _ := ptypes.TimestampProto(
Expand Down Expand Up @@ -1055,7 +1057,6 @@ func PublishAppInfoToZedCloud(ctx *zedagentContext, uuid string,
ReportAppInfo.AppVersion = aiStatus.UUIDandVersion.Version
ReportAppInfo.AppName = aiStatus.DisplayName
ReportAppInfo.State = aiStatus.State.ZSwState()
ReportAppInfo.PatchEnvelope = composePatchEnvelopeUsage(uuid, ctx)
if !aiStatus.ErrorTime.IsZero() {
errInfo := encodeErrorInfo(
aiStatus.ErrorAndTimeWithSource.ErrorDescription)
Expand Down
7 changes: 4 additions & 3 deletions pkg/pillar/cmd/zedagent/handlepatchenvelopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (

"github.com/golang/protobuf/ptypes"
"github.com/lf-edge/eve-api/go/info"
"github.com/lf-edge/eve-api/go/metrics"
"github.com/lf-edge/eve/pkg/pillar/types"
"google.golang.org/protobuf/proto"
)

func composePatchEnvelopeUsage(appUUID string, ctx *zedagentContext) []*info.ZInfoPatchEnvelopeUsage {
result := []*info.ZInfoPatchEnvelopeUsage{}
func composePatchEnvelopeUsage(appUUID string, ctx *zedagentContext) []*metrics.AppPatchEnvelopeMetric {
result := []*metrics.AppPatchEnvelopeMetric{}

for _, c := range ctx.subPatchEnvelopeUsage.GetAll() {
peUsage := c.(types.PatchEnvelopeUsage)
if peUsage.AppUUID == appUUID {
result = append(result, &info.ZInfoPatchEnvelopeUsage{
result = append(result, &metrics.AppPatchEnvelopeMetric{
Uuid: peUsage.PatchID,
Version: peUsage.Version,
PatchApiCallCount: peUsage.PatchAPICallCount,
Expand Down

0 comments on commit 6dcf486

Please sign in to comment.