Skip to content

Conversation

@pquerna
Copy link
Contributor

@pquerna pquerna commented Jun 29, 2025

  • in our graph expansion code, in several places, we log the entire graph using a zap.Any.
  • This is a data-structure of unbounded size. Often many megabytes. That's not nice -- even at debug levels.

Summary by CodeRabbit

  • Chores
    • Reduced verbosity of debug logs by removing detailed graph data from log messages during grant expansion processes.

@pquerna pquerna changed the title Don't log entire grpah Don't log entire graph Jun 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 29, 2025

Walkthrough

The changes remove detailed entitlement graph objects from debug log statements in the syncer type's grant expansion methods. Only the log messages remain, reducing log verbosity without altering any logic, error handling, or control flow in the affected methods.

Changes

File(s) Change Summary
pkg/sync/syncer.go Removed logging of the full entitlement graph object from debug logs in grant expansion methods

Sequence Diagram(s)

Possibly related PRs

Suggested reviewers

  • jirwin

Poem

In the warren of logs, a rabbit did see,
Too much graph clutter, as busy as can be.
With a hop and a trim, the logs now are neat,
Debugging is lighter, a streamlined feat!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pquerna pquerna requested review from Copilot and ggreer June 29, 2025 04:08
Copy link

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 aims to reduce the overhead of logging by removing the logging of entire graph data structures in debug and error messages.

  • Removed logging of potentially large graph objects in several functions.
  • Updated debug and error log statements to improve performance and reduce log noise.

// Peek the next action on the stack
if len(graph.Actions) == 0 {
l.Debug("runGrantExpandActions: no actions", zap.Any("graph", graph))
l.Debug("runGrantExpandActions: no actions") // zap.Any("graph", graph),
Copy link

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

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

The commented out zap.Any parameter can be removed if it is no longer needed for debugging, to help avoid confusion and improve code clarity.

Suggested change
l.Debug("runGrantExpandActions: no actions") // zap.Any("graph", graph),
l.Debug("runGrantExpandActions: no actions")

Copilot uses AI. Check for mistakes.
Comment on lines +2587 to +2593
l.Debug("expandGrantsForEntitlements: graph is expanded") // zap.Any("graph", graph)
s.state.FinishAction(ctx)
return nil
}

graph.Depth++
l.Debug("expandGrantsForEntitlements: graph is not expanded", zap.Any("graph", graph))
l.Debug("expandGrantsForEntitlements: graph is not expanded") // zap.Any("graph", graph)
Copy link

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

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

Eliminate the commented out zap.Any field to keep the code clean and maintainable if no additional debug information is needed.

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
pkg/sync/syncer.go (2)

2335-2336: Delete commented-out zap.Any("graph", …) to avoid dead code

The payload has already been removed from the structured log call, but the commented argument fragments remain.
They don’t compile-break, yet they count as dead code and noisily remain in every git blame.

-    l.Debug("runGrantExpandActions: no actions") // zap.Any("graph", graph),
+    l.Debug("runGrantExpandActions: no actions")

Apply the same surgical removal to the other four occurrences to keep the file tidy.
No functional change – pure cleanup.

Also applies to: 2524-2525, 2551-2552, 2587-2588, 2593-2594


2548-2554: Consider logging light-weight graph stats instead of nothing

Now that the full graph is suppressed, the “exceeded max depth” branch only carries depth.
Including cheap metrics such as len(graph.Edges) or len(graph.GetEntitlements()) would still be O(1) but far more actionable when debugging.

l.Error("expandGrantsForEntitlements: exceeded max depth",
        zap.Int("edges", len(graph.Edges)),
        zap.Int("entitlements", len(graph.GetEntitlements())),
        zap.Int64("max_depth", maxDepth),
)

Keeps logs small while preserving the context that engineers previously relied on when the entire graph was dumped.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b34e09a and 2e06ff5.

📒 Files selected for processing (1)
  • pkg/sync/syncer.go (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
pkg/sync/syncer.go (2)
Learnt from: ggreer
PR: ConductorOne/baton-sdk#194
File: pkg/uhttp/gocache.go:125-132
Timestamp: 2024-07-30T19:21:37.891Z
Learning: Errors when clearing the cache in the `GoCache` struct are logged later in the process, so additional logging in the `Clear` method is unnecessary and would cause log spam.
Learnt from: ggreer
PR: ConductorOne/baton-sdk#194
File: pkg/uhttp/gocache.go:125-132
Timestamp: 2024-10-08T21:29:30.695Z
Learning: Errors when clearing the cache in the `GoCache` struct are logged later in the process, so additional logging in the `Clear` method is unnecessary and would cause log spam.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: go-test (1.23.x, windows-latest)

@pquerna pquerna merged commit 9e5fea0 into main Jun 29, 2025
5 checks passed
@pquerna pquerna deleted the pq/dont_log_whole_graph branch June 29, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants