Skip to content

Commit

Permalink
🐛(project) fix version fetching in Sentry integration
Browse files Browse the repository at this point in the history
Depending on the way QualiCharge is installed, the package version may
not be available using importlib.metadata module. Let's use a less
elegant but explicit way to declare/fetch project's version.
  • Loading branch information
jmaupetit committed May 29, 2024
1 parent 8e29beb commit c9c3260
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/api/qualicharge/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""QualiCharge package root."""

__version__ = "0.6.0"
4 changes: 2 additions & 2 deletions src/api/qualicharge/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""QualiCharge API root."""

import importlib.metadata
from contextlib import asynccontextmanager

import sentry_sdk
Expand All @@ -9,6 +8,7 @@
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.starlette import StarletteIntegration

from .. import __version__
from ..conf import settings
from ..db import get_engine
from .v1 import app as v1
Expand All @@ -25,7 +25,7 @@ async def lifespan(app: FastAPI):
dsn=str(settings.SENTRY_DSN),
enable_tracing=True,
traces_sample_rate=settings.SENTRY_TRACES_SAMPLE_RATE,
release=importlib.metadata.version("qualicharge"),
release=__version__,
environment=settings.EXECUTION_ENVIRONMENT,
integrations=[
StarletteIntegration(),
Expand Down

0 comments on commit c9c3260

Please sign in to comment.