Skip to content

Add environment info#1928

Draft
hmpf wants to merge 4 commits into
mainfrom
add-environment-info
Draft

Add environment info#1928
hmpf wants to merge 4 commits into
mainfrom
add-environment-info

Conversation

@hmpf

@hmpf hmpf commented May 7, 2026

Copy link
Copy Markdown
Contributor

Scope and purpose

Should probably be merged after #1927, #1929.

Adds the django string setting "ENVIRONMENT" and makes it available to logs. via a log filter -or- a log formatter.

"ENVIRONMENT" is be default set to "environment-unset".

If set to "blbl" and made visible in a log format string, e.g. via:

{
    "formatters": {
        "environment": {
            "()": "argus.logging.formatters.EnvironmentFormatter",
            "format": "{environment} {levelname} {message}",
            "style": "{",
        },
}

then every single log message will start with "blbl ":

LOG.debug("foo")` -> "blbl DEBUG foo"

unless "environment" is passed in via the extra-parameter:

LOG.debug("foo", extra={"environment": "blapp"})` -> "blapp DEBUG foo"

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation, including updates to the user manual if feature flow or UI is considerably changed
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this results in changes to the database model: Updated the ER diagram

hmpf added 2 commits May 7, 2026 09:25
This may be used to enrich for instance logs and is a slug (string
without whitespace) that defaults to "environment-unset". It can be
overridden via the environment variable "ARGUS_ENVIRONMENT".

When running in development this could be set to for instance "dev" or
"localhost". When running in production it could be automatically set by
the deployment system, to an ip-address or hostname for instance.
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

Test results

    8 files  1 712 suites   3m 8s ⏱️
  933 tests   932 ✅ 1 💤 0 ❌
7 464 runs  7 456 ✅ 8 💤 0 ❌

Results for commit 6a8a177.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.22%. Comparing base (7c04efb) to head (6a8a177).

Files with missing lines Patch % Lines
src/argus/logging/formatters.py 0.00% 20 Missing ⚠️
src/argus/logging/filters.py 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1928      +/-   ##
==========================================
- Coverage   88.60%   88.22%   -0.39%     
==========================================
  Files         146      148       +2     
  Lines        7093     7124      +31     
==========================================
  Hits         6285     6285              
- Misses        808      839      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hmpf hmpf marked this pull request as draft May 7, 2026 13:29
@hmpf hmpf added new setting Needs a new setting in settings.py, possibly with validator logging labels May 7, 2026
@hmpf hmpf requested a review from a team May 7, 2026 13:29
@hmpf hmpf self-assigned this May 8, 2026
@hmpf hmpf added documentation Improvements or additions to documentation production Anything especially useful when running in production. labels May 8, 2026
@hmpf hmpf force-pushed the add-environment-info branch from ff8176c to 6a8a177 Compare May 8, 2026 10:01
@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

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

Labels

documentation Improvements or additions to documentation logging new setting Needs a new setting in settings.py, possibly with validator production Anything especially useful when running in production.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant