Page MenuHomePhabricator

🧬 Investigate measuring federation on WDQS/WBQS UI
Closed, DeclinedPublic

Description

Context

We want to measure query federation in the Wikibase ecosystem to be able to evaluate the success of our initiatives focused on improving it. See details in the main doc.

We are currently looking for a metric that could be used that is 1) easiest to measure, 2) provides meaningful insights that can drive our work.

One of the approaches we decided to explore is measuring on the Query Service UI.
+: Naturally mitigates the effect of subqueries coming from other SPARQL endpoints, only focusing on the 'original' queries.
-: Completely ignores the 'original' queries that were executed from a client different from Query Service UI (for example, Python notebooks).

Task

Measure:

  • A: # of federated queries that started on a specific WD/WBQS UI in the last day/week/month
  • B: # of non-federated queries that started on this WD/WBQS UI in the last day/week/month

Our metric is A/(A+B).

Acceptance Criteria

Write a report on Phabricator that assesses the feasibility of a future set of work that builds something like:

  1. No dashboard required at this point, but we should be able to run this measurement ad hoc for a given WD/WBQS UI to get the measurement.
  2. For WBQS UI on Cloud, we should be able to get measurements for all running Wikibases separately.

It's not necessary to fully implement this metrics but having a plan of work with some of the tickets necessary would be desirable.

Notes

  1. When analyzing a script, we should not consider it federated if the SERVICE syntax is only used for utilizing helpers. See example chat with GPT on this topic. One approach to recognizing proper federation would be to compare the URL after SERVICE with the instance's Allowlist. If this is not available yet out of the box, another cheapest meaningful solution could be used in the prototype.
  2. The PrPL team is already experimenting with doing similar analysis of queries on the front end (although, they are classifying them according to different criteria). Please get in touch with them where possible. T391264 cc: @Ifrahkhanyaree_WMDE @AndrewTavis_WMDE @ItamarWMDE

Event Timeline

Tarrow renamed this task from Investigate capturing queries from WDQS/WBQS UI to 🧬 Investigate capturing queries from WDQS/WBQS UI.May 22 2025, 8:26 AM
Tarrow claimed this task.
Anton.Kokh renamed this task from 🧬 Investigate capturing queries from WDQS/WBQS UI to 🧬 Investigate measuring federation on WDQS/WBQS UI.May 22 2025, 2:50 PM

Short summary of Thursday:

  • Started looking at the work in https://gitlab.wikimedia.org/repos/wmde/wikidata-query-gui/-/merge_requests/11
    • hopeful that maybe we could use a similar method of identifying queries in JS but clearly it's not trivial
  • Considered that to get metrics out of this we're very happy to see the move to prometheus but we'd still need to set up the stats/statsv equivalent endpoints for us
  • Open question to check: do Wikibase Queryservice UIs actually already submit stats to query.wikidata.org accidentally?
Anton.Kokh updated the task description. (Show Details)
Anton.Kokh added a subscriber: AndrewTavis_WMDE.
Anton.Kokh added a subscriber: ItamarWMDE.

Open question to check: do Wikibase Queryservice UIs actually already submit stats to query.wikidata.org accidentally?

From my quick checking inspecting the requests from my browser this doesn't seem to be the case.

I looked a bit more at the query service UI tracking stuff and I discovered that it only works for wikidata.org where it was recently fixed see T391532 and this specific line of code: https://gitlab.wikimedia.org/repos/wmde/wikidata-query-gui/-/blob/main/wikibase/queryService/api/TrackingFactory.js#L9

I've gone ahead and tried to ask a bit about the details on that ticket to get an idea of how that might work on either cloud or suite

Looked a small amount at wdqs-gui and came the the conclusion that if we wanted to benefit from the work upstream the lowest effort workflow collecting metrics from the UI would probably look like:

  • reconcile all upstream changes (DRAFT PR doing this rebase in an unwise way) in order to benefit from:
    • new "stats" collection (now via dogstatsd and prometheus)
    • any work done on parsing queries and trying to identify types of them
  • introduce new config option to enable metric collection not only on wikidata but also on wikibases with a custom "stats" endpoint
  • deploy a prometheus statsd exporter for wikibase clouds to phone home to
  • introduce our own query parsing and then report metrics after categorising queries into the above buckets
  • deploy on wikidata and on cloud
  • talk to suite about turning on this metrics collection too
    • see if they would want to by default push metrics up to WMF
    • or to a locally hosted prometheus-statsd-exporter + prometheus

As we discussed today I'll hand this over (with a proper call tomorrow) since I believe it's not possible for someone without access to hive to work on T395044

@dena and I think that a great first step is to sync our fork with upstream and try and rationalise the changes. We would want to then ship this to our staging and production. This would put in place the ground work for collecting metrics using prometheus. We'll make a new ticket for this bit of work.

Tarrow removed dena as the assignee of this task.Jun 5 2025, 8:26 AM
Tarrow moved this task from Doing to To do on the Wikibase Cloud (Kanban Board Q2 2025) board.
Tarrow added a subscriber: dena.

We're going to deprioritise this ticket in favour of the collecting the metrics from the backend of Wikidata Queryservice

Anton.Kokh subscribed.

We decided to proceed with measurements on backend for now