Skip to content

Add log skipper for internal API calls#2255

Merged
cb-github-robot merged 2 commits intocloud-barista:mainfrom
seokho-son:main
Jan 5, 2026
Merged

Add log skipper for internal API calls#2255
cb-github-robot merged 2 commits intocloud-barista:mainfrom
seokho-son:main

Conversation

@seokho-son
Copy link
Copy Markdown
Member

Now CB-TB support log skip patterns for 3 points.

  • INTERNAL CALL LOG SKIP PATTERNS has been added (to reduce verbose internal logs)
  • All skipping patterns will be managed in a common pkg
// ==============================================================================
// REQUEST LOG SKIP PATTERNS
// Used by: Echo middleware (zerologger, request tracker)
// Purpose: Skip logging for high-frequency or utility endpoints
// ==============================================================================

var RequestSkipPatterns = []SkipRule{
	// Swagger/API documentation
	{Patterns: []string{"/tumblebug/api"}},

	// Health check and utility endpoints
	{Patterns: []string{"/tumblebug/readyz"}},
	{Patterns: []string{"/tumblebug/httpVersion"}},
	{Patterns: []string{"/tumblebug/testStreamResponse"}},

	// Request tracking endpoints (avoid recursive logging)
	{Patterns: []string{"/tumblebug/request"}},
	{Patterns: []string{"/tumblebug/requests"}},
}

// ==============================================================================
// API LOG SKIP PATTERNS
// Used by: API call logging middleware
// Purpose: Skip verbose logging for frequently polled or list endpoints
// ==============================================================================

var APISkipPatterns = []SkipRule{
	// Swagger/API documentation
	{Patterns: []string{"/tumblebug/api"}},

	// Health check endpoints
	{Patterns: []string{"/tumblebug/readyz"}},
	{Patterns: []string{"/tumblebug/httpVersion"}},

	// MCI status polling (very frequent) - GET only
	{Method: "GET", Patterns: []string{"/mci", "option=status"}},
	{Method: "GET", Patterns: []string{"/mci"}},

	// Kubernetes cluster operations - GET only
	{Method: "GET", Patterns: []string{"/k8sCluster"}},

	// Resource list operations (frequent polling from UI) - GET only
	{Method: "GET", Patterns: []string{"/resources/vNet"}},
	{Method: "GET", Patterns: []string{"/resources/securityGroup"}},
	{Method: "GET", Patterns: []string{"/resources/vpn"}},
	{Method: "GET", Patterns: []string{"/resources/sshKey"}},
	{Method: "GET", Patterns: []string{"/resources/customImage"}},
	{Method: "GET", Patterns: []string{"/resources/dataDisk"}},
}

// ==============================================================================
// INTERNAL CALL LOG SKIP PATTERNS
// Used by: Internal HTTP client (client.go)
// Purpose: Skip logging for high-frequency internal API calls
// ==============================================================================

var InternalCallSkipPatterns = []SkipRule{
	// Spider registration APIs (high frequency during init/sync) - any method
	{Patterns: []string{"/spider/region"}},
	{Patterns: []string{"/spider/credential"}},
	{Patterns: []string{"/spider/driver"}},
	{Patterns: []string{"/spider/connectionconfig"}},

	// Examples with method filtering:
	// {Method: "GET", Patterns: []string{"/spider/vm", "option=status"}},  // GET VM status only
	// {Method: "POST", Patterns: []string{"/spider/vm"}},                   // POST VM creation
	// {Patterns: []string{"/terrarium/"}},                                  // Any method for terrarium
}

Signed-off-by: Seokho Son <shsongist@gmail.com>
@seokho-son seokho-son requested a review from yunkon-kim as a code owner January 5, 2026 09:43
Copilot AI review requested due to automatic review settings January 5, 2026 09:43
@github-actions github-actions bot added the src label Jan 5, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a centralized log filtering system to reduce verbose logging from internal API calls, refactors service initialization with parallel startup, and improves log message consistency across the codebase.

  • Adds new logfilter package with three types of skip patterns: Request logging, API logging, and Internal call logging
  • Refactors main.go initialization to use concurrent goroutines for waiting on PostgreSQL, CB-Spider, and etcd services
  • Updates all log messages with consistent prefixes (init:, setup:, config:, migrate:, main:) for better traceability

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/core/common/logfilter/patterns.go New package defining centralized log skip patterns with method-aware filtering using SkipRule struct
src/main.go Refactors service initialization to run concurrently, removes unused credentials loading, adds consistent log message prefixes
src/interface/rest/server/server.go Migrates skip patterns to logfilter package, updates pattern matching logic to use SkipRule
src/interface/rest/server/middlewares/zerologger.go Updates middleware to use SkipRule from logfilter package with method-aware filtering
src/core/common/client/client.go Adds shouldSkipInternalCallLog function to filter high-frequency internal API calls from logs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Seokho Son <shsongist@gmail.com>
@seokho-son
Copy link
Copy Markdown
Member Author

@seokho-son
Copy link
Copy Markdown
Member Author

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Jan 5, 2026
@cb-github-robot cb-github-robot merged commit 440c86e into cloud-barista:main Jan 5, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon. src

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants