Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Testing custom agent check on stage #264

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion commerce_coordinator/apps/commercetools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import logging

from datadog_checks.base import AgentCheck
from rest_framework import status
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAdminUser
Expand All @@ -26,12 +27,15 @@


# noinspection DuplicatedCode
class OrderFulfillView(SingleInvocationAPIView):
class OrderFulfillView(SingleInvocationAPIView, AgentCheck):
"""Order Fulfillment View"""

authentication_classes = [JwtBearerAuthentication, SessionAuthentication]
permission_classes = [IsAdminUser]

def check(self, instance):
self.gauge("hello.world", 1)

def post(self, request):
"""Receive a message from commerce tools forwarded by aws event bridge"""

Expand Down Expand Up @@ -64,6 +68,8 @@ def post(self, request):
message_id=message_id
)

self.check({})

return Response(status=status.HTTP_200_OK)


Expand Down
25 changes: 22 additions & 3 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Our own rebuilt Commercetools SDK (see SONIC-30)
commercetools @ git+https://github.com/edx/commercetools-python-sdk.git@main

asgiref==3.7.2 # Until we switch to Py 3.10, this has some serius issues with debuggers.
asgiref==3.7.2 # Until we switch to Py 3.10 this has some serius issues with debuggers.
attrs
celery
celery[redis]
currencies # Currency Formatting
currencies # Currency Formatting
python-dateutil
Django>=2.2 # Web application framework
Django>=2.2 # Web application framework
django-cors-headers
django-extensions
django-rest-swagger
Expand All @@ -22,9 +22,28 @@ edx-django-utils
edx-django-release-util
edx-drf-extensions
edx-rest-api-client
importlib-metadata==8.2.0
mysqlclient
openedx-filters
Pillow
pytz
segment-analytics-python
stripe

# Datadog
datadog-checks-base

# Required by datadog, their package doesnt seem to like pip? (Versions are specified by DD, but we avoid pinning...
# so they are kept for reference)
binary #==1.0.0
# https://github.com/DataDog/dd-trace-py/issues/10002
ddtrace #==2.9.3
jellyfish #==1.1.0
prometheus-client #==0.20.0
protobuf #==5.27.3
pydantic #==2.8.2
requests-unixsocket2 #==0.4.1
uptime #==3.0.1

# Not specified but required by DD
requests-toolbelt
102 changes: 84 additions & 18 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
#
amqp==5.2.0
# via kombu
annotated-types==0.7.0
# via pydantic
asgiref==3.7.2
# via
# -r requirements/base.in
# django
# django-cors-headers
async-timeout==4.0.3
# via redis
attrs==23.2.0
# via -r requirements/base.in
attrs==24.2.0
# via
# -r requirements/base.in
# cattrs
# ddtrace
backoff==2.2.1
# via segment-analytics-python
backports-zoneinfo[tzdata]==0.2.1
Expand All @@ -25,11 +30,17 @@ backports-zoneinfo[tzdata]==0.2.1
# kombu
billiard==4.2.0
# via celery
binary==1.0.0
# via -r requirements/base.in
bytecode==0.15.1
# via ddtrace
cattrs==23.2.3
# via ddtrace
celery[redis]==5.4.0
# via -r requirements/base.in
certifi==2024.6.2
certifi==2024.7.4
# via requests
cffi==1.16.0
cffi==1.17.0
# via
# cryptography
# pynacl
Expand All @@ -56,17 +67,25 @@ coreapi==2.3.3
# openapi-codec
coreschema==0.0.4
# via coreapi
cryptography==42.0.8
cryptography==43.0.0
# via
# pyjwt
# social-auth-core
currencies==2020.12.12
# via -r requirements/base.in
datadog-checks-base==36.13.0
# via -r requirements/base.in
ddsketch==3.0.1
# via ddtrace
ddtrace==2.10.4
# via -r requirements/base.in
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.13
deprecated==1.2.14
# via opentelemetry-api
django==4.2.15
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
Expand Down Expand Up @@ -112,7 +131,7 @@ edx-braze-client==0.2.5
# via -r requirements/base.in
edx-django-release-util==1.4.0
# via -r requirements/base.in
edx-django-utils==5.14.2
edx-django-utils==5.15.0
# via
# -r requirements/base.in
# edx-drf-extensions
Expand All @@ -123,13 +142,21 @@ edx-opaque-keys==2.10.0
# via edx-drf-extensions
edx-rest-api-client==5.7.1
# via -r requirements/base.in
envier==0.5.2
# via ddtrace
exceptiongroup==1.2.2
# via cattrs
idna==3.7
# via requests
importlib-metadata==8.2.0
# via -r requirements/base.in
itypes==1.2.0
# via coreapi
jellyfish==1.1.0
# via -r requirements/base.in
jinja2==3.1.4
# via coreschema
kombu==5.3.7
kombu==5.4.0
# via celery
markupsafe==2.1.5
# via
Expand All @@ -143,7 +170,7 @@ marshmallow-enum==1.5.1
# via commercetools
mysqlclient==2.2.4
# via -r requirements/base.in
newrelic==9.11.0
newrelic==9.13.0
# via edx-django-utils
oauthlib==3.2.2
# via
Expand All @@ -153,18 +180,30 @@ openapi-codec==1.3.2
# via django-rest-swagger
openedx-filters==1.9.0
# via -r requirements/base.in
opentelemetry-api==1.16.0
# via ddtrace
packaging==24.1
# via marshmallow
pbr==6.0.0
# via stevedore
pillow==10.3.0
pillow==10.4.0
# via -r requirements/base.in
prometheus-client==0.20.0
# via -r requirements/base.in
prompt-toolkit==3.0.47
# via click-repl
protobuf==5.27.3
# via
# -r requirements/base.in
# ddtrace
psutil==6.0.0
# via edx-django-utils
pycparser==2.22
# via cffi
pydantic==2.8.2
# via -r requirements/base.in
pydantic-core==2.20.1
# via pydantic
pyjwt[crypto]==2.8.0
# via
# drf-jwt
Expand All @@ -173,7 +212,7 @@ pyjwt[crypto]==2.8.0
# edx-rest-api-client
# segment-analytics-python
# social-auth-core
pymongo==4.7.3
pymongo==4.8.0
# via edx-opaque-keys
pynacl==1.5.0
# via edx-django-utils
Expand All @@ -188,9 +227,9 @@ pytz==2024.1
# via
# -r requirements/base.in
# commercetools
pyyaml==6.0.1
pyyaml==6.0.2
# via edx-django-release-util
redis==5.0.7
redis==5.0.8
# via celery
requests==2.32.3
# via
Expand All @@ -200,6 +239,8 @@ requests==2.32.3
# edx-rest-api-client
# requests-mock
# requests-oauthlib
# requests-toolbelt
# requests-unixsocket2
# segment-analytics-python
# slumber
# social-auth-core
Expand All @@ -210,6 +251,10 @@ requests-oauthlib==2.0.0
# via
# commercetools
# social-auth-core
requests-toolbelt==1.0.0
# via -r requirements/base.in
requests-unixsocket2==0.4.1
# via -r requirements/base.in
segment-analytics-python==2.3.2
# via -r requirements/base.in
semantic-version==2.10.0
Expand All @@ -218,39 +263,51 @@ simplejson==3.19.2
# via django-rest-swagger
six==1.16.0
# via
# ddsketch
# ddtrace
# edx-auth-backends
# edx-django-release-util
# python-dateutil
slumber==0.7.1
# via edx-rest-api-client
social-auth-app-django==5.4.1
social-auth-app-django==5.4.2
# via edx-auth-backends
social-auth-core==4.5.4
# via
# edx-auth-backends
# social-auth-app-django
sqlparse==0.5.0
sqlparse==0.5.1
# via django
stevedore==5.2.0
# via
# edx-django-utils
# edx-opaque-keys
stripe==10.0.0
stripe==10.7.0
# via -r requirements/base.in
typing-extensions==4.12.2
# via
# annotated-types
# asgiref
# bytecode
# cattrs
# ddtrace
# edx-opaque-keys
# kombu
# pydantic
# pydantic-core
# stripe
tzdata==2024.1
# via
# backports-zoneinfo
# celery
uptime==3.0.1
# via -r requirements/base.in
uritemplate==4.1.1
# via coreapi
urllib3==2.2.2
# via requests
# via
# requests
# requests-unixsocket2
vine==5.1.0
# via
# amqp
Expand All @@ -263,4 +320,13 @@ webob==1.8.7
werkzeug==3.0.3
# via commercetools
wrapt==1.16.0
# via commercetools
# via
# commercetools
# deprecated
xmltodict==0.13.0
# via ddtrace
zipp==3.20.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
4 changes: 2 additions & 2 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
cachetools==5.3.3
cachetools==5.4.0
# via tox
chardet==5.2.0
# via tox
Expand Down Expand Up @@ -32,7 +32,7 @@ tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.15.1
tox==4.17.1
# via -r requirements/ci.in
virtualenv==20.26.3
# via tox
15 changes: 7 additions & 8 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ Django<5.0

# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
# See https://github.com/openedx/edx-platform/issues/35126 for more info
elasticsearch<7.14.0

# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected
django-simple-history==3.0.0

# opentelemetry requires version 6.x at the moment:
# https://github.com/open-telemetry/opentelemetry-python/issues/3570
# Normally this could be added as a constraint in edx-django-utils, where we're
# adding the opentelemetry dependency. However, when we compile pip-tools.txt,
# that uses version 7.x, and then there's no undoing that when compiling base.txt.
# So we need to pin it globally, for now.
# Ticket for unpinning: https://github.com/openedx/edx-lint/issues/407
importlib-metadata<7
# Cause: https://github.com/openedx/event-tracking/pull/290
# event-tracking 2.4.1 upgrades to pymongo 4.4.0 which is not supported on edx-platform.
# We will pin event-tracking to do not break existing installations
# This can be unpinned once https://github.com/openedx/edx-platform/issues/34586
# has been resolved and edx-platform is running with pymongo>=4.4.0
event-tracking<2.4.1
Loading
Loading