diff --git a/api/.dockerignore b/api/.dockerignore index b6aaccd33..04ff72f11 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -4,3 +4,4 @@ **/build.sh **/build_*.sh **/*deploy.sh +Dockerfile* \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index 8f8691159..d02dda8ba 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -8,6 +8,7 @@ ARG envarg ENV SOURCE_MAP_VERSION=0.7.4 \ APP_NAME=chalice \ LISTEN_PORT=8000 \ + MAPPING_WASM=/work/sourcemap-reader/mappings.wasm \ ENTERPRISE_BUILD=${envarg} ADD https://unpkg.com/source-map@${SOURCE_MAP_VERSION}/lib/mappings.wasm /mappings.wasm @@ -20,7 +21,8 @@ RUN cd /work_tmp && npm install WORKDIR /work COPY . . -RUN mv env.default .env && mv /work_tmp/node_modules sourcemap-reader/. && chmod 644 /mappings.wasm +RUN mv env.default .env && mv /work_tmp/node_modules sourcemap-reader/. \ + && mv /mappings.wasm ${MAPPING_WASM} && chmod 644 ${MAPPING_WASM} RUN adduser -u 1001 openreplay -D USER 1001 diff --git a/api/Dockerfile.alerts.dockerignore b/api/Dockerfile.alerts.dockerignore index 3539023b4..bb4179739 100644 --- a/api/Dockerfile.alerts.dockerignore +++ b/api/Dockerfile.alerts.dockerignore @@ -4,6 +4,7 @@ **/build.sh **/build_*.sh **/*deploy.sh +Dockerfile* app.py entrypoint_alerts.sh diff --git a/api/chalicelib/core/sourcemaps_parser.py b/api/chalicelib/core/sourcemaps_parser.py index 4cc6ae1df..a6c2a92cc 100644 --- a/api/chalicelib/core/sourcemaps_parser.py +++ b/api/chalicelib/core/sourcemaps_parser.py @@ -27,4 +27,5 @@ def get_original_trace(key, positions): return None except Exception as e: print("Issue getting sourcemap") + print(e) return None diff --git a/api/chalicelib/utils/pg_client.py b/api/chalicelib/utils/pg_client.py index 1ec1f2a19..8b9001649 100644 --- a/api/chalicelib/utils/pg_client.py +++ b/api/chalicelib/utils/pg_client.py @@ -20,7 +20,7 @@ PG_CONFIG = dict(_PG_CONFIG) if config("pg_timeout", cast=int, default=0) > 0: PG_CONFIG["options"] = f"-c statement_timeout={config('pg_timeout', cast=int) * 1000}" -logging.info(f">PG_POOL:{config('PG_POOL', cast=bool, default=None)}") +logging.info(f">PG_POOL:{config('PG_POOL', default=None)}") class ORThreadedConnectionPool(psycopg2.pool.ThreadedConnectionPool): @@ -44,7 +44,7 @@ class ORThreadedConnectionPool(psycopg2.pool.ThreadedConnectionPool): except psycopg2.pool.PoolError as e: if str(e) == "trying to put unkeyed connection": print("!!! trying to put unkeyed connection") - print(f"env-PG_POOL:{config('PG_POOL', cast=bool, default=None)}") + print(f"env-PG_POOL:{config('PG_POOL', default=None)}") return raise e diff --git a/ee/api/.dockerignore b/ee/api/.dockerignore index b456d908b..7d122d6cb 100644 --- a/ee/api/.dockerignore +++ b/ee/api/.dockerignore @@ -4,6 +4,7 @@ **/build.sh **/build_*.sh **/*deploy.sh +Dockerfile* app_crons.py app_alerts.py diff --git a/ee/api/Dockerfile b/ee/api/Dockerfile index dad5fa20d..1b23fc6d4 100644 --- a/ee/api/Dockerfile +++ b/ee/api/Dockerfile @@ -6,6 +6,7 @@ ARG envarg ENV SOURCE_MAP_VERSION=0.7.4 \ APP_NAME=chalice \ LISTEN_PORT=8000 \ + MAPPING_WASM=/work/sourcemap-reader/mappings.wasm \ ENTERPRISE_BUILD=${envarg} ADD https://unpkg.com/source-map@${SOURCE_MAP_VERSION}/lib/mappings.wasm /mappings.wasm @@ -18,7 +19,8 @@ RUN cd /work_tmp && npm install WORKDIR /work COPY . . -RUN mv env.default .env && mv /work_tmp/node_modules sourcemap-reader/. && chmod 644 /mappings.wasm +RUN mv env.default .env && mv /work_tmp/node_modules sourcemap-reader/. \ + && mv /mappings.wasm ${MAPPING_WASM} && chmod 644 ${MAPPING_WASM} RUN adduser -u 1001 openreplay -D USER 1001 diff --git a/ee/api/Dockerfile.alerts.dockerignore b/ee/api/Dockerfile.alerts.dockerignore index 8e1cbef03..1b8f57638 100644 --- a/ee/api/Dockerfile.alerts.dockerignore +++ b/ee/api/Dockerfile.alerts.dockerignore @@ -4,6 +4,7 @@ **/build.sh **/build_*.sh **/*deploy.sh +Dockerfile* app.py app_crons.py diff --git a/ee/api/Dockerfile.crons.dockerignore b/ee/api/Dockerfile.crons.dockerignore index 38fed8fd0..fa6ca7a65 100644 --- a/ee/api/Dockerfile.crons.dockerignore +++ b/ee/api/Dockerfile.crons.dockerignore @@ -4,6 +4,7 @@ **/build.sh **/build_*.sh **/*deploy.sh +Dockerfile* app.py app_alerts.py diff --git a/ee/api/chalicelib/core/metrics.py b/ee/api/chalicelib/core/metrics.py index 62a1fbb27..3861f48aa 100644 --- a/ee/api/chalicelib/core/metrics.py +++ b/ee/api/chalicelib/core/metrics.py @@ -793,7 +793,7 @@ def get_missing_resources_trend(project_id, startTimestamp=TimeUTC.now(delta_day GROUP BY url_hostpath ORDER BY doc_count DESC LIMIT 10;""" - params = {"project_id": project_id, "startTimestamp": startTimestamp, + params = {"step_size": step_size, "project_id": project_id, "startTimestamp": startTimestamp, "endTimestamp": endTimestamp, **__get_constraint_values(args)} rows = ch.execute(query=ch_query, params=params) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql new file mode 100644 index 000000000..f6204aff5 --- /dev/null +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql @@ -0,0 +1,8 @@ +BEGIN; +CREATE OR REPLACE FUNCTION openreplay_version() + RETURNS text AS +$$ +SELECT 'v1.8.1-ee' +$$ LANGUAGE sql IMMUTABLE; + +COMMIT; \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 91cb307eb..238cf3273 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -7,7 +7,7 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto; CREATE OR REPLACE FUNCTION openreplay_version() RETURNS text AS $$ -SELECT 'v1.8.0-ee' +SELECT 'v1.8.1-ee' $$ LANGUAGE sql IMMUTABLE; diff --git a/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql b/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql index 3089eafd0..170851a80 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.8.1/1.8.1.sql @@ -5,4 +5,4 @@ $$ SELECT 'v1.8.1' $$ LANGUAGE sql IMMUTABLE; -COMMIT; +COMMIT; \ No newline at end of file diff --git a/sourcemap-reader/clean.sh b/sourcemap-reader/clean.sh new file mode 100755 index 000000000..a0cb5c9ed --- /dev/null +++ b/sourcemap-reader/clean.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rm -rf ./utils \ No newline at end of file diff --git a/sourcemap-reader/prepare-dev.sh b/sourcemap-reader/prepare-dev.sh new file mode 100755 index 000000000..e057555db --- /dev/null +++ b/sourcemap-reader/prepare-dev.sh @@ -0,0 +1,2 @@ +#!/bin/bash +rsync -avr --exclude=".*" --ignore-existing ../utilities/utils ./ \ No newline at end of file diff --git a/sourcemap-reader/server.js b/sourcemap-reader/server.js index 327994042..1620bea8f 100644 --- a/sourcemap-reader/server.js +++ b/sourcemap-reader/server.js @@ -8,7 +8,11 @@ const PORT = process.env.SR_PORT || 9000; const app = express(); app.use(request_logger("[SR]")); - +app.get(['/'], (req, res) => { + res.statusCode = 200; + res.end("ok!"); + } +); app.use('/sourcemaps', sourcemapsReaderServer); app.use('/heapdump', dumps.router); diff --git a/sourcemap-reader/servers/sourcemaps-handler.js b/sourcemap-reader/servers/sourcemaps-handler.js index 191267b5b..7baf62b66 100644 --- a/sourcemap-reader/servers/sourcemaps-handler.js +++ b/sourcemap-reader/servers/sourcemaps-handler.js @@ -3,11 +3,13 @@ const fs = require('fs'); const sourceMap = require('source-map'); const AWS = require('aws-sdk'); const URL = require('url'); -const wasm = fs.readFileSync('/mappings.wasm'); +const wasm = fs.readFileSync(process.env.MAPPING_WASM || '/mappings.wasm'); sourceMap.SourceMapConsumer.initialize({ "lib/mappings.wasm": wasm }); +console.log(`>sourceMap initialised using ${process.env.MAPPING_WASM || '/mappings.wasm'}`); + module.exports.sourcemapReader = async event => { let s3; if (event.S3_HOST) {