Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instrumentation): adopt slog #6907

Merged
merged 2 commits into from
Jan 24, 2025
Merged

feat(instrumentation): adopt slog #6907

merged 2 commits into from
Jan 24, 2025

Conversation

grandwizard28
Copy link
Collaborator

@grandwizard28 grandwizard28 commented Jan 22, 2025

Summary

feat(instrumentation): adopt slog

Related Issues / PR's


Important

Adopt slog for logging across the codebase, replacing zap, updating configurations, and adding structured logging with trace correlation.

  • Logging:
    • Replace zap with slog for logging in pkg/errors/errors.go, pkg/factory/setting.go, pkg/instrumentation/instrumentation.go, pkg/sqlmigrator/migrator.go, and pkg/sqlstore/sqlitesqlstore/provider.go.
    • Add LogValue() method to base struct in pkg/errors/errors.go for structured logging.
    • Implement NewLogger() in pkg/instrumentation/logger.go to create slog logger with JSON handler.
    • Add correlation log handler in pkg/instrumentation/loghandler/correlation.go to include trace and span IDs in logs.
  • Configuration:
    • Update LogsConfig in pkg/instrumentation/config.go to use slog.Level.
    • Modify example.yaml to remove enabled field from logs and add comments for clarity.
  • Dependencies:
    • Update go.mod and go.sum to include slog and update related dependencies.
  • Testing:
    • Add TestNewWithEnvProvider in pkg/instrumentation/config_test.go to validate configuration loading from environment variables.
    • Add TestCorrelation in pkg/instrumentation/loghandler/correlation_test.go to test log correlation with trace and span IDs.

This description was created by Ellipsis for ed2012c. It will automatically update as commits are pushed.

@github-actions github-actions bot added the enhancement New feature or request label Jan 22, 2025
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to ed2012c in 1 minute and 40 seconds

More details
  • Looked at 908 lines of code in 16 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/errors/errors.go:35
  • Draft comment:
    Consider using slog.Strings instead of slog.Any for the additional field if it always contains strings.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The LogValue method in the base struct uses slog.Any for the additional field, which is an array of strings. This is correct as it allows for flexibility in logging different types of data, but it's worth noting that if the array is always strings, slog.Strings could be used for clarity.
2. pkg/factory/setting.go:45
  • Draft comment:
    Ensure that the Logger method returns a non-nil logger to avoid potential nil pointer dereferences.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    The Logger method in the scoped struct returns a pointer to slog.Logger, which is consistent with the rest of the codebase. No issues here.
3. pkg/instrumentation/logger.go:19
  • Draft comment:
    slog.SetLogLoggerLevel is not a standard method in the slog package. Ensure this is a valid method or replace it with the correct one.
  • Reason this comment was not posted:
    Comment did not seem useful.
4. pkg/instrumentation/instrumentationtest/instrumentation.go:24
  • Draft comment:
    Avoid using inline styles in React components. Instead, use external stylesheets, CSS classes, or styled components.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_5Fns5CMUjL0Pna6u


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Member

@nityanandagohain nityanandagohain left a comment

Choose a reason for hiding this comment

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

minor comments

pkg/instrumentation/loghandler/correlation.go Show resolved Hide resolved
conf/example.yaml Show resolved Hide resolved
@grandwizard28 grandwizard28 enabled auto-merge (squash) January 24, 2025 09:16
@grandwizard28 grandwizard28 merged commit 001122d into main Jan 24, 2025
15 checks passed
@grandwizard28 grandwizard28 deleted the instrumentation-fixes branch January 24, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants