Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Fix/logs and metrics#357

Merged
nxtcoder17 merged 4 commits into
release-v1.0.7from
fix/logs-and-metrics
Jul 29, 2024
Merged

Fix/logs and metrics#357
nxtcoder17 merged 4 commits into
release-v1.0.7from
fix/logs-and-metrics

Conversation

@nxtcoder17
Copy link
Copy Markdown
Member

@nxtcoder17 nxtcoder17 commented Jul 29, 2024

closes kloudlite/kloudlite#260

Summary by Sourcery

This pull request introduces a new HTTP logger with enhanced customization options, adds a health check endpoint to the observability API, and refactors several components for improved logging and configuration. It also includes updates to the build and CI workflows to support the new 'gateway-kube-proxy' target, and removes the deprecated 'pod-logs-proxy' command.

  • New Features:
    • Introduced a new HTTP logger with customizable options for showing query parameters, headers, and silent paths.
    • Added a new logging response writer to capture HTTP response status codes and flush responses.
    • Implemented a health check endpoint in the observability API.
  • Bug Fixes:
    • Fixed the DNS configuration in WireGuard parameters to conditionally include the DNS setting based on a new 'WithDNS' flag.
  • Enhancements:
    • Refactored the HTTP logger to use the 'slog' package instead of 'zerolog'.
    • Updated the Kloudlite banner to include a 'Built At' timestamp and improved formatting.
    • Modified the observability API to log the start of the HTTP server with the port number.
    • Changed the 'defaultValue' and 'RawMessage' fields in the GraphQL models to use 'any' instead of 'interface{}'.
  • Build:
    • Added a new build target for 'gateway-kube-proxy' in the GitHub Actions workflow.
    • Updated the Taskfile for 'gateway-kube-proxy' to include Docker build and push steps.
  • CI:
    • Enhanced the GitHub Actions workflow to include caching for the 'gateway-kube-proxy' build.
  • Chores:
    • Deleted the 'pod-logs-proxy' command and its associated Taskfile.

@nxtcoder17 nxtcoder17 self-assigned this Jul 29, 2024
@nxtcoder17 nxtcoder17 requested a review from karthik1729 as a code owner July 29, 2024 08:41
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 29, 2024

Reviewer's Guide by Sourcery

This pull request focuses on improving logging and metrics by replacing zerolog with slog, adding configurable logging options, and integrating new middleware. It also updates banner printing functions, adds build configurations for gateway-kube-proxy, and refactors type definitions for better type safety and readability. Additionally, it introduces a health check endpoint and a debug flag for logging configuration.

File-Level Changes

Files Changes
pkg/logging/http-logger.go
cmd/gateway-kube-proxy/main.go
Replaced zerolog with slog for logging and integrated new HttpLogger middleware.
common/banner.go
cmd/gateway-kube-proxy/main.go
Updated banner constants and printing functions.
.github/actions/build-api-images/action.yml
cmd/gateway-kube-proxy/Taskfile.yml
Added build configuration for gateway-kube-proxy and updated Taskfile includes.
apps/infra/internal/app/graph/model/models_gen.go
apps/infra/internal/app/graph/schema.resolvers.go
Refactored type definitions for better type safety and readability.
apps/observability/internal/framework/framework.go
apps/observability/main.go
Added health check endpoint and debug flag for logging configuration.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @nxtcoder17 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The improvements to the logging system, especially the switch to slog and the enhanced HTTP logging, are commendable. This should improve observability and debugging capabilities.
  • Please provide an explanation for the removal of the pod-logs-proxy component. It's a significant change that should be documented in the PR description.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

route = fmt.Sprintf("%s?%s", route, r.URL.RawQuery)
}

h.Logger.Info(fmt.Sprintf("❯❯ %s %s", r.Method, route))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (performance): Consider using structured logging instead of fmt.Sprintf for better performance

Using structured logging with slog would be more efficient and provide better log output for parsing. For example: h.Logger.Info("incoming request", "method", r.Method, "route", route)

Suggested change
h.Logger.Info(fmt.Sprintf("❯❯ %s %s", r.Method, route))
h.Logger.Info("incoming request", "method", r.Method, "route", route)

Comment thread cmd/gateway-kube-proxy/main.go Outdated
SilentPaths: []string{},
})
r.Use(httpLogger.Use)
_ = middleware.Logger
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Remove or explain the commented-out middleware.Logger line

If the middleware.Logger is no longer needed, consider removing this line entirely. If it's kept for future reference, add a comment explaining why it's commented out and when it might be used.

Suggested change
_ = middleware.Logger
// _ = middleware.Logger
// The middleware.Logger line is commented out for future reference.
// It might be used for logging HTTP requests in the future if needed.

save-always: true
restore-keys: go-${{ runner.os }}-gateway-kube-proxy-

- name: gateway logs proxy
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Use more descriptive names for GitHub Actions steps

Consider using more descriptive names for the steps, especially for the new gateway kube proxy steps. For example, 'Build and push gateway kube proxy image' would be clearer than 'gateway logs proxy'.

Suggested change
- name: gateway logs proxy
- name: Build and push gateway kube proxy image

@nxtcoder17 nxtcoder17 force-pushed the fix/logs-and-metrics branch from a7be00b to c157e0a Compare July 29, 2024 08:52
@nxtcoder17 nxtcoder17 merged commit d8716d9 into release-v1.0.7 Jul 29, 2024
@nxtcoder17 nxtcoder17 deleted the fix/logs-and-metrics branch July 29, 2024 08:53
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Logs & Metrics are not working

1 participant