Skip to content

Commit

Permalink
fix: skip logfire intialization if inside github workflow (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-ahuja authored Aug 24, 2024
1 parent 2e6a514 commit a6c095e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
APP_ENVIRONMENT: github_workflow

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
S3_BUCKET_NAME: ${{secrets.S3_BUCKET_NAME}}
S3_LOGS_FOLDER: ${{secrets.S3_LOGS_FOLDER}}
REDIS_HOST: localhost
APP_ENVIRONMENT: github_workflow

jobs:
build:
Expand Down
5 changes: 5 additions & 0 deletions src/config/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Settings(BaseSettings):

redis_host: str
redis_password: SecretStr | None = None
app_environment: str


def generate_settings_config(env_location: str | None = None) -> Settings:
Expand All @@ -76,6 +77,10 @@ def generate_settings_config(env_location: str | None = None) -> Settings:
def initialize_logfire_services(app: FastAPI) -> None:
"""Initializes LogFire services by configuring and initializing its client, and registering requisite services."""

# skip as requisite env vars wont be available
if settings.app_environment == "github_workflow":
return

logfire.configure()
logfire.instrument_fastapi(app)
logfire.instrument_redis()
Expand Down

0 comments on commit a6c095e

Please sign in to comment.