diff --git a/.freeleaps/devops/helm-pkg/templates/authentication-config.yaml b/.freeleaps/devops/helm-pkg/templates/authentication-config.yaml index b92f984..771460a 100644 --- a/.freeleaps/devops/helm-pkg/templates/authentication-config.yaml +++ b/.freeleaps/devops/helm-pkg/templates/authentication-config.yaml @@ -18,4 +18,6 @@ data: MONGODB_PORT: {{ .Values.authentication.configs.mongodbPort | toString | b64enc }} METRICS_ENABLED: {{ .Values.authentication.configs.metricsEnabled | default false | toString | b64enc }} PROBES_ENABLED: {{ .Values.authentication.configs.probesEnabled | default false | toString | b64enc }} + FREELEAPS_PRODUCT_ID: { { .Values.authentication.configs.freeleapsProductId | b64enc | quote } } + ENVIRONMENT: { { .Values.authentication.configs.environment | b64enc | quote } } \ No newline at end of file diff --git a/.freeleaps/devops/helm-pkg/values.alpha.yaml b/.freeleaps/devops/helm-pkg/values.alpha.yaml index 067bb57..f83ee6c 100644 --- a/.freeleaps/devops/helm-pkg/values.alpha.yaml +++ b/.freeleaps/devops/helm-pkg/values.alpha.yaml @@ -15,7 +15,7 @@ authentication: registry: docker.io repository: null name: 6901bcf4ed3725f39f11343d-authentication - tag: snapshot-ddcf8d8 + tag: snapshot-e6b358e imagePullPolicy: IfNotPresent ports: - name: http @@ -89,6 +89,8 @@ authentication: mongodbPort: 27017 metricsEnabled: 'false' probesEnabled: 'true' + freeleapsProductId: 6901bcf4ed3725f39f11343d + environment: alpha secrets: secretStoreRef: kind: FreeleapsSecretStore diff --git a/.freeleaps/devops/helm-pkg/values.prod.yaml b/.freeleaps/devops/helm-pkg/values.prod.yaml index a3852c7..8bb2150 100644 --- a/.freeleaps/devops/helm-pkg/values.prod.yaml +++ b/.freeleaps/devops/helm-pkg/values.prod.yaml @@ -18,7 +18,7 @@ authentication: registry: docker.io repository: null name: 6901bcf4ed3725f39f11343d-authentication - tag: snapshot-8584f90 + tag: snapshot-9a7fa21 imagePullPolicy: IfNotPresent ports: - name: http @@ -97,6 +97,8 @@ authentication: mongodbPort: 27017 metricsEnabled: 'true' probesEnabled: 'true' + freeleapsProductId: 6901bcf4ed3725f39f11343d + environment: prod secrets: secretStoreRef: kind: FreeleapsSecretStore diff --git a/.freeleaps/devops/helm-pkg/values.yaml b/.freeleaps/devops/helm-pkg/values.yaml index 68ccf39..1586b3f 100644 --- a/.freeleaps/devops/helm-pkg/values.yaml +++ b/.freeleaps/devops/helm-pkg/values.yaml @@ -82,6 +82,8 @@ authentication: metricsEnabled: "false" # PROBES_ENABLED probesEnabled: "false" + freeleapsProductId: "" + environment: alpha # AKV secrets configuration secrets: secretStoreRef: diff --git a/Dockerfile b/Dockerfile index 91763b2..d89a8c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,9 @@ ENV LOG_BASE_PATH=$CONTAINER_APP_ROOT/log/$APP_NAME ENV BACKEND_LOG_FILE_NAME=$APP_NAME ENV APPLICATION_ACTIVITY_LOG=$APP_NAME-activity +ENV FREELEAPS_PRODUCT_ID="6901bcf4ed3725f39f11343d" +ENV ENVIRONMENT="alpha" + WORKDIR ${CONTAINER_APP_ROOT} COPY requirements.txt . diff --git a/common/config/app_settings.py b/common/config/app_settings.py index 804e341..9a0acdb 100644 --- a/common/config/app_settings.py +++ b/common/config/app_settings.py @@ -30,6 +30,9 @@ class AppSettings(BaseSettings): BACKEND_LOG_FILE_NAME: str = APP_NAME APPLICATION_ACTIVITY_LOG: str = APP_NAME + "-application-activity" + FREELEAPS_PRODUCT_ID: str = "" + ENVIRONMENT: str = "" + class Config: env_file = ".myapp.env" env_file_encoding = "utf-8" diff --git a/webapi/providers/metrics.py b/webapi/providers/metrics.py index ae5a634..974942a 100644 --- a/webapi/providers/metrics.py +++ b/webapi/providers/metrics.py @@ -2,12 +2,14 @@ import logging from prometheus_fastapi_instrumentator import Instrumentator from common.config.app_settings import app_settings -def register(app): - instrumentator = Instrumentator().instrument(app, - metric_namespace="freeleaps", - metric_subsystem=app_settings.APP_NAME) - @app.on_event("startup") - async def startup(): - instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True) - logging.info("Metrics endpoint exposed at /api/_/metrics") \ No newline at end of file +def register(app): + instrumentator = Instrumentator().instrument( + app, + metric_namespace="freeleaps_{}".format(app_settings.FREELEAPS_PRODUCT_ID), + metric_subsystem=app_settings.ENVIRONMENT) + + @app.on_event("startup") + async def startup(): + instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True) + logging.info("Metrics endpoint exposed at /api/_/metrics")