From ef25b78d850c58e2bde0b2203fce95fdcfd31512 Mon Sep 17 00:00:00 2001 From: Jason Collins Date: Wed, 3 Jan 2024 14:36:29 -0700 Subject: [PATCH 1/3] update the discovery process --- pkg/discovery/gateway/client.go | 6 ++++-- pkg/discovery/gateway/definitions.go | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/discovery/gateway/client.go b/pkg/discovery/gateway/client.go index fd39938..aeed476 100644 --- a/pkg/discovery/gateway/client.go +++ b/pkg/discovery/gateway/client.go @@ -277,7 +277,7 @@ func newKongAPI( } return KongAPI{ - id: *service.Name, + id: *service.ID, name: *service.Name, description: spec.GetDescription(), version: spec.GetVersion(), @@ -286,7 +286,8 @@ func newKongAPI( documentation: []byte(*service.Name), spec: spec.GetSpecBytes(), endpoints: endpoints, - stage: *route.Name, + stageName: *route.Name, + stage: *route.ID, } } @@ -315,6 +316,7 @@ func (ka *KongAPI) buildServiceBody() (apic.ServiceBody, error) { SetServiceAgentDetails(util.MapStringStringToMapStringInterface(ka.agentDetails)). SetServiceAttribute(serviceAttributes). SetStage(ka.stage). + SetStageDisplayName(ka.stageName). SetStageDescriptor("Route"). SetState(apic.PublishedStatus). SetStatus(apic.PublishedStatus). diff --git a/pkg/discovery/gateway/definitions.go b/pkg/discovery/gateway/definitions.go index 824f5af..c3ffe63 100644 --- a/pkg/discovery/gateway/definitions.go +++ b/pkg/discovery/gateway/definitions.go @@ -39,5 +39,6 @@ type KongAPI struct { agentDetails map[string]string tags []string stage string + stageName string ard string } From 00802d9e05f088c3fe9e88af34e00076f5a0143b Mon Sep 17 00:00:00 2001 From: Jason Collins Date: Wed, 3 Jan 2024 15:21:15 -0700 Subject: [PATCH 2/3] use ids for traceability agent --- go.mod | 2 +- go.sum | 4 ++-- pkg/traceability/processor/metrics.go | 15 +++++++++------ pkg/traceability/processor/transaction.go | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 6366126..5864f36 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Axway/agents-kong go 1.18 require ( - github.com/Axway/agent-sdk v1.1.72-0.20240102220515-d0cc4b4fbc8e + github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72 github.com/elastic/beats/v7 v7.17.15 github.com/google/uuid v1.3.1 github.com/kong/go-kong v0.47.0 diff --git a/go.sum b/go.sum index 7070369..b8e5777 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Axway/agent-sdk v1.1.72-0.20240102220515-d0cc4b4fbc8e h1:j2vkONYI4oS13kP0wRJp3hWi/Qqj8V0HYPkrGdwhaks= -github.com/Axway/agent-sdk v1.1.72-0.20240102220515-d0cc4b4fbc8e/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= +github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72 h1:/XTNrz8VTJObq1y5i0tDaznBmSemZiA0jSrMKlXaj+Y= +github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= diff --git a/pkg/traceability/processor/metrics.go b/pkg/traceability/processor/metrics.go index ba6b2ee..041d296 100644 --- a/pkg/traceability/processor/metrics.go +++ b/pkg/traceability/processor/metrics.go @@ -7,7 +7,6 @@ import ( "github.com/Axway/agent-sdk/pkg/traceability/sampling" "github.com/Axway/agent-sdk/pkg/transaction/metric" "github.com/Axway/agent-sdk/pkg/transaction/models" - "github.com/Axway/agent-sdk/pkg/transaction/util" sdkUtil "github.com/Axway/agent-sdk/pkg/transaction/util" "github.com/Axway/agent-sdk/pkg/util/log" ) @@ -34,10 +33,13 @@ func (m *MetricsProcessor) setCollector(collector metricCollector) { func (m *MetricsProcessor) process(entry TrafficLogEntry) (bool, error) { details := sampling.TransactionDetails{} if entry.Response != nil { - details.Status = util.GetTransactionSummaryStatus(entry.Response.Status) + details.Status = sdkUtil.GetTransactionSummaryStatus(entry.Response.Status) } if entry.Service != nil { - details.APIID = entry.Route.ID + details.APIID = entry.Service.ID + if entry.Route != nil { + details.APIID = fmt.Sprintf("%s-%s", entry.Service.ID, entry.Route.ID) + } } if entry.Consumer != nil { details.SubID = entry.Consumer.ID @@ -54,9 +56,10 @@ func (m *MetricsProcessor) process(entry TrafficLogEntry) (bool, error) { func (m *MetricsProcessor) updateMetric(entry TrafficLogEntry) { apiDetails := models.APIDetails{ - ID: entry.Service.Name, - Name: entry.Service.Name, - Stage: entry.Route.Name, + ID: sdkUtil.FormatProxyID(entry.Service.ID), + Name: entry.Service.Name, + Stage: entry.Route.ID, + Revision: 1, } statusCode := entry.Response.Status diff --git a/pkg/traceability/processor/transaction.go b/pkg/traceability/processor/transaction.go index 9c8d122..fe11b3c 100644 --- a/pkg/traceability/processor/transaction.go +++ b/pkg/traceability/processor/transaction.go @@ -134,7 +134,7 @@ func (p *TransactionProcessor) createSummaryEvent(teamID string, txnid string) ( SetTeam(teamID). SetEntryPoint(p.event.Service.Protocol, p.event.Request.Method, p.event.Request.URI, p.event.Request.URL). SetDuration(p.event.Latencies.Request). - SetProxyWithStage(sdkUtil.FormatProxyID(p.event.Service.Name), p.event.Service.Name, p.event.Route.Name, 1) + SetProxyWithStage(sdkUtil.FormatProxyID(p.event.Service.ID), p.event.Service.Name, p.event.Route.ID, 1) if p.event.Consumer != nil { builder.SetApplication(sdkUtil.FormatApplicationID(p.event.Consumer.ID), p.event.Consumer.Username) From 258d62229c5c458684e0cac5d6ee0d4323624381 Mon Sep 17 00:00:00 2001 From: Jason Collins Date: Wed, 3 Jan 2024 15:43:59 -0700 Subject: [PATCH 3/3] update dep --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5864f36..9284d50 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Axway/agents-kong go 1.18 require ( - github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72 + github.com/Axway/agent-sdk v1.1.72-0.20240103224310-c9edbdc66989 github.com/elastic/beats/v7 v7.17.15 github.com/google/uuid v1.3.1 github.com/kong/go-kong v0.47.0 diff --git a/go.sum b/go.sum index b8e5777..13b5240 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72 h1:/XTNrz8VTJObq1y5i0tDaznBmSemZiA0jSrMKlXaj+Y= -github.com/Axway/agent-sdk v1.1.72-0.20240103170931-9a7231485d72/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= +github.com/Axway/agent-sdk v1.1.72-0.20240103224310-c9edbdc66989 h1:ptdjxNICx+Ftau9usJbKdI0MHxpG2tjgzmW6X+MNhlc= +github.com/Axway/agent-sdk v1.1.72-0.20240103224310-c9edbdc66989/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw=