Skip to content

Commit

Permalink
lookup api service id in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollins-axway committed Oct 28, 2024
1 parent 4408d1f commit 86c7e98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/transaction/metric/metricscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,17 @@ func (c *collector) createAppDetail(appRI *v1.ResourceInstance) *models.Applicat
}

func (c *collector) createAPIDetail(api models.APIDetails) *models.APIResourceReference {
return &models.APIResourceReference{
ref := &models.APIResourceReference{
ResourceReference: models.ResourceReference{
ID: api.ID,
},
Name: api.Name,
}
svc, err := agent.GetAPICache().GetBySecondaryKey(strings.TrimPrefix(api.ID, transutil.SummaryEventProxyIDPrefix))
if err == nil {
ref.APIServiceID = svc.(v1.ResourceInstance).Metadata.ID
}
return ref
}

func (c *collector) getAssetResource(accessRequest *management.AccessRequest) *models.ResourceReference {
Expand Down
8 changes: 7 additions & 1 deletion pkg/transaction/metric/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package metric
import (
"strings"

"github.com/Axway/agent-sdk/pkg/agent"
v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1"
"github.com/Axway/agent-sdk/pkg/transaction/models"
transutil "github.com/Axway/agent-sdk/pkg/transaction/util"
)

func centralMetricFromAPIMetric(in *APIMetric) *centralMetric {
Expand Down Expand Up @@ -61,7 +64,10 @@ func centralMetricFromAPIMetric(in *APIMetric) *centralMetric {
ID: in.API.ID,
},
Name: in.API.Name,
//TODO find api service ID
}
svc, err := agent.GetAPICache().GetBySecondaryKey(strings.TrimPrefix(in.API.ID, transutil.SummaryEventProxyIDPrefix))
if err == nil {
out.API.APIServiceID = svc.(v1.ResourceInstance).Metadata.ID
}
}

Expand Down

0 comments on commit 86c7e98

Please sign in to comment.