Skip to content

Commit

Permalink
fix(infra/staging): Add INFLUXDB_BUCKET to task def (#3199)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
  • Loading branch information
gagantrivedi and matthewelwell authored Jan 3, 2024
1 parent de3f73d commit 445dc2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 17 additions & 15 deletions api/app/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,10 @@

MAX_PROJECTS_IN_FREE_PLAN = 1

# Google Analytics Configuration
GOOGLE_ANALYTICS_KEY = env("GOOGLE_ANALYTICS_KEY", default="")
GOOGLE_SERVICE_ACCOUNT = env("GOOGLE_SERVICE_ACCOUNT", default=None)
GA_TABLE_ID = env("GA_TABLE_ID", default=None)

INFLUXDB_TOKEN = env.str("INFLUXDB_TOKEN", default="")
INFLUXDB_BUCKET = env.str("INFLUXDB_BUCKET", default="")
INFLUXDB_URL = env.str("INFLUXDB_URL", default="")
INFLUXDB_ORG = env.str("INFLUXDB_ORG", default="")

ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=[])
USE_X_FORWARDED_HOST = env.bool("USE_X_FORWARDED_HOST", default=False)

USE_POSTGRES_FOR_ANALYTICS = env.bool("USE_POSTGRES_FOR_ANALYTICS", default=False)

CSRF_TRUSTED_ORIGINS = env.list("DJANGO_CSRF_TRUSTED_ORIGINS", default=[])

Expand Down Expand Up @@ -288,17 +278,29 @@
# ref: https://docs.djangoproject.com/en/2.2/ref/middleware/#middleware-ordering
MIDDLEWARE.insert(1, "django.middleware.gzip.GZipMiddleware")

# Google Analytics Configuration
GOOGLE_ANALYTICS_KEY = env("GOOGLE_ANALYTICS_KEY", default="")
GOOGLE_SERVICE_ACCOUNT = env("GOOGLE_SERVICE_ACCOUNT", default=None)
GA_TABLE_ID = env("GA_TABLE_ID", default=None)

if GOOGLE_ANALYTICS_KEY:
MIDDLEWARE.append("app_analytics.middleware.GoogleAnalyticsMiddleware")

if INFLUXDB_TOKEN:
MIDDLEWARE.append("app_analytics.middleware.InfluxDBMiddleware")
# Influx configuration
INFLUXDB_TOKEN = env.str("INFLUXDB_TOKEN", default="")
INFLUXDB_BUCKET = env.str("INFLUXDB_BUCKET", default="")
INFLUXDB_URL = env.str("INFLUXDB_URL", default="")
INFLUXDB_ORG = env.str("INFLUXDB_ORG", default="")

if USE_POSTGRES_FOR_ANALYTICS:
if INFLUXDB_BUCKET:
raise RuntimeError("Cannot use both InfluxDB and Postgres for analytics")
USE_POSTGRES_FOR_ANALYTICS = env.bool("USE_POSTGRES_FOR_ANALYTICS", default=False)

# NOTE: Because we use Postgres for analytics data in staging and Influx for tracking SSE data,
# we need to support setting the influx configuration alongside using postgres for analytics.
if USE_POSTGRES_FOR_ANALYTICS:
MIDDLEWARE.append("app_analytics.middleware.APIUsageMiddleware")
elif INFLUXDB_TOKEN:
MIDDLEWARE.append("app_analytics.middleware.InfluxDBMiddleware")


ALLOWED_ADMIN_IP_ADDRESSES = env.list("ALLOWED_ADMIN_IP_ADDRESSES", default=list())
if len(ALLOWED_ADMIN_IP_ADDRESSES) > 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
"name": "INFLUXDB_ORG",
"value": "ben.rometsch@bullet-train.io"
},
{
"name": "INFLUXDB_BUCKET",
"value": "api_staging"
},
{
"name": "INFLUXDB_URL",
"value": "https://eu-central-1-1.aws.cloud2.influxdata.com"
Expand Down

3 comments on commit 445dc2b

@vercel
Copy link

@vercel vercel bot commented on 445dc2b Jan 3, 2024

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 445dc2b Jan 3, 2024

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 445dc2b Jan 3, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs – ./docs

docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.flagsmith.com
docs.bullet-train.io

Please sign in to comment.