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

Add Driver Info into the MongoClient #210

Merged
merged 2 commits into from
Jan 7, 2025
Merged

Add Driver Info into the MongoClient #210

merged 2 commits into from
Jan 7, 2025

Conversation

Jibola
Copy link
Collaborator

@Jibola Jibola commented Jan 7, 2025

No description provided.

Copy link
Collaborator

@timgraham timgraham left a comment

Choose a reason for hiding this comment

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

Do we need a setting to let users disable telemetry? Should we disable telemetry during development of this library (i.e. running the Django test suite). Two things I've done in other backends: https://github.com/cockroachdb/django-cockroachdb/blob/00c9e2a13adb00a6f89d0eda725d675238e4611e/django_cockroachdb/base.py#L64-L67

return MongoClient(**conn_params, driver=self._driver_info())

def _driver_info(self):
return DriverInfo("django-mongodb", metadata.version("django-mongodb"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than using importlib.metadata you could use from . import __version__ as django_mongodb_version (this is what I used in other libraries).

return MongoClient(**conn_params)
return MongoClient(**conn_params, driver=self._driver_info())

def _driver_info(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it need to be a separate method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, but I like the separation is all.

@Jibola
Copy link
Collaborator Author

Jibola commented Jan 7, 2025

Do we need a setting to let users disable telemetry? Should we disable telemetry during development of this library (i.e. running the Django test suite). Two things I've done in other backends: https://github.com/cockroachdb/django-cockroachdb/blob/00c9e2a13adb00a6f89d0eda725d675238e4611e/django_cockroachdb/base.py#L64-L67

That's a good idea. I'll add an env flag check.

As a general FYI, In other repos we don't make it optional.

@Jibola Jibola merged commit 082f12d into main Jan 7, 2025
11 checks passed
@timgraham timgraham deleted the driver-info branch January 8, 2025 19:00
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.

2 participants