From 44d1ff2b34980344eb8e40e12c71bfe6c26e4dad Mon Sep 17 00:00:00 2001 From: Mayank Pande Date: Sat, 30 Mar 2024 17:42:15 +0530 Subject: [PATCH 1/2] fix: fix for request body capture on failure --- containers/l7.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/containers/l7.go b/containers/l7.go index 2d1c7c50..1695f15b 100644 --- a/containers/l7.go +++ b/containers/l7.go @@ -1,6 +1,7 @@ package containers import ( + "log" "time" "github.com/coroot/coroot-node-agent/common" @@ -69,7 +70,8 @@ func (s L7Stats) get(protocol l7.Protocol, destination, actualDestination netadd labels = append(labels, "method") case l7.ProtocolHTTP: method, path, payload := l7.ParseHttpAndRest(r.Payload) - if r.Status == l7.StatusFailed { + if r.Status.Http() == "400" || r.Status.Http() == "500" { + log.Println("Captured failed request actual body %s, converted body %s, status %s", string(r.Payload), payload, r.Status.Http()) constLabels["payload"] = payload } constLabels["path"] = path From eb1d024689e97fbb7eabe629a59fa3f059e9b2aa Mon Sep 17 00:00:00 2001 From: Mayank Pande Date: Sat, 30 Mar 2024 19:04:18 +0530 Subject: [PATCH 2/2] chore: added ci and fix build --- .github/workflows/dev-ci.yaml | 38 ++++++++++++++++++++++++++++++++++ .github/workflows/prod-ci.yaml | 38 ++++++++++++++++++++++++++++++++++ containers/l7.go | 2 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dev-ci.yaml create mode 100644 .github/workflows/prod-ci.yaml diff --git a/.github/workflows/dev-ci.yaml b/.github/workflows/dev-ci.yaml new file mode 100644 index 00000000..3b2ffb10 --- /dev/null +++ b/.github/workflows/dev-ci.yaml @@ -0,0 +1,38 @@ +name: dev build image +on: + workflow_dispatch: + push: + branches: [ "main" ] + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Create tag name + run: echo "tag=$(date +'%Y-%m-%dT%H-%M-%S')_$GITHUB_SHA" >> $GITHUB_ENV + + - name: Install AWS cli + uses: unfor19/install-aws-cli-action@master + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build and Push Agent Image + uses: docker/build-push-action@v3 + with: + context: . + file: 'Dockerfile' + push: true + tags: | + 280501305789.dkr.ecr.us-east-1.amazonaws.com/nudgebee-node-agent:${{ env.tag }} diff --git a/.github/workflows/prod-ci.yaml b/.github/workflows/prod-ci.yaml new file mode 100644 index 00000000..b83f59bc --- /dev/null +++ b/.github/workflows/prod-ci.yaml @@ -0,0 +1,38 @@ +name: dev build image +on: + workflow_dispatch: + push: + branches: [ "prod" ] + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + + - name: Create tag name + run: echo "tag=$(date +'%Y-%m-%dT%H-%M-%S')_$GITHUB_SHA" >> $GITHUB_ENV + + - name: Install AWS cli + uses: unfor19/install-aws-cli-action@master + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build and Push Agent Image + uses: docker/build-push-action@v3 + with: + context: . + file: 'Dockerfile' + push: true + tags: | + 740395098545.dkr.ecr.us-east-1.amazonaws.com/nudgebee-node-agent:${{ env.tag }} diff --git a/containers/l7.go b/containers/l7.go index 1695f15b..6153616c 100644 --- a/containers/l7.go +++ b/containers/l7.go @@ -71,7 +71,7 @@ func (s L7Stats) get(protocol l7.Protocol, destination, actualDestination netadd case l7.ProtocolHTTP: method, path, payload := l7.ParseHttpAndRest(r.Payload) if r.Status.Http() == "400" || r.Status.Http() == "500" { - log.Println("Captured failed request actual body %s, converted body %s, status %s", string(r.Payload), payload, r.Status.Http()) + log.Printf("Captured failed request actual body %s, converted body %s, status %s", string(r.Payload), payload, r.Status.Http()) constLabels["payload"] = payload } constLabels["path"] = path