Skip to content

Commit dd6c3f3

Browse files
author
Ben Corlett
committed
Add initial otel metrics and spans
1 parent a32827b commit dd6c3f3

File tree

8 files changed

+265
-11
lines changed

8 files changed

+265
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically copied from notifications-utils@99.8.0
1+
# This file was automatically copied from notifications-utils@100.1.0
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks

app/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from notifications_python_client.errors import HTTPError
2727
from notifications_utils import request_helper
2828
from notifications_utils.asset_fingerprinter import asset_fingerprinter
29+
from notifications_utils.clients.otel.otel_client import init_otel_app
2930
from notifications_utils.eventlet import EventletTimeout
3031
from notifications_utils.formatters import (
3132
formatted_list,
@@ -179,6 +180,7 @@ def create_app(application):
179180
asset_fingerprinter._asset_root = application.config["ASSET_PATH"]
180181

181182
init_app(application)
183+
init_otel_app(application)
182184

183185
if "extensions" not in application.jinja_options:
184186
application.jinja_options["extensions"] = []

app/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
22
import os
33

4+
from notifications_utils.config import BaseConfig
45

5-
class Config:
6+
7+
class Config(BaseConfig):
68
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET")
79
API_HOST_NAME = os.environ.get("API_HOST_NAME")
810
SECRET_KEY = os.environ.get("SECRET_KEY")
@@ -15,6 +17,8 @@ class Config:
1517
TEMPLATE_PREVIEW_API_HOST = os.environ.get("TEMPLATE_PREVIEW_API_HOST", "http://localhost:6013")
1618
TEMPLATE_PREVIEW_API_KEY = os.environ.get("TEMPLATE_PREVIEW_API_KEY", "my-secret-key")
1719

20+
OTEL_EXPORT_TYPE = os.environ.get("OTEL_EXPORT_TYPE", "otlp").lower().strip()
21+
1822
# Logging
1923
DEBUG = False
2024
NOTIFY_REQUEST_LOG_LEVEL = os.getenv("NOTIFY_REQUEST_LOG_LEVEL", "INFO")

requirements.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ notifications-python-client==10.0.0
1717
fido2==1.1.3
1818

1919
# Run `make bump-utils` to update to the latest version
20-
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@99.8.0
20+
notifications-utils[otel-flask,otel-requests,otel-redis,otel-botocore] @ git+https://github.com/alphagov/notifications-utils.git@3d7d1a63bf37b77f321ec49feb842aae669b5e82
21+
#notifications-utils @ ../notifications-utils
2122

2223
govuk-frontend-jinja==3.6.0
2324

requirements.txt

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ click==8.1.3
3131
# via flask
3232
cryptography==44.0.1
3333
# via fido2
34+
deprecated==1.2.18
35+
# via
36+
# opentelemetry-api
37+
# opentelemetry-exporter-otlp-proto-grpc
38+
# opentelemetry-exporter-otlp-proto-http
39+
# opentelemetry-semantic-conventions
3440
dnspython==2.6.1
3541
# via eventlet
3642
docopt==0.6.2
@@ -57,18 +63,26 @@ flask-wtf==1.2.1
5763
# via -r requirements.in
5864
gds-metrics @ git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6fb1ee40b7e84f2f18ec229de8aa72
5965
# via -r requirements.in
66+
googleapis-common-protos==1.70.0
67+
# via
68+
# opentelemetry-exporter-otlp-proto-grpc
69+
# opentelemetry-exporter-otlp-proto-http
6070
govuk-bank-holidays==0.15
6171
# via notifications-utils
6272
govuk-frontend-jinja==3.6.0
6373
# via -r requirements.in
6474
greenlet==3.2.2
6575
# via eventlet
76+
grpcio==1.73.1
77+
# via opentelemetry-exporter-otlp-proto-grpc
6678
gunicorn==23.0.0
6779
# via notifications-utils
6880
humanize==4.4.0
6981
# via -r requirements.in
7082
idna==3.7
7183
# via requests
84+
importlib-metadata==8.6.1
85+
# via opentelemetry-api
7286
itsdangerous==2.2.0
7387
# via
7488
# flask
@@ -102,14 +116,91 @@ mistune==0.8.4
102116
# via notifications-utils
103117
notifications-python-client==10.0.0
104118
# via -r requirements.in
105-
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@a97b36f6a32e7bb917152c8cd716fe65fa15ac9f
119+
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@3d7d1a63bf37b77f321ec49feb842aae669b5e82
106120
# via -r requirements.in
107121
openpyxl==3.1.5
108122
# via pyexcel-xlsx
123+
opentelemetry-api==1.33.1
124+
# via
125+
# opentelemetry-distro
126+
# opentelemetry-exporter-otlp-proto-grpc
127+
# opentelemetry-exporter-otlp-proto-http
128+
# opentelemetry-instrumentation
129+
# opentelemetry-instrumentation-botocore
130+
# opentelemetry-instrumentation-flask
131+
# opentelemetry-instrumentation-redis
132+
# opentelemetry-instrumentation-requests
133+
# opentelemetry-instrumentation-wsgi
134+
# opentelemetry-processor-baggage
135+
# opentelemetry-propagator-aws-xray
136+
# opentelemetry-sdk
137+
# opentelemetry-semantic-conventions
138+
opentelemetry-distro==0.54b1
139+
# via notifications-utils
140+
opentelemetry-exporter-otlp==1.33.1
141+
# via notifications-utils
142+
opentelemetry-exporter-otlp-proto-common==1.33.1
143+
# via
144+
# opentelemetry-exporter-otlp-proto-grpc
145+
# opentelemetry-exporter-otlp-proto-http
146+
opentelemetry-exporter-otlp-proto-grpc==1.33.1
147+
# via opentelemetry-exporter-otlp
148+
opentelemetry-exporter-otlp-proto-http==1.33.1
149+
# via opentelemetry-exporter-otlp
150+
opentelemetry-instrumentation==0.54b1
151+
# via
152+
# opentelemetry-distro
153+
# opentelemetry-instrumentation-botocore
154+
# opentelemetry-instrumentation-flask
155+
# opentelemetry-instrumentation-redis
156+
# opentelemetry-instrumentation-requests
157+
# opentelemetry-instrumentation-wsgi
158+
opentelemetry-instrumentation-botocore==0.54b1
159+
# via notifications-utils
160+
opentelemetry-instrumentation-flask==0.54b1
161+
# via notifications-utils
162+
opentelemetry-instrumentation-redis==0.54b1
163+
# via notifications-utils
164+
opentelemetry-instrumentation-requests==0.54b1
165+
# via notifications-utils
166+
opentelemetry-instrumentation-wsgi==0.54b1
167+
# via opentelemetry-instrumentation-flask
168+
opentelemetry-processor-baggage==0.54b1
169+
# via notifications-utils
170+
opentelemetry-propagator-aws-xray==1.0.2
171+
# via opentelemetry-instrumentation-botocore
172+
opentelemetry-proto==1.33.1
173+
# via
174+
# opentelemetry-exporter-otlp-proto-common
175+
# opentelemetry-exporter-otlp-proto-grpc
176+
# opentelemetry-exporter-otlp-proto-http
177+
opentelemetry-sdk==1.33.1
178+
# via
179+
# opentelemetry-distro
180+
# opentelemetry-exporter-otlp-proto-grpc
181+
# opentelemetry-exporter-otlp-proto-http
182+
# opentelemetry-processor-baggage
183+
opentelemetry-semantic-conventions==0.54b1
184+
# via
185+
# opentelemetry-instrumentation
186+
# opentelemetry-instrumentation-botocore
187+
# opentelemetry-instrumentation-flask
188+
# opentelemetry-instrumentation-redis
189+
# opentelemetry-instrumentation-requests
190+
# opentelemetry-instrumentation-wsgi
191+
# opentelemetry-sdk
192+
opentelemetry-util-http==0.54b1
193+
# via
194+
# opentelemetry-instrumentation-flask
195+
# opentelemetry-instrumentation-requests
196+
# opentelemetry-instrumentation-wsgi
109197
ordered-set==4.1.0
110198
# via notifications-utils
111199
packaging==23.1
112-
# via gunicorn
200+
# via
201+
# gunicorn
202+
# opentelemetry-instrumentation
203+
# opentelemetry-instrumentation-flask
113204
phonenumbers==8.13.50
114205
# via notifications-utils
115206
pillow==11.2.1
@@ -118,6 +209,10 @@ prometheus-client==0.15.0
118209
# via
119210
# -r requirements.in
120211
# gds-metrics
212+
protobuf==5.29.5
213+
# via
214+
# googleapis-common-protos
215+
# opentelemetry-proto
121216
pycparser==2.21
122217
# via cffi
123218
pyexcel==0.7.1
@@ -141,8 +236,10 @@ pyjwt==2.4.0
141236
# via notifications-python-client
142237
pypdf==3.13.0
143238
# via notifications-utils
144-
python-dateutil==2.8.2
145-
# via botocore
239+
python-dateutil==2.9.0.post0
240+
# via
241+
# botocore
242+
# notifications-utils
146243
python-json-logger==3.3.0
147244
# via notifications-utils
148245
pytz==2024.2
@@ -156,6 +253,7 @@ requests==2.32.3
156253
# govuk-bank-holidays
157254
# notifications-python-client
158255
# notifications-utils
256+
# opentelemetry-exporter-otlp-proto-http
159257
s3transfer==0.10.1
160258
# via boto3
161259
segno==1.6.1
@@ -170,6 +268,8 @@ statsd==4.0.1
170268
# via notifications-utils
171269
texttable==1.6.4
172270
# via pyexcel
271+
typing-extensions==4.14.0
272+
# via opentelemetry-sdk
173273
urllib3==1.26.19
174274
# via
175275
# botocore
@@ -179,9 +279,17 @@ werkzeug==3.1.3
179279
# via
180280
# flask
181281
# flask-login
282+
wrapt==1.17.2
283+
# via
284+
# deprecated
285+
# opentelemetry-instrumentation
286+
# opentelemetry-instrumentation-redis
287+
# opentelemetry-processor-baggage
182288
wtforms==3.1.0
183289
# via flask-wtf
184290
xlrd==2.0.1
185291
# via pyexcel-xls
186292
xlwt==1.3.0
187293
# via pyexcel-xls
294+
zipp==3.23.0
295+
# via importlib-metadata

0 commit comments

Comments
 (0)