Page MenuHomePhabricator

MediaWiki OLTPExporter fails when passed attribute is an array
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

$tracer = MediaWikiServices::getInstance()->getTracer();
$span = $tracer->createSpan( 'Causing problems' )->start();
$span->setAttributes( [
 'expand' => [ 'key_one', 'key_two' ]
);

What happens?:
The code doesn't complain about storing the span, but when trying to export it the OtlpHttpExporter fails to export the trace.
I assume that the problem is most likely around the OtlpSerializer - how the data being sent to OTEL collector is serialized. Instead of getting http code 200 during export to the collector, we get 400:

A sample collector response for a failed export is:

http_code:  400
http_response: {"code":3,"message":"ReadObjectCB: expect { or n, but found [, error found in #10 byte of ...|ayValue\":[\"trust_and|..., bigger context ...|\"Lublin\"}},{\"key\":\"expand\",\"value\":{\"arrayValue\":[\"trust_and_relevance\",\"calls_to_action\"]}}]},{\"tra|..."}

Request_ID: 86d13b3b-aff4-4059-adaf-68397e282aa8

This error is beggin logged in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/4e6b470be5150281cea6e64e1efb68126e1f7056/includes/libs/Telemetry/OtlpHttpExporter.php#92

What should have happened instead?:
It should log the trace. Probably it would be good to also have some checks on what can be stored as an attribute as currently there is zero validation.

Event Timeline

Change #1270471 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/extensions/WikimediaCustomizations@master] Telemetry: Attribution: Pass expand attribute as string

https://gerrit.wikimedia.org/r/1270471

Change #1270471 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Telemetry: Attribution: Pass expand attribute as string

https://gerrit.wikimedia.org/r/1270471

The fix attached to this ticket is not the fix for the issue, but a workaround around this bug. The root cause ( invalid serialization of arrays ) still has to be handled.