Skip to content

Commit

Permalink
Add sampling support for latency metrics on ad server callbacks (#116)
Browse files Browse the repository at this point in the history
* add log based metrics for pipeline & overall latency sampling in cloud function. removed brotlipy because it wouldn't install and isn't ever imported

* add namespace and version to log so that we can differentiate behavior by client versions
  • Loading branch information
dmueller authored Apr 29, 2024
1 parent ddea2fb commit 43fec10
Show file tree
Hide file tree
Showing 6 changed files with 1,185 additions and 1,038 deletions.
107 changes: 4 additions & 103 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
#
version: 2.1

orbs:
aws-cli: circleci/aws-cli@0.1.13
aws-ecr: circleci/aws-ecr@6.5.0
assume-role: airswap/assume-role@0.2.0

jobs:
tests_unit:
docker:
- image: cimg/python:3.11
- image: cimg/python:3.11.8
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
Expand All @@ -27,14 +23,14 @@ jobs:
- checkout

- restore_cache:
key: deps-test-{{ checksum "<<parameters.pipenv_path>>Pipfile.lock" }}-v1
key: deps-test-{{ checksum "<<parameters.pipenv_path>>Pipfile.lock" }}-v2
- run:
name: Build environment and install requirements
command: |
pip install pipenv
pipenv install --dev
- save_cache:
key: deps-test-{{ checksum "<<parameters.pipenv_path>>Pipfile.lock" }}-v1
key: deps-test-{{ checksum "<<parameters.pipenv_path>>Pipfile.lock" }}-v2
paths:
- "~/.venv"

Expand All @@ -54,106 +50,11 @@ jobs:
- store_artifacts:
path: proxy-server-coverage

build:
parameters:
env:
description: Deployment environment
type: enum
enum: ["dev", "prod", "staging"]
default: dev
main_image_name:
description: Main Docker image name
type: string
default: proxy
nginx_image_name:
description: Nginx Docker image name
type: string
default: nginx
docker:
- image: pocket/ops-cli:v0.0.5
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
environment:
MAIN_IMAGE_NAME: << parameters.main_image_name >>
NGINX_IMAGE_NAME: << parameters.nginx_image_name >>
steps:
- checkout
- when:
condition:
equal: ["dev", << parameters.env >>]
steps:
- run:
name: Setup common environment variables
command: |
echo "building for dev...main image name is $MAIN_IMAGE_NAME"
echo 'export AWS_ECR_ACCOUNT_DEV_URL="${ACCOUNT_ID_DEV}.dkr.ecr.us-east-1.amazonaws.com"' >> $BASH_ENV
echo 'export AWS_ECR_ACCOUNT_URL="${AWS_ECR_ACCOUNT_DEV_URL}"' >> $BASH_ENV
- assume-role/assume-role:
account-id: $ACCOUNT_ID_DEV
- when:
condition:
equal: ["prod", << parameters.env >>]
steps:
- run:
name: Setup common environment variables
command: |
echo "building for prod...main image name is $MAIN_IMAGE_NAME"
echo 'export AWS_ECR_ACCOUNT_PROD_URL="${ACCOUNT_ID_PROXY}.dkr.ecr.us-east-1.amazonaws.com"' >> $BASH_ENV
echo 'export AWS_ECR_ACCOUNT_URL="${AWS_ECR_ACCOUNT_PROD_URL}"' >> $BASH_ENV
- assume-role/assume-role:
account-id: $ACCOUNT_ID_PROXY
- aws-ecr/ecr-login
- aws-ecr/build-and-push-image:
checkout: false
repo: $MAIN_IMAGE_NAME
setup-remote-docker: true
tag: $CIRCLE_SHA1,latest
dockerfile: ./images/app/Dockerfile
extra-build-args: --build-arg GIT_SHA=${CIRCLE_SHA1}
- aws-ecr/build-and-push-image:
checkout: false
repo: $NGINX_IMAGE_NAME
setup-remote-docker: false
tag: $CIRCLE_SHA1,latest
path: ./images/nginx/
dockerfile: ./images/nginx/Dockerfile
extra-build-args: --build-arg GIT_SHA=${CIRCLE_SHA1}



# Workflow shortcuts
not_main: &not_main
filters:
branches:
ignore:
- main

only_main: &only_main
filters:
branches:
only:
- main

workflows:
version: 2
build_and_test:
jobs:
- tests_unit:
context: pocket-proxy
- build:
<<: *not_main
env: dev
main_image_name: proxy-server-dev
nginx_image_name: proxy-server-nginx-dev
context: pocket-proxy
requires:
- tests_unit
- build:
<<: *only_main
env: prod
context: pocket-proxy
requires:
- tests_unit


2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ fastapi = {extras = ["all"], version = "*"}
uvloop = "*"
httptools = "*"
aiohttp = {extras = ["speedups"], version = "*"}
brotlipy = "==0.7.0"
schemathesis = "*"
google-cloud-storage = "*"
sentry-sdk = {extras = ["fastapi"], version = "*"}
google-cloud-logging = "*"

[dev-packages]
responses = "*"
Expand Down
Loading

0 comments on commit 43fec10

Please sign in to comment.