Skip to content

Commit

Permalink
Merge pull request #325 from Amsterdam/yrob/rollback
Browse files Browse the repository at this point in the history
Rollback otel changes and upgrades
  • Loading branch information
Yrob authored Nov 18, 2024
2 parents 5936cef + aa45576 commit 57827af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 115 deletions.
63 changes: 2 additions & 61 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,2 @@
FROM python:3.9-bullseye as builder
MAINTAINER [email protected]

ENV PYTHONUNBUFFERED 1

RUN apt update && apt install --no-install-recommends -y \
curl \
gdal-bin \
libgeos-c1v5 \
libpq5 \
netcat-openbsd \
build-essential \
libgeos-dev \
libpq-dev \
python3-dev \
libffi-dev

WORKDIR /app/

COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt

# Start runtime image
FROM python:3.9-bullseye
RUN apt update && apt install --no-install-recommends -y \
gdal-bin \
libgeos-c1v5 \
libpq5 \
netcat-openbsd

# Copy python build artifacts from builder image
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/lib/python3.9/site-packages/ /usr/local/lib/python3.9/site-packages/

RUN adduser --system datapunt


ENV PYTHONUNBUFFERED 1
ARG BAG_OBJECTSTORE_PASSWORD
ENV BAG_OBJECTSTORE_PASSWORD=$BAG_OBJECTSTORE_PASSWORD


WORKDIR /app/

RUN chown datapunt -R /app
EXPOSE 8080


RUN mkdir -p /static && chown datapunt /static

ENV DJANGO_SETTINGS_MODULE=bag.settings.docker

COPY bag /app/
COPY .jenkins-import /.jenkins-import/

USER datapunt

ENV BAG_SECRET_KEY=insecure
RUN ./manage.py collectstatic

CMD /app/docker-entrypoint.sh
FROM amsterdam/python:3.9-buster
MAINTAINER [email protected]
2 changes: 1 addition & 1 deletion bag/bag/settings/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# Log all unhandled exceptions
'django.request': {
'handlers': ['console'],
'level': 'INFO',
'level': 'ERROR',
'propagate': False,
},
},
Expand Down
40 changes: 0 additions & 40 deletions bag/bag/settings/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import json
import sys
import sentry_sdk
import logging
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from sentry_sdk.integrations.django import DjangoIntegration

from bag.settings.settings_common import * # noqa F403
Expand Down Expand Up @@ -276,40 +273,3 @@
else:
APIKEY_LOCALKEYS = json.loads(apikey_localkeys_env)


APPLICATIONINSIGHTS_CONNECTION_STRING = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
from opentelemetry.instrumentation.django import DjangoInstrumentor
if APPLICATIONINSIGHTS_CONNECTION_STRING is not None:
configure_azure_monitor(
logger_name="root",
instrumentation_options={
"azure_sdk": {"enabled": False},
"django": {"enabled": False},
"fastapi": {"enabled": False},
"flask": {"enabled": False},
"psycopg2": {"enabled": False},
"requests": {"enabled": False},
"urllib": {"enabled": False},
"urllib3": {"enabled": False},
},
resource=Resource.create({SERVICE_NAME: "bag_services"}),
)

# Enable the Python logger
logger = logging.getLogger("root")
logger.info("OpenTelemetry has been enabled")

def response_hook(span, request, response):
if span and span.is_recording():
email = request.get_token_subject
if "Origin" in request.headers:
origin = request.headers['Origin']
span.set_attribute("Origin", origin)
if "Referer" in request.headers:
referer = request.headers['Referer']
span.set_attribute("Referer", referer)


# Instrument Django app
DjangoInstrumentor().instrument(response_hook=response_hook)
print("django instrumentor enabled")
21 changes: 8 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appdirs==1.4.3
asn1crypto==1.3.0
asn1crypto==0.24.0
astroid==2.0.1
Babel==2.9.1
cached-property==1.5.1
Expand All @@ -11,7 +11,7 @@ colorama==0.4.1
coreapi==2.3.3
coreschema==0.0.4
coverage==4.5.2
cryptography==42.0.4
cryptography==41.0.6
datadiensten-apikeyclient==0.3.5
datapunt-authorization-django==1.3.2
debtcollector==1.20.0
Expand Down Expand Up @@ -43,7 +43,7 @@ frosted==1.4.1
graypy==0.3.1
httplib2==0.19.0
idna==2.8
ipaddress==1.0.23
ipaddress==1.0.22
iso8601==0.1.12
isort==4.3.4
itypes==1.2.0
Expand Down Expand Up @@ -76,16 +76,16 @@ pyflakes==2.0.0
PyJWT==2.8.0
pyparsing==2.4.7
pyslack-real==0.6.0
python-dateutil==2.8.1
python-dateutil==2.7.5
python-keystoneclient==3.18.0
python-swiftclient==3.6.0
pytz==2019.3
pytz==2018.9
PyYAML==6.0.1
requests==2.32.0
requests==2.31.0
rfc3986==1.2.0
sentry-sdk==1.14.0
simplejson==3.16.0
six==1.14.0
six==1.12.0
sphinx-me==0.3
sqlparse==0.4.4
stevedore==1.30.0
Expand All @@ -94,11 +94,6 @@ texttable==1.5.0
typing==3.6.6
unicodecsv==0.14.1
uritemplate==3.0.0
uwsgi==2.0.22
uwsgi-readiness-check==0.2.0
uwsgitop==0.12
urllib3==1.26.19
urllib3==1.26.18
websocket-client==0.54.0
Werkzeug==3.0.1
azure-identity==1.16.1
azure-monitor-opentelemetry == 1.5.0

0 comments on commit 57827af

Please sign in to comment.