arize-phoenix 11.33.0__py3-none-any.whl → 11.34.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of arize-phoenix might be problematic. Click here for more details.
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/METADATA +1 -1
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/RECORD +26 -26
- phoenix/config.py +44 -0
- phoenix/db/bulk_inserter.py +111 -116
- phoenix/server/api/routers/v1/documents.py +1 -1
- phoenix/server/api/routers/v1/evaluations.py +4 -4
- phoenix/server/api/routers/v1/spans.py +2 -2
- phoenix/server/api/routers/v1/traces.py +18 -3
- phoenix/server/app.py +56 -18
- phoenix/server/daemons/span_cost_calculator.py +10 -8
- phoenix/server/grpc_server.py +9 -9
- phoenix/server/prometheus.py +30 -6
- phoenix/server/static/.vite/manifest.json +39 -39
- phoenix/server/static/assets/{components-YTHUASXI.js → components-CdQiQTvs.js} +1 -1
- phoenix/server/static/assets/{index-CugQp26L.js → index-B1VuXYRI.js} +2 -2
- phoenix/server/static/assets/{pages-4Qu8GNlt.js → pages-CnfZ3RhB.js} +498 -494
- phoenix/server/static/assets/{vendor-CRRxHwSp.js → vendor-Cfrr9FCF.js} +135 -135
- phoenix/server/static/assets/{vendor-arizeai-CUN6lRd9.js → vendor-arizeai-Dz0kN-lQ.js} +1 -1
- phoenix/server/static/assets/{vendor-codemirror-sJXwoqrE.js → vendor-codemirror-ClqtONZQ.js} +11 -11
- phoenix/server/static/assets/{vendor-recharts-BT_PeGhc.js → vendor-recharts-D6kvOpmb.js} +1 -1
- phoenix/server/static/assets/{vendor-shiki-1F3op0QC.js → vendor-shiki-xSOiKxt0.js} +1 -1
- phoenix/version.py +1 -1
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/WHEEL +0 -0
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/entry_points.txt +0 -0
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/licenses/IP_NOTICE +0 -0
- {arize_phoenix-11.33.0.dist-info → arize_phoenix-11.34.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
phoenix/__init__.py,sha256=Sgb4r2MLoY2BbC9Caky5C0bwnOyiVOMHly2sRItmg3Q,5555
|
|
2
2
|
phoenix/auth.py,sha256=9rscOefuxy5VPcb6MlOYenuy3gDd5l7RxknONovGslE,11342
|
|
3
|
-
phoenix/config.py,sha256=
|
|
3
|
+
phoenix/config.py,sha256=J0qpqoweNwQOErnvGnzrH8g3QC2VCyjNYQ0EKECvzCg,65211
|
|
4
4
|
phoenix/datetime_utils.py,sha256=pRD-nzxXYKlMWNtd3r2tKGKfPFhwuJhfOAtlGLVAO60,8784
|
|
5
5
|
phoenix/exceptions.py,sha256=n2L2KKuecrdflB9MsCdAYCiSEvGJptIsfRkXMoJle7A,169
|
|
6
6
|
phoenix/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
7
7
|
phoenix/services.py,sha256=ngkyKGVatX3cO2WJdo2hKdaVKP-xJCMvqthvga6kJss,5196
|
|
8
8
|
phoenix/settings.py,sha256=2kHfT3BNOVd4dAO1bq-syEQbHSG8oX2-7NhOwK2QREk,896
|
|
9
|
-
phoenix/version.py,sha256=
|
|
9
|
+
phoenix/version.py,sha256=muN5TyR0wlxL44978731Bf111znItdl8HBAWgNnGSOQ,24
|
|
10
10
|
phoenix/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
phoenix/core/embedding_dimension.py,sha256=zKGbcvwOXgLf-yrJBpQyKtd-LEOPRKHnUToyAU8Owis,87
|
|
12
12
|
phoenix/core/model.py,sha256=qBFraOtmwCCnWJltKNP18DDG0mULXigytlFsa6YOz6k,4837
|
|
@@ -15,7 +15,7 @@ phoenix/core/model_schema_adapter.py,sha256=y1RXPYGt2HLTGpkB2X-XVQvRJXYGmJ9EL4m7
|
|
|
15
15
|
phoenix/db/README.md,sha256=51cZyk1XzkUz0jn1cIRkgrZW3LeQZmhWCIXUMWjWO90,10905
|
|
16
16
|
phoenix/db/__init__.py,sha256=pDjEFXukHmJBM-1D8RjmXkvLsz85YWNxMQczt81ec3A,118
|
|
17
17
|
phoenix/db/alembic.ini,sha256=GIS6HpHaKaJbbuahZg1Rc1D2_QqyCkV9r58wdARGf6w,3262
|
|
18
|
-
phoenix/db/bulk_inserter.py,sha256=
|
|
18
|
+
phoenix/db/bulk_inserter.py,sha256=yfhnSJU4kpLlZxQr971fTAmkzP2LjQKMyYLXEijomMU,13761
|
|
19
19
|
phoenix/db/constants.py,sha256=-YE2rkzcROG06_rerfnX5hC7fLzOHx1Gjw4nXhX_um4,46
|
|
20
20
|
phoenix/db/engines.py,sha256=e-VdW9FZVrs-F8P8FeQP2NzOTOXuq9LeUq1ebv99ZdM,6731
|
|
21
21
|
phoenix/db/enums.py,sha256=w3O5YuJEEzVTwVDZb8b2UUFhU8yK_GosF081VVrrno0,188
|
|
@@ -91,16 +91,16 @@ phoenix/pointcloud/pointcloud.py,sha256=SN_1wXZcwKrtSnHGZLDZGx71orqE1WyVF7E-D58d
|
|
|
91
91
|
phoenix/pointcloud/projectors.py,sha256=TQgwc9cJDjJkin1WZyZzgl3HsYrLLiyWD7Czy4jNW3U,1088
|
|
92
92
|
phoenix/pointcloud/umap_parameters.py,sha256=db_WEPoamuWtopZx7tQfAXPnoE0MS8FkAV0_ThjEx_Q,1735
|
|
93
93
|
phoenix/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
94
|
-
phoenix/server/app.py,sha256=
|
|
94
|
+
phoenix/server/app.py,sha256=wSCpFMo_PWnOftbxvPdexnLfW9HbX_9gjErVykCTVLQ,50319
|
|
95
95
|
phoenix/server/authorization.py,sha256=OxROn7ibpKtCTrcgDkzWuNxVaQcSQ8MAx7zbjZiliK0,3201
|
|
96
96
|
phoenix/server/bearer_auth.py,sha256=f4v4W94KyTdGGCPsK1tXOe0vouPuvanAEa03XSdCvPE,6650
|
|
97
97
|
phoenix/server/dml_event.py,sha256=8UciN7W8X_IqQfAnAeAh68BezNmfxSxuTeD6IUerTW8,2911
|
|
98
98
|
phoenix/server/dml_event_handler.py,sha256=71_iPcHiJ4E-8Z7sGL2j0vx_RpkmcMVEUFIBsWrdp-E,8483
|
|
99
|
-
phoenix/server/grpc_server.py,sha256=
|
|
99
|
+
phoenix/server/grpc_server.py,sha256=THDdkMKXQEC3gZjFG2nUgXHFbUnWsRHgFM9oh5WtAX0,4758
|
|
100
100
|
phoenix/server/jwt_store.py,sha256=B6uVildN_dQDTG_-aHHvuVSI7wIVK1yvED-_y6se2GU,16905
|
|
101
101
|
phoenix/server/main.py,sha256=UBwxrQIEE7ci-SbE6GAlRYmbMHooI6JYG6sG-UpBFFs,18905
|
|
102
102
|
phoenix/server/oauth2.py,sha256=GvUqZBoZ5dG-l2G1RMl1SUcN10jNAjaMXFznMSWz2Zs,3336
|
|
103
|
-
phoenix/server/prometheus.py,sha256=
|
|
103
|
+
phoenix/server/prometheus.py,sha256=ovh6Hrw2mLUC6KddGydT0_lv-yK0upV9mL-T9UjqlcE,9373
|
|
104
104
|
phoenix/server/rate_limiters.py,sha256=cFc73D2NaxqNZZDbwfIDw4So-fRVOJPBtqxOZ8Qky_s,7155
|
|
105
105
|
phoenix/server/retention.py,sha256=MQe1FWuc_NxhqgIq5q2hfFhWT8ddAmpppgI74xYEQ6c,3064
|
|
106
106
|
phoenix/server/session_filters.py,sha256=zEJHnF2sDCxjWti2eOz1Yx4r4-zS1rAzq0oUxzl0gEY,1697
|
|
@@ -265,16 +265,16 @@ phoenix/server/api/routers/v1/__init__.py,sha256=_CxVCs26dPuC2KygV3VzYqmoAECeFwi
|
|
|
265
265
|
phoenix/server/api/routers/v1/annotation_configs.py,sha256=xp5lJmKYlRsINCUrRD9-lTAElw2v4hdFndS5BWrxICA,16048
|
|
266
266
|
phoenix/server/api/routers/v1/annotations.py,sha256=V_Cm_XOJaSVpMsTCfxBd1H39sk17b2y6Lyk5qwwDHvI,11433
|
|
267
267
|
phoenix/server/api/routers/v1/datasets.py,sha256=9iPORLmbOrPKgUUcRDMs6ZczSIz7hvc6bngJy3IbdR0,38331
|
|
268
|
-
phoenix/server/api/routers/v1/documents.py,sha256=
|
|
269
|
-
phoenix/server/api/routers/v1/evaluations.py,sha256=
|
|
268
|
+
phoenix/server/api/routers/v1/documents.py,sha256=qSEQaavpKd3IFuvEiIPj4oYU4AZOi4CLlDu-ZTwWMDw,5745
|
|
269
|
+
phoenix/server/api/routers/v1/evaluations.py,sha256=bZmOttGlI7MIDC80YfSX7-gYPa5c0WKQDIA6qbQRNEU,13084
|
|
270
270
|
phoenix/server/api/routers/v1/experiment_evaluations.py,sha256=DZ3UK9OoYKElpRcEER7559-KiAqWr-1IXpZ27FbfP3k,5249
|
|
271
271
|
phoenix/server/api/routers/v1/experiment_runs.py,sha256=KaQ6EI1qQrIE-q1C22C9sEUnr9aho-23xcDDPIIkwko,8378
|
|
272
272
|
phoenix/server/api/routers/v1/experiments.py,sha256=-xoAh4rTMKkmjDJSICNv3dvlTtMdCGB6ZuxuossHuMY,20617
|
|
273
273
|
phoenix/server/api/routers/v1/models.py,sha256=p3gJN-9SWiUYTUTft4bZMsZVCBNTb4nN1Foy68eRZzQ,1997
|
|
274
274
|
phoenix/server/api/routers/v1/projects.py,sha256=XR6uJxHXXtC1q8LNyS9W6iaj440sv1OKCu-OSBfxEys,12824
|
|
275
275
|
phoenix/server/api/routers/v1/prompts.py,sha256=chRYcLkOYDJdJfVZVukVTUyIRnLPvsJCg41CuPxOIU8,26695
|
|
276
|
-
phoenix/server/api/routers/v1/spans.py,sha256=
|
|
277
|
-
phoenix/server/api/routers/v1/traces.py,sha256
|
|
276
|
+
phoenix/server/api/routers/v1/spans.py,sha256=m_4VfYndU6wVZ4xXMMJyajfuYHBiB28HCl8BAC2t2V0,47581
|
|
277
|
+
phoenix/server/api/routers/v1/traces.py,sha256=dtJej9kHcbxb0OXa7HBSD19nO-HASaR1ixj0-HFJgc4,10454
|
|
278
278
|
phoenix/server/api/routers/v1/users.py,sha256=eO8zMtGU33Td2_G1l9D7Z0a4CG1CwBUCj_Z9z2uk7wg,12089
|
|
279
279
|
phoenix/server/api/routers/v1/utils.py,sha256=oXIOGPzPTkE0ZWUTRCoRIQQ7wTzoSwtWFaUSjlGBqts,4960
|
|
280
280
|
phoenix/server/api/types/Annotation.py,sha256=gsl8CwjIbDUbZRj4d9USwZ_w_Tkz4i7zuZh9ftV80jA,1132
|
|
@@ -379,7 +379,7 @@ phoenix/server/cost_tracking/token_cost_calculator.py,sha256=2JEZnvusx2-xbhp8krp
|
|
|
379
379
|
phoenix/server/daemons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
380
380
|
phoenix/server/daemons/db_disk_usage_monitor.py,sha256=2WBkrL1QyRGbLtskXEdxwAdnWLjtdQ-mix95AkLQSbg,7997
|
|
381
381
|
phoenix/server/daemons/generative_model_store.py,sha256=CkMG0jFWtxcUNP_7iFTgzHPyl5IgnXUwwJb7584pmkI,1566
|
|
382
|
-
phoenix/server/daemons/span_cost_calculator.py,sha256=
|
|
382
|
+
phoenix/server/daemons/span_cost_calculator.py,sha256=0P0ErNmUd8Hi8jqjieNR-bakAMiYfiBlB7QkLEoHX3o,3284
|
|
383
383
|
phoenix/server/email/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
384
384
|
phoenix/server/email/sender.py,sha256=tmigvAyLV6cyGLfH6Ks_q0L5wlTpo6mBB951QCmhadw,5161
|
|
385
385
|
phoenix/server/email/types.py,sha256=f1XXk4OQJlLSCHweujrGlkZic7CtbUSnfdPXzqP9WRI,772
|
|
@@ -402,16 +402,16 @@ phoenix/server/static/apple-touch-icon-76x76.png,sha256=CT_xT12I0u2i0WU8JzBZBuOQ
|
|
|
402
402
|
phoenix/server/static/apple-touch-icon.png,sha256=fOfpjqGpWYbJ0eAurKsyoZP1EAs6ZVooBJ_SGk2ZkDs,3801
|
|
403
403
|
phoenix/server/static/favicon.ico,sha256=bY0vvCKRftemZfPShwZtE93DiiQdaYaozkPGwNFr6H8,34494
|
|
404
404
|
phoenix/server/static/modernizr.js,sha256=mvK-XtkNqjOral-QvzoqsyOMECXIMu5BQwSVN_wcU9c,2564
|
|
405
|
-
phoenix/server/static/.vite/manifest.json,sha256=
|
|
406
|
-
phoenix/server/static/assets/components-
|
|
407
|
-
phoenix/server/static/assets/index-
|
|
408
|
-
phoenix/server/static/assets/pages-
|
|
405
|
+
phoenix/server/static/.vite/manifest.json,sha256=UKiCtA5rvKMr8U4zLFRXo5S5Fdvy8dKouD1kF3GESko,2328
|
|
406
|
+
phoenix/server/static/assets/components-CdQiQTvs.js,sha256=ffg4jmfz-Bc9PTLXXAz7OduRazQDl5KZyeR_3S2aILs,675981
|
|
407
|
+
phoenix/server/static/assets/index-B1VuXYRI.js,sha256=jOk_qo0Q0SRXWfvHVlValebC3vs1mUfV1v-Kf94B2rc,62934
|
|
408
|
+
phoenix/server/static/assets/pages-CnfZ3RhB.js,sha256=XYLansUm9qmewwVwsW-dskFdfP72RCMzRAdzlLMJMhg,1298004
|
|
409
409
|
phoenix/server/static/assets/vendor-BGzfc4EU.css,sha256=Nx5Lmx-bqYR7nsO_O4kEBcrJ8cwknWjZ6seHN3_s4UQ,3171
|
|
410
|
-
phoenix/server/static/assets/vendor-
|
|
411
|
-
phoenix/server/static/assets/vendor-arizeai-
|
|
412
|
-
phoenix/server/static/assets/vendor-codemirror-
|
|
413
|
-
phoenix/server/static/assets/vendor-recharts-
|
|
414
|
-
phoenix/server/static/assets/vendor-shiki-
|
|
410
|
+
phoenix/server/static/assets/vendor-Cfrr9FCF.js,sha256=e5sXxTzHgKwjsNy7bFWp19fM9QolSJBQ9FvE4hmxrPs,2575393
|
|
411
|
+
phoenix/server/static/assets/vendor-arizeai-Dz0kN-lQ.js,sha256=hPa1rpMUjztQaAsf5h87E_RCDhcuWowkoTrfMaTS5_g,121519
|
|
412
|
+
phoenix/server/static/assets/vendor-codemirror-ClqtONZQ.js,sha256=zPD9V1TJW7mlnmIQcpjjaajHLATsDb0dxXnGsq24Qcg,413205
|
|
413
|
+
phoenix/server/static/assets/vendor-recharts-D6kvOpmb.js,sha256=AcaZOFH-ggGi-znCeAP_b072ALbIcPqhqYDZn63Hjps,231653
|
|
414
|
+
phoenix/server/static/assets/vendor-shiki-xSOiKxt0.js,sha256=itTnSRR18G_YLCygdVlLLqMrXHaPqjnD2Z6WcS4O9ro,305160
|
|
415
415
|
phoenix/server/static/assets/vendor-three-BLWp5bic.js,sha256=vfSCVXS20jA0Ceo_O0mDxYBcROinWMdPE6RR4JXmtec,620972
|
|
416
416
|
phoenix/server/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
417
417
|
phoenix/server/templates/index.html,sha256=QAYh0TG5mg-GvDQUR09aD9ebl9Sfq0fYAcfIa5G7J6E,7148
|
|
@@ -451,9 +451,9 @@ phoenix/utilities/project.py,sha256=auVpARXkDb-JgeX5f2aStyFIkeKvGwN9l7qrFeJMVxI,
|
|
|
451
451
|
phoenix/utilities/re.py,sha256=6YyUWIkv0zc2SigsxfOWIHzdpjKA_TZo2iqKq7zJKvw,2081
|
|
452
452
|
phoenix/utilities/span_store.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
453
453
|
phoenix/utilities/template_formatters.py,sha256=gh9PJD6WEGw7TEYXfSst1UR4pWWwmjxMLrDVQ_CkpkQ,2779
|
|
454
|
-
arize_phoenix-11.
|
|
455
|
-
arize_phoenix-11.
|
|
456
|
-
arize_phoenix-11.
|
|
457
|
-
arize_phoenix-11.
|
|
458
|
-
arize_phoenix-11.
|
|
459
|
-
arize_phoenix-11.
|
|
454
|
+
arize_phoenix-11.34.0.dist-info/METADATA,sha256=Gz2R_IDvu10Q5Ek_NSzZjyWxitfXO8VYnIgUxxxvOQ0,32877
|
|
455
|
+
arize_phoenix-11.34.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
456
|
+
arize_phoenix-11.34.0.dist-info/entry_points.txt,sha256=Pgpn8Upxx9P8z8joPXZWl2LlnAlGc3gcQoVchb06X1Q,94
|
|
457
|
+
arize_phoenix-11.34.0.dist-info/licenses/IP_NOTICE,sha256=JBqyyCYYxGDfzQ0TtsQgjts41IJoa-hiwDrBjCb9gHM,469
|
|
458
|
+
arize_phoenix-11.34.0.dist-info/licenses/LICENSE,sha256=HFkW9REuMOkvKRACuwLPT0hRydHb3zNg-fdFt94td18,3794
|
|
459
|
+
arize_phoenix-11.34.0.dist-info/RECORD,,
|
phoenix/config.py
CHANGED
|
@@ -134,6 +134,25 @@ ENV_PHOENIX_ENABLE_PROMETHEUS = "PHOENIX_ENABLE_PROMETHEUS"
|
|
|
134
134
|
"""
|
|
135
135
|
Whether to enable Prometheus. Defaults to false.
|
|
136
136
|
"""
|
|
137
|
+
ENV_PHOENIX_MAX_SPANS_QUEUE_SIZE = "PHOENIX_MAX_SPANS_QUEUE_SIZE"
|
|
138
|
+
"""
|
|
139
|
+
The maximum number of spans to hold in the processing queue before rejecting new requests.
|
|
140
|
+
|
|
141
|
+
This is a heuristic to prevent memory issues when spans accumulate faster than they can be
|
|
142
|
+
written to the database. When this limit is reached, new incoming requests will be rejected
|
|
143
|
+
to protect system memory.
|
|
144
|
+
|
|
145
|
+
Note: The actual queue size may exceed this limit due to batch processing. Requests are
|
|
146
|
+
accepted or rejected before spans are deserialized, but a single accepted request may
|
|
147
|
+
contain multiple spans. This behavior is intentional to balance memory protection with
|
|
148
|
+
processing efficiency.
|
|
149
|
+
|
|
150
|
+
Memory usage: If an average span takes ~50KiB of memory, then 20,000 spans would use ~1GiB
|
|
151
|
+
of memory. Adjust this value based on your system's available memory and expected database
|
|
152
|
+
throughput.
|
|
153
|
+
|
|
154
|
+
Defaults to 20000.
|
|
155
|
+
"""
|
|
137
156
|
ENV_LOGGING_MODE = "PHOENIX_LOGGING_MODE"
|
|
138
157
|
"""
|
|
139
158
|
The logging mode (either 'default' or 'structured').
|
|
@@ -1422,6 +1441,30 @@ def get_env_enable_prometheus() -> bool:
|
|
|
1422
1441
|
)
|
|
1423
1442
|
|
|
1424
1443
|
|
|
1444
|
+
def get_env_max_spans_queue_size() -> int:
|
|
1445
|
+
"""
|
|
1446
|
+
Gets the maximum spans queue size from the PHOENIX_MAX_SPANS_QUEUE_SIZE environment variable.
|
|
1447
|
+
|
|
1448
|
+
Returns:
|
|
1449
|
+
int: The maximum number of spans to hold in queue before rejecting requests.
|
|
1450
|
+
Defaults to 20,000 if not set.
|
|
1451
|
+
|
|
1452
|
+
Raises:
|
|
1453
|
+
ValueError: If the value is not a positive integer.
|
|
1454
|
+
|
|
1455
|
+
Note:
|
|
1456
|
+
The actual queue size may exceed this limit due to batch processing where a single
|
|
1457
|
+
accepted request can contain multiple spans. This is a heuristic for memory protection.
|
|
1458
|
+
"""
|
|
1459
|
+
max_size = _int_val(ENV_PHOENIX_MAX_SPANS_QUEUE_SIZE, 20_000)
|
|
1460
|
+
if max_size <= 0:
|
|
1461
|
+
raise ValueError(
|
|
1462
|
+
f"Invalid value for environment variable {ENV_PHOENIX_MAX_SPANS_QUEUE_SIZE}: "
|
|
1463
|
+
f"{max_size}. Value must be a positive integer."
|
|
1464
|
+
)
|
|
1465
|
+
return max_size
|
|
1466
|
+
|
|
1467
|
+
|
|
1425
1468
|
def get_env_client_headers() -> dict[str, str]:
|
|
1426
1469
|
headers = parse_env_headers(getenv(ENV_PHOENIX_CLIENT_HEADERS))
|
|
1427
1470
|
if (api_key := get_env_phoenix_api_key()) and "authorization" not in [
|
|
@@ -1684,6 +1727,7 @@ def verify_server_environment_variables() -> None:
|
|
|
1684
1727
|
get_env_database_allocated_storage_capacity_gibibytes()
|
|
1685
1728
|
get_env_database_usage_email_warning_threshold_percentage()
|
|
1686
1729
|
get_env_database_usage_insertion_blocking_threshold_percentage()
|
|
1730
|
+
get_env_max_spans_queue_size()
|
|
1687
1731
|
validate_env_support_email()
|
|
1688
1732
|
|
|
1689
1733
|
# Notify users about deprecated environment variables if they are being used.
|
phoenix/db/bulk_inserter.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import logging
|
|
3
3
|
from asyncio import Queue, as_completed
|
|
4
|
-
from collections
|
|
4
|
+
from collections import deque
|
|
5
5
|
from dataclasses import dataclass, field
|
|
6
6
|
from functools import singledispatchmethod
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from typing import Any, Optional, cast
|
|
7
|
+
from time import perf_counter, time
|
|
8
|
+
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, cast
|
|
10
9
|
|
|
11
10
|
from openinference.semconv.trace import SpanAttributes
|
|
12
11
|
from typing_extensions import TypeAlias
|
|
13
12
|
|
|
14
13
|
import phoenix.trace.v1 as pb
|
|
14
|
+
from phoenix.db import models
|
|
15
15
|
from phoenix.db.insertion.constants import DEFAULT_RETRY_ALLOWANCE, DEFAULT_RETRY_DELAY_SEC
|
|
16
16
|
from phoenix.db.insertion.document_annotation import DocumentAnnotationQueueInserter
|
|
17
17
|
from phoenix.db.insertion.evaluation import (
|
|
@@ -29,15 +29,23 @@ from phoenix.db.insertion.trace_annotation import TraceAnnotationQueueInserter
|
|
|
29
29
|
from phoenix.db.insertion.types import Insertables, Precursors
|
|
30
30
|
from phoenix.server.daemons.span_cost_calculator import (
|
|
31
31
|
SpanCostCalculator,
|
|
32
|
-
SpanCostCalculatorQueueItem,
|
|
33
32
|
)
|
|
34
33
|
from phoenix.server.dml_event import DmlEvent, SpanInsertEvent
|
|
34
|
+
from phoenix.server.prometheus import (
|
|
35
|
+
BULK_LOADER_EVALUATION_INSERTIONS,
|
|
36
|
+
BULK_LOADER_EXCEPTIONS,
|
|
37
|
+
BULK_LOADER_LAST_ACTIVITY,
|
|
38
|
+
BULK_LOADER_SPAN_EXCEPTIONS,
|
|
39
|
+
BULK_LOADER_SPAN_INSERTION_TIME,
|
|
40
|
+
SPAN_QUEUE_SIZE,
|
|
41
|
+
)
|
|
35
42
|
from phoenix.server.types import CanPutItem, DbSessionFactory
|
|
36
43
|
from phoenix.trace.schemas import Span
|
|
37
44
|
|
|
38
45
|
logger = logging.getLogger(__name__)
|
|
39
46
|
|
|
40
47
|
ProjectRowId: TypeAlias = int
|
|
48
|
+
ProjectName: TypeAlias = str
|
|
41
49
|
|
|
42
50
|
|
|
43
51
|
@dataclass(frozen=True)
|
|
@@ -52,12 +60,12 @@ class BulkInserter:
|
|
|
52
60
|
*,
|
|
53
61
|
event_queue: CanPutItem[DmlEvent],
|
|
54
62
|
span_cost_calculator: SpanCostCalculator,
|
|
55
|
-
initial_batch_of_spans:
|
|
56
|
-
initial_batch_of_evaluations:
|
|
63
|
+
initial_batch_of_spans: Iterable[tuple[Span, ProjectName]] = (),
|
|
64
|
+
initial_batch_of_evaluations: Iterable[pb.Evaluation] = (),
|
|
57
65
|
sleep: float = 0.1,
|
|
58
66
|
max_ops_per_transaction: int = 1000,
|
|
59
67
|
max_queue_size: int = 1000,
|
|
60
|
-
|
|
68
|
+
max_spans_queue_size: Optional[int] = None,
|
|
61
69
|
retry_delay_sec: float = DEFAULT_RETRY_DELAY_SEC,
|
|
62
70
|
retry_allowance: int = DEFAULT_RETRY_ALLOWANCE,
|
|
63
71
|
) -> None:
|
|
@@ -68,7 +76,6 @@ class BulkInserter:
|
|
|
68
76
|
:param max_ops_per_transaction: The maximum number of operations to dequeue from
|
|
69
77
|
the operations queue for each transaction.
|
|
70
78
|
:param max_queue_size: The maximum length of the operations queue.
|
|
71
|
-
:param enable_prometheus: Whether Prometheus is enabled.
|
|
72
79
|
"""
|
|
73
80
|
self._db = db
|
|
74
81
|
self._running = False
|
|
@@ -76,20 +83,20 @@ class BulkInserter:
|
|
|
76
83
|
self._max_ops_per_transaction = max_ops_per_transaction
|
|
77
84
|
self._operations: Optional[Queue[DataManipulation]] = None
|
|
78
85
|
self._max_queue_size = max_queue_size
|
|
79
|
-
self.
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
self._evaluations: list[pb.Evaluation] = (
|
|
83
|
-
[] if initial_batch_of_evaluations is None else list(initial_batch_of_evaluations)
|
|
84
|
-
)
|
|
86
|
+
self._max_spans_queue_size = max_spans_queue_size
|
|
87
|
+
self._spans: deque[tuple[Span, ProjectName]] = deque(initial_batch_of_spans)
|
|
88
|
+
self._evaluations: deque[pb.Evaluation] = deque(initial_batch_of_evaluations)
|
|
85
89
|
self._task: Optional[asyncio.Task[None]] = None
|
|
86
90
|
self._event_queue = event_queue
|
|
87
|
-
self._enable_prometheus = enable_prometheus
|
|
88
91
|
self._retry_delay_sec = retry_delay_sec
|
|
89
92
|
self._retry_allowance = retry_allowance
|
|
90
93
|
self._queue_inserters = _QueueInserters(db, self._retry_delay_sec, self._retry_allowance)
|
|
91
94
|
self._span_cost_calculator = span_cost_calculator
|
|
92
95
|
|
|
96
|
+
@property
|
|
97
|
+
def is_full(self) -> bool:
|
|
98
|
+
return bool(self._max_spans_queue_size and self._max_spans_queue_size <= len(self._spans))
|
|
99
|
+
|
|
93
100
|
async def __aenter__(
|
|
94
101
|
self,
|
|
95
102
|
) -> tuple[
|
|
@@ -102,9 +109,9 @@ class BulkInserter:
|
|
|
102
109
|
self._operations = Queue(maxsize=self._max_queue_size)
|
|
103
110
|
self._task = asyncio.create_task(self._bulk_insert())
|
|
104
111
|
return (
|
|
105
|
-
self.
|
|
106
|
-
self.
|
|
107
|
-
self.
|
|
112
|
+
self._enqueue_annotations,
|
|
113
|
+
self._enqueue_span,
|
|
114
|
+
self._enqueue_evaluation,
|
|
108
115
|
self._enqueue_operation,
|
|
109
116
|
)
|
|
110
117
|
|
|
@@ -114,23 +121,22 @@ class BulkInserter:
|
|
|
114
121
|
self._task.cancel()
|
|
115
122
|
self._task = None
|
|
116
123
|
|
|
117
|
-
async def
|
|
124
|
+
async def _enqueue_annotations(self, *items: Any) -> None:
|
|
118
125
|
await self._queue_inserters.enqueue(*items)
|
|
119
126
|
|
|
120
127
|
def _enqueue_operation(self, operation: DataManipulation) -> None:
|
|
121
128
|
cast("Queue[DataManipulation]", self._operations).put_nowait(operation)
|
|
122
129
|
|
|
123
|
-
async def
|
|
130
|
+
async def _enqueue_span(self, span: Span, project_name: str) -> None:
|
|
124
131
|
self._spans.append((span, project_name))
|
|
125
132
|
|
|
126
|
-
async def
|
|
133
|
+
async def _enqueue_evaluation(self, evaluation: pb.Evaluation) -> None:
|
|
127
134
|
self._evaluations.append(evaluation)
|
|
128
135
|
|
|
129
136
|
async def _process_events(self, events: Iterable[Optional[DataManipulationEvent]]) -> None: ...
|
|
130
137
|
|
|
131
138
|
async def _bulk_insert(self) -> None:
|
|
132
139
|
assert isinstance(self._operations, Queue)
|
|
133
|
-
spans_buffer, evaluations_buffer = None, None
|
|
134
140
|
# start first insert immediately if the inserter has not run recently
|
|
135
141
|
while (
|
|
136
142
|
self._running
|
|
@@ -139,6 +145,8 @@ class BulkInserter:
|
|
|
139
145
|
or self._spans
|
|
140
146
|
or self._evaluations
|
|
141
147
|
):
|
|
148
|
+
BULK_LOADER_LAST_ACTIVITY.set(time())
|
|
149
|
+
SPAN_QUEUE_SIZE.set(len(self._spans))
|
|
142
150
|
if (
|
|
143
151
|
self._queue_inserters.empty
|
|
144
152
|
and self._operations.empty()
|
|
@@ -156,113 +164,100 @@ class BulkInserter:
|
|
|
156
164
|
async with session.begin_nested():
|
|
157
165
|
await op(session)
|
|
158
166
|
except Exception as e:
|
|
159
|
-
|
|
160
|
-
from phoenix.server.prometheus import BULK_LOADER_EXCEPTIONS
|
|
161
|
-
|
|
162
|
-
BULK_LOADER_EXCEPTIONS.inc()
|
|
167
|
+
BULK_LOADER_EXCEPTIONS.inc()
|
|
163
168
|
logger.exception(str(e))
|
|
164
169
|
# It's important to grab the buffers at the same time so there's
|
|
165
170
|
# no race condition, since an eval insertion will fail if the span
|
|
166
171
|
# it references doesn't exist. Grabbing the eval buffer later may
|
|
167
172
|
# include an eval whose span is in the queue but missed being
|
|
168
173
|
# included in the span buffer that was grabbed previously.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
self._spans = []
|
|
172
|
-
if self._evaluations:
|
|
173
|
-
evaluations_buffer = self._evaluations
|
|
174
|
-
self._evaluations = []
|
|
174
|
+
num_spans_to_insert = min(self._max_ops_per_transaction, len(self._spans))
|
|
175
|
+
num_evals_to_insert = min(self._max_ops_per_transaction, len(self._evaluations))
|
|
175
176
|
# Spans should be inserted before the evaluations, since an evaluation
|
|
176
177
|
# insertion will fail if the span it references doesn't exist.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
spans_buffer = None
|
|
180
|
-
if evaluations_buffer:
|
|
181
|
-
await self._insert_evaluations(evaluations_buffer)
|
|
182
|
-
evaluations_buffer = None
|
|
178
|
+
await self._insert_spans(num_spans_to_insert)
|
|
179
|
+
await self._insert_evaluations(num_evals_to_insert)
|
|
183
180
|
async for event in self._queue_inserters.insert():
|
|
184
181
|
self._event_queue.put(event)
|
|
185
182
|
await asyncio.sleep(self._sleep)
|
|
186
183
|
|
|
187
|
-
async def _insert_spans(self,
|
|
184
|
+
async def _insert_spans(self, num_spans_to_insert: int) -> None:
|
|
185
|
+
if not num_spans_to_insert or not self._spans:
|
|
186
|
+
return
|
|
188
187
|
project_ids = set()
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
async with self._db() as session:
|
|
242
|
-
for evaluation in islice(evaluations, i, i + self._max_ops_per_transaction):
|
|
243
|
-
if self._enable_prometheus:
|
|
244
|
-
from phoenix.server.prometheus import BULK_LOADER_EVALUATION_INSERTIONS
|
|
245
|
-
|
|
246
|
-
BULK_LOADER_EVALUATION_INSERTIONS.inc()
|
|
247
|
-
try:
|
|
248
|
-
async with session.begin_nested():
|
|
249
|
-
await insert_evaluation(session, evaluation)
|
|
250
|
-
except InsertEvaluationError as error:
|
|
251
|
-
if self._enable_prometheus:
|
|
252
|
-
from phoenix.server.prometheus import BULK_LOADER_EXCEPTIONS
|
|
253
|
-
|
|
254
|
-
BULK_LOADER_EXCEPTIONS.inc()
|
|
255
|
-
logger.exception(f"Failed to insert evaluation: {str(error)}")
|
|
256
|
-
if self._enable_prometheus:
|
|
257
|
-
from phoenix.server.prometheus import BULK_LOADER_INSERTION_TIME
|
|
258
|
-
|
|
259
|
-
BULK_LOADER_INSERTION_TIME.observe(perf_counter() - start)
|
|
260
|
-
except Exception:
|
|
261
|
-
if self._enable_prometheus:
|
|
262
|
-
from phoenix.server.prometheus import BULK_LOADER_EXCEPTIONS
|
|
188
|
+
span_costs: list[models.SpanCost] = []
|
|
189
|
+
try:
|
|
190
|
+
start = perf_counter()
|
|
191
|
+
async with self._db() as session:
|
|
192
|
+
while num_spans_to_insert > 0:
|
|
193
|
+
num_spans_to_insert -= 1
|
|
194
|
+
if not self._spans:
|
|
195
|
+
break
|
|
196
|
+
span, project_name = self._spans.popleft()
|
|
197
|
+
result: Optional[SpanInsertionEvent] = None
|
|
198
|
+
try:
|
|
199
|
+
async with session.begin_nested():
|
|
200
|
+
result = await insert_span(session, span, project_name)
|
|
201
|
+
except Exception:
|
|
202
|
+
BULK_LOADER_SPAN_EXCEPTIONS.inc()
|
|
203
|
+
logger.exception(
|
|
204
|
+
f"Failed to insert span with span_id={span.context.span_id}"
|
|
205
|
+
)
|
|
206
|
+
if result is None:
|
|
207
|
+
continue
|
|
208
|
+
project_ids.add(result.project_rowid)
|
|
209
|
+
try:
|
|
210
|
+
if not should_calculate_span_cost(span.attributes):
|
|
211
|
+
continue
|
|
212
|
+
span_cost = self._span_cost_calculator.calculate_cost(
|
|
213
|
+
span.start_time,
|
|
214
|
+
span.attributes,
|
|
215
|
+
)
|
|
216
|
+
except Exception:
|
|
217
|
+
logger.exception(
|
|
218
|
+
f"Failed to calculate span cost for span with "
|
|
219
|
+
f"span_id={span.context.span_id}"
|
|
220
|
+
)
|
|
221
|
+
else:
|
|
222
|
+
if span_cost is None:
|
|
223
|
+
continue
|
|
224
|
+
span_cost.span_rowid = result.span_rowid
|
|
225
|
+
span_cost.trace_rowid = result.trace_rowid
|
|
226
|
+
span_costs.append(span_cost)
|
|
227
|
+
BULK_LOADER_SPAN_INSERTION_TIME.observe(perf_counter() - start)
|
|
228
|
+
except Exception:
|
|
229
|
+
BULK_LOADER_SPAN_EXCEPTIONS.inc()
|
|
230
|
+
logger.exception("Failed to insert spans")
|
|
231
|
+
if project_ids:
|
|
232
|
+
self._event_queue.put(SpanInsertEvent(tuple(project_ids)))
|
|
233
|
+
if not span_costs:
|
|
234
|
+
return
|
|
235
|
+
try:
|
|
236
|
+
async with self._db() as session:
|
|
237
|
+
session.add_all(span_costs)
|
|
238
|
+
except Exception:
|
|
239
|
+
logger.exception("Failed to insert span costs")
|
|
263
240
|
|
|
264
|
-
|
|
265
|
-
|
|
241
|
+
async def _insert_evaluations(self, num_evals_to_insert: int) -> None:
|
|
242
|
+
if not num_evals_to_insert or not self._evaluations:
|
|
243
|
+
return
|
|
244
|
+
try:
|
|
245
|
+
async with self._db() as session:
|
|
246
|
+
while num_evals_to_insert > 0:
|
|
247
|
+
num_evals_to_insert -= 1
|
|
248
|
+
if not self._evaluations:
|
|
249
|
+
break
|
|
250
|
+
evaluation = self._evaluations.popleft()
|
|
251
|
+
BULK_LOADER_EVALUATION_INSERTIONS.inc()
|
|
252
|
+
try:
|
|
253
|
+
async with session.begin_nested():
|
|
254
|
+
await insert_evaluation(session, evaluation)
|
|
255
|
+
except InsertEvaluationError as error:
|
|
256
|
+
BULK_LOADER_EXCEPTIONS.inc()
|
|
257
|
+
logger.exception(f"Failed to insert evaluation: {str(error)}")
|
|
258
|
+
except Exception:
|
|
259
|
+
BULK_LOADER_EXCEPTIONS.inc()
|
|
260
|
+
logger.exception("Failed to insert evaluations")
|
|
266
261
|
|
|
267
262
|
|
|
268
263
|
class _QueueInserters:
|
|
@@ -82,7 +82,7 @@ async def annotate_span_documents(
|
|
|
82
82
|
annotation.as_precursor(user_id=user_id) for annotation in span_document_annotations
|
|
83
83
|
]
|
|
84
84
|
if not sync:
|
|
85
|
-
await request.state.
|
|
85
|
+
await request.state.enqueue_annotations(*precursors)
|
|
86
86
|
return AnnotateSpanDocumentsResponseBody(data=[])
|
|
87
87
|
|
|
88
88
|
span_ids = {p.span_id for p in precursors}
|
|
@@ -102,7 +102,7 @@ async def post_evaluations(
|
|
|
102
102
|
detail="Evaluation name must not be blank/empty",
|
|
103
103
|
status_code=HTTP_422_UNPROCESSABLE_ENTITY,
|
|
104
104
|
)
|
|
105
|
-
await request.state.
|
|
105
|
+
await request.state.enqueue_evaluation(evaluation)
|
|
106
106
|
return Response()
|
|
107
107
|
|
|
108
108
|
|
|
@@ -221,7 +221,7 @@ async def _add_evaluations(state: State, evaluations: Evaluations) -> None:
|
|
|
221
221
|
explanation=explanation,
|
|
222
222
|
metadata_={},
|
|
223
223
|
)
|
|
224
|
-
await state.
|
|
224
|
+
await state.enqueue_annotations(document_annotation)
|
|
225
225
|
elif len(names) == 1 and names[0] in ("context.span_id", "span_id"):
|
|
226
226
|
for index, row in dataframe.iterrows():
|
|
227
227
|
score, label, explanation = _get_annotation_result(row)
|
|
@@ -235,7 +235,7 @@ async def _add_evaluations(state: State, evaluations: Evaluations) -> None:
|
|
|
235
235
|
explanation=explanation,
|
|
236
236
|
metadata_={},
|
|
237
237
|
)
|
|
238
|
-
await state.
|
|
238
|
+
await state.enqueue_annotations(span_annotation)
|
|
239
239
|
elif len(names) == 1 and names[0] in ("context.trace_id", "trace_id"):
|
|
240
240
|
for index, row in dataframe.iterrows():
|
|
241
241
|
score, label, explanation = _get_annotation_result(row)
|
|
@@ -249,7 +249,7 @@ async def _add_evaluations(state: State, evaluations: Evaluations) -> None:
|
|
|
249
249
|
explanation=explanation,
|
|
250
250
|
metadata_={},
|
|
251
251
|
)
|
|
252
|
-
await state.
|
|
252
|
+
await state.enqueue_annotations(trace_annotation)
|
|
253
253
|
|
|
254
254
|
|
|
255
255
|
def _get_annotation_result(
|
|
@@ -897,7 +897,7 @@ async def annotate_spans(
|
|
|
897
897
|
)
|
|
898
898
|
precursors = [d.as_precursor(user_id=user_id) for d in filtered_span_annotations]
|
|
899
899
|
if not sync:
|
|
900
|
-
await request.state.
|
|
900
|
+
await request.state.enqueue_annotations(*precursors)
|
|
901
901
|
return AnnotateSpansResponseBody(data=[])
|
|
902
902
|
|
|
903
903
|
span_ids = {p.span_id for p in precursors}
|
|
@@ -1072,7 +1072,7 @@ async def create_spans(
|
|
|
1072
1072
|
|
|
1073
1073
|
# All spans are valid, queue them all
|
|
1074
1074
|
for span_for_insertion, project_name in spans_to_queue:
|
|
1075
|
-
await request.state.
|
|
1075
|
+
await request.state.enqueue_span(span_for_insertion, project_name)
|
|
1076
1076
|
|
|
1077
1077
|
return CreateSpansResponseBody(
|
|
1078
1078
|
total_received=total_received,
|