Skip to content

Commit bfddaca

Browse files
dalpassoalambare
authored andcommitted
fix: change bucket boundaries and attributes in the metrics
1 parent 1077b2a commit bfddaca

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-13
lines changed

eodag/rest/utils.py

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,26 +1126,56 @@ def telemetry_init(fastapi_app: Optional[FastAPI] = None) -> None:
11261126
trace.set_tracer_provider(tracer_provider)
11271127
# metrics
11281128
reader = PeriodicExportingMetricReader(OTLPMetricExporter())
1129-
view = View(
1129+
view_histograms: View = View(
11301130
instrument_type=Histogram,
11311131
aggregation=ExplicitBucketHistogramAggregation(
11321132
boundaries=(
1133-
0.02,
1134-
0.05,
1135-
0.1,
11361133
0.25,
1137-
0.5,
1134+
0.50,
11381135
0.75,
11391136
1.0,
1140-
2.5,
1137+
1.5,
1138+
2.0,
1139+
3.0,
1140+
4.0,
11411141
5.0,
1142-
7.5,
1142+
6.0,
1143+
7.0,
1144+
8.0,
1145+
9.0,
11431146
10.0,
1144-
),
1147+
)
1148+
),
1149+
)
1150+
view_overhead_histograms: View = View(
1151+
instrument_type=Histogram,
1152+
instrument_name="*overhead*",
1153+
aggregation=ExplicitBucketHistogramAggregation(
1154+
boundaries=(
1155+
0.030,
1156+
0.040,
1157+
0.050,
1158+
0.060,
1159+
0.070,
1160+
0.080,
1161+
0.090,
1162+
0.100,
1163+
0.125,
1164+
0.150,
1165+
0.175,
1166+
0.200,
1167+
0.250,
1168+
0.500,
1169+
)
11451170
),
11461171
)
11471172
meter_provider = MeterProvider(
1148-
resource=resource, metric_readers=[reader], views=(view,)
1173+
resource=resource,
1174+
metric_readers=[reader],
1175+
views=(
1176+
view_histograms,
1177+
view_overhead_histograms,
1178+
),
11491179
)
11501180
metrics.set_meter_provider(meter_provider)
11511181

eodag/utils/instrumentation/eodag/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,11 @@ def wrapper_server_search_stac_items(
195195
request_duration_seconds.record(
196196
timer.get_global_time(), attributes=attributes
197197
)
198+
overhead_attributes = {
199+
k: v for k, v in attributes.items() if k != "product_type"
200+
}
198201
request_overhead_duration_seconds.record(
199-
timer.get_overhead_time(), attributes=attributes
202+
timer.get_overhead_time(), attributes=overhead_attributes
200203
)
201204
del overhead_timers[trace_id]
202205
del trace_attributes[trace_id]
@@ -336,8 +339,11 @@ def wrapper_server_download_stac_item_by_id_stream(
336339
request_duration_seconds.record(
337340
timer.get_global_time(), attributes=attributes
338341
)
342+
overhead_attributes = {
343+
k: v for k, v in attributes.items() if k != "product_type"
344+
}
339345
request_overhead_duration_seconds.record(
340-
timer.get_overhead_time(), attributes=attributes
346+
timer.get_overhead_time(), attributes=overhead_attributes
341347
)
342348
del overhead_timers[trace_id]
343349
del trace_attributes[trace_id]
@@ -485,7 +491,7 @@ def _available_providers_callback(
485491
observations = [
486492
Observation(
487493
v,
488-
{"label": "Available Providers", "provider_id": k},
494+
{"provider_id": k},
489495
)
490496
for k, v in observations_dict.items()
491497
]
@@ -514,7 +520,7 @@ def _available_product_types_callback(
514520
observations = [
515521
Observation(
516522
v,
517-
{"label": "Available Product Types", "product_type_id": k},
523+
{"product_type_id": k},
518524
)
519525
for k, v in observations_dict.items()
520526
]

0 commit comments

Comments
 (0)