From 91afe5e830b44ba7de4e5ca9c91eed56b40fcfde Mon Sep 17 00:00:00 2001 From: orenzhang <41963680+OrenZhang@users.noreply.github.com> Date: Wed, 22 Apr 2026 11:29:50 +0800 Subject: [PATCH 1/2] fix(middleware): exclude health check endpoint from logging --- internal/router/middlewares.go | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/internal/router/middlewares.go b/internal/router/middlewares.go index a709e012..1bad4eed 100644 --- a/internal/router/middlewares.go +++ b/internal/router/middlewares.go @@ -25,13 +25,15 @@ package router import ( + "strconv" + "time" + "github.com/gin-gonic/gin" + "github.com/linux-do/cdk/internal/config" "github.com/linux-do/cdk/internal/logger" "github.com/linux-do/cdk/internal/otel_trace" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" - "strconv" - "time" ) func loggerMiddleware() gin.HandlerFunc { @@ -58,18 +60,22 @@ func loggerMiddleware() gin.HandlerFunc { latency := end.Sub(start) // 打印日志 - logger.InfoF( - ctx, - "[LoggerMiddleware] %s %s\nStartTime: %s\nEndTime: %s\nLatency: %d\nClientIP: %s\nResponse: %d %d", - c.Request.Method, - path, - start.Format(time.RFC3339), - end.Format(time.RFC3339), - latency.Milliseconds(), - c.ClientIP(), - c.Writer.Status(), - c.Writer.Size(), - ) + // 排除健康检查接口 + healthPath := config.Config.App.APIPrefix + "/v1/health" + if c.Request.URL.Path != healthPath { + logger.InfoF( + ctx, + "[LoggerMiddleware] %s %s\nStartTime: %s\nEndTime: %s\nLatency: %d\nClientIP: %s\nResponse: %d %d", + c.Request.Method, + path, + start.Format(time.RFC3339), + end.Format(time.RFC3339), + latency.Milliseconds(), + c.ClientIP(), + c.Writer.Status(), + c.Writer.Size(), + ) + } // 设置 Span 状态 if c.Writer.Status() >= 400 { From 9381b0d585e2622d0272ec32d3a9ba87a9d3b951 Mon Sep 17 00:00:00 2001 From: orenzhang <41963680+OrenZhang@users.noreply.github.com> Date: Wed, 22 Apr 2026 11:30:04 +0800 Subject: [PATCH 2/2] chore(cdk): update image tag paths in build_image.yml --- .github/workflows/build_image.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 9e73530f..3dc64a7b 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -143,12 +143,12 @@ jobs: sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 sudo chmod +x /usr/local/bin/yq - # update image tags in values/cdk.yaml - - name: Update image tags in values/cdk.yaml + # update image tags in values/cdk/cdk.yaml + - name: Update image tags in values/cdk/cdk.yaml run: | cd helm-charts - yq -i '.image.tag = "${{ github.ref_name }}"' values/cdk.yaml - yq -i '.image.webTag = "${{ github.ref_name }}"' values/cdk.yaml + yq -i '.image.tag = "${{ github.ref_name }}"' values/cdk/cdk.yaml + yq -i '.image.webTag = "${{ github.ref_name }}"' values/cdk/cdk.yaml # commit and push to a new branch, then open a PR for review - name: Commit, push and create PR @@ -159,13 +159,13 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git checkout -b update/cdk-${{ github.ref_name }} - git add values/cdk.yaml + git add values/cdk/cdk.yaml git commit -m "chore: update cdk image tag to ${{ github.ref_name }}" git push origin update/cdk-${{ github.ref_name }} HELM_REPO=$(echo "${{ vars.HELM_CHARTS_REPO }}" | sed 's/git@github.com://;s/\.git$//') gh pr create \ --repo "${HELM_REPO}" \ --title "chore: update cdk image tag to ${{ github.ref_name }}" \ - --body "Automated PR: update \`values/cdk.yaml\` image tags to \`${{ github.ref_name }}\` after Docker image build." \ + --body "Automated PR: update \`values/cdk/cdk.yaml\` image tags to \`${{ github.ref_name }}\` after Docker image build." \ --base main \ --head update/cdk-${{ github.ref_name }}