Skip to content

feat: add Mezmo provider#6250

Open
theshahnawazali wants to merge 4 commits intokeephq:mainfrom
theshahnawazali:MezmoProvider
Open

feat: add Mezmo provider#6250
theshahnawazali wants to merge 4 commits intokeephq:mainfrom
theshahnawazali:MezmoProvider

Conversation

@theshahnawazali
Copy link
Copy Markdown

@theshahnawazali theshahnawazali commented Apr 14, 2026

Closes #1838

📑 Description

This PR adds support for a Mezmo (LogDNA) logging provider.

Changes:

  • Added Mezmo provider integration
  • Implemented environment-based configuration using MEZMO_INGESTION_KEY
  • Added validation for missing/empty ingestion key
  • Added graceful fallback to console logging when key is not provided
  • Followed existing logging provider structure

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

  • Requires logdna package for Mezmo integration
  • Users must set the environment variable:
    MEZMO_INGESTION_KEY
  • If the key is not set, the logger falls back to default console logging
  • No breaking changes introduced

Note

Medium Risk
Introduces new logging initialization and an optional external logdna handler controlled by environment configuration, which can affect runtime logging behavior and startup if misconfigured or dependencies are missing.

Overview
Adds a new MezmoProvider under keep/providers/mezmo_provider to configure the keep logger via logging.config.dictConfig, always logging to stdout and optionally adding a Mezmo/LogDNA handler when MEZMO_INGESTION_KEY is present.

Includes dotenv-based env loading plus a small __main__ validation path for missing/empty ingestion keys, with a fallback warning when the logdna package isn’t installed.

Reviewed by Cursor Bugbot for commit 91e8e07. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Feature A new feature Provider Providers related issues labels Apr 14, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 91e8e07. Configure here.

"""

def __init__(self, mezmo_key: str = "Keep", app: str = "Keep", env: str = "production", hostname: str = "keep-server"):
self.mezmo_key = MEZMO_INGESTION_KEY
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Undefined variable MEZMO_INGESTION_KEY causes NameError on instantiation

High Severity

self.mezmo_key = MEZMO_INGESTION_KEY references a variable that only exists inside the if __name__ == "__main__": block, so it's undefined at module scope. Any normal instantiation of MezmoProvider (e.g. when imported by the provider framework) will raise a NameError. The mezmo_key constructor parameter is accepted but never used, compounding the issue.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 91e8e07. Configure here.

}
logging_config["loggers"]["keep"]["handlers"].append("mezmo")
except ImportError:
logging.warning("logdna package not installed")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

try/except ImportError can never catch dictionary construction

Medium Severity

The try/except ImportError wraps pure dictionary construction, which can never raise an ImportError. The actual import of logdna.LogDNAHandler happens later inside logging.config.dictConfig() in _setup_logger, which is outside this handler. If logdna is missing, the error will propagate unhandled instead of falling back to console logging as intended.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 91e8e07. Configure here.

logger.info("Hello from Keep!")
"""

def __init__(self, mezmo_key: str = "Keep", app: str = "Keep", env: str = "production", hostname: str = "keep-server"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Default mezmo_key parameter value is "Keep" not None

Low Severity

The mezmo_key parameter defaults to "Keep", which appears to be a copy-paste error from the app parameter. This would always be truthy, defeating the fallback-to-console behavior described in the PR. The default likely needs to be None so the if self.mezmo_key: check in _build_config can correctly skip the Mezmo handler when no key is provided.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 91e8e07. Configure here.

if not MEZMO_INGESTION_KEY:
raise ValueError("Mezmo ingestion key is empty!")
except NameError:
raise ValueError("MEZMO_INGESTION_KEY is not defined!")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreachable except NameError due to prior assignment

Low Severity

The except NameError handler on lines 94–95 is unreachable dead code. MEZMO_INGESTION_KEY is unconditionally assigned on line 88 via os.environ.get(...), so it will always be defined (as None or a string) by the time the try block on line 91 executes. A NameError can never occur here, making the fallback error message misleading and the branch dead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 91e8e07. Configure here.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@theshahnawazali
Copy link
Copy Markdown
Author

Thanks for the review! I've addressed all the reported issues:

  • Fixed MEZMO_INGESTION_KEY handling
  • Corrected default parameter value
  • Added proper dependency check for logdna
  • Removed unreachable code

Please let me know if any further changes are needed 🙂

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature A new feature Provider Providers related issues size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🔌 Provider]: Add Mezmo provider

2 participants