Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
34 changes: 20 additions & 14 deletions internal/router/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Loading