-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APIGOV-28931 - custom unit ingestion and refactoring of metric storag…
…e/sending (#843) * udpates for custom unit metric ingestion * get event id from v4Event during acking * set status in metric * use pointers in metric event sent to central * code cleanup * add additional methods to get resource reference information * fix get key method * update to use counter for custom metrics * cleanup * add test for sending custom usage metrics * add name for generator docker container * resource generate * update models * APIGOV-28931 - fix generator * get product plan unit ref * use the plan unit ref while handing metrics
- Loading branch information
1 parent
5d14643
commit 5bcf075
Showing
40 changed files
with
858 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
pkg/apic/apiserver/models/catalog/v1alpha1/model_subscription_invoice_references.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* API Server specification. | ||
* | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* API version: SNAPSHOT | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package catalog | ||
|
||
// SubscriptionInvoiceReferences (catalog.v1alpha1.SubscriptionInvoice) | ||
type SubscriptionInvoiceReferences struct { | ||
// Reference to product. | ||
Product string `json:"product,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
pkg/apic/apiserver/models/management/v1alpha1/model_access_request_spec_additional_quotas.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* API Server specification. | ||
* | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* API version: SNAPSHOT | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package management | ||
|
||
// AccessRequestSpecAdditionalQuotas Quota information for accessing the api. (management.v1alpha1.AccessRequest) | ||
type AccessRequestSpecAdditionalQuotas struct { | ||
// The logical name of the quota | ||
Name string `json:"name"` | ||
// The limit of the allowed quota for the access request. | ||
Limit int32 `json:"limit,omitempty"` | ||
// The interval for the applied quota. | ||
Interval string `json:"interval,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package metric | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/Axway/agent-sdk/pkg/transaction/models" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// APIMetric - struct to hold metric aggregated for subscription,application,api,statuscode | ||
type APIMetric struct { | ||
Subscription models.Subscription `json:"subscription,omitempty"` | ||
App models.AppDetails `json:"application,omitempty"` | ||
Product models.Product `json:"product,omitempty"` | ||
API models.APIDetails `json:"api"` | ||
AssetResource models.AssetResource `json:"assetResource,omitempty"` | ||
ProductPlan models.ProductPlan `json:"productPlan,omitempty"` | ||
Quota models.Quota `json:"quota,omitempty"` | ||
Unit models.Unit `json:"unit,omitempty"` | ||
StatusCode string `json:"statusCode,omitempty"` | ||
Status string `json:"status,omitempty"` | ||
Count int64 `json:"count"` | ||
Response ResponseMetrics `json:"response,omitempty"` | ||
Observation ObservationDetails `json:"observation"` | ||
EventID string `json:"-"` | ||
StartTime time.Time `json:"-"` | ||
} | ||
|
||
// GetStartTime - Returns the start time for subscription metric | ||
func (a *APIMetric) GetStartTime() time.Time { | ||
return a.StartTime | ||
} | ||
|
||
// GetType - Returns APIMetric | ||
func (a *APIMetric) GetType() string { | ||
return "APIMetric" | ||
} | ||
|
||
// GetType - Returns APIMetric | ||
func (a *APIMetric) GetEventID() string { | ||
return a.EventID | ||
} | ||
|
||
func (a *APIMetric) GetLogFields() logrus.Fields { | ||
fields := logrus.Fields{ | ||
"id": a.EventID, | ||
"count": a.Count, | ||
"status": a.StatusCode, | ||
"minResponse": a.Response.Min, | ||
"maxResponse": a.Response.Max, | ||
"avgResponse": a.Response.Avg, | ||
"startTimestamp": a.Observation.Start, | ||
"endTimestamp": a.Observation.End, | ||
} | ||
fields = a.Subscription.GetLogFields(fields) | ||
fields = a.App.GetLogFields(fields) | ||
fields = a.Product.GetLogFields(fields) | ||
fields = a.API.GetLogFields(fields) | ||
fields = a.AssetResource.GetLogFields(fields) | ||
fields = a.ProductPlan.GetLogFields(fields) | ||
fields = a.Quota.GetLogFields(fields) | ||
return fields | ||
} |
Oops, something went wrong.