Page MenuHomePhabricator

Add support for request tracing to WikimediaDebug browser extension
Open, MediumPublic

Description

Extend WikimediaDebug extension to support a new "Application tracing" option.

When "Application tracing" is enabled, the browser should send X-Wikimedia-Debug header with tracing

Headers example:

With tracing disabled: backend=mwdebug2001.codfw.wmnet
With tracing enabled: backend=mwdebug2001.codfw.wmnet; tracing

Implementation steps
  • Expose tracestate/traceparent information in response headers
  • SRE provides a URL to preview the request trace
  • Update the Extension - add the "Application Tracing" as one of options.
  • Document new option in https://wikitech.wikimedia.org/wiki/WikimediaDebug
  • Deploy new extension
  • Upload to Chrome Webstore
  • Upload to Firefox Add-ons
  • Announce to Wikitech-l

Event Timeline

Krinkle renamed this task from WikimediaDebug browser extension is able force a trace on the next request to Add support for request tracing to WikimediaDebug browser extension.Jul 3 2023, 6:44 PM

I see two tickets here, one to add tracing headers to the response (same as X-Request-ID), and second ticket to modify the extension to show additional fields.

@CDanis could you elaborate a little bit on this one? What do you mean "force a distributed tracing" ?

Currently there is no way to enforce distributed tracing. What we do - we only forward the tracestate and traceparent headers. And until MediaWiki supports OpenTelemetry-PHP library I don't see a way to force the tracing.

What we can do is to return tracestate and traceparent headers in the response - the same we do for X-Request-Id. Therefore if requests go to any of mwdebug hosts - it will get tracestate and traceparent.

Is there anything you think of in the current (MVP) state? Or is it something for future when we have the OpenTelementry integration?

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

[mediawiki/core@master] http: HeaderCallback should inject all telemetry headers

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

Change 957302 merged by jenkins-bot:

[mediawiki/core@master] http: HeaderCallback should inject all telemetry headers

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

After a conversation with @CDanis, we clarified that this ticket is about modifying the WikimediaDebug extension to add a new checkbox to trigger the tracing on the edge. I'll update the ticket description and fill in all necessary information.

@CDanis before I proceed with this work, I would need the URL template that the Debug Extension would point to. For example. when we enable the Profiler, there is a code in the extension that would add the URL to code:

if ( debug.state.profile && reqId ) {
    links.push( {
        label: 'Find in XHGui',
        href: isBeta
            ? 'https://performance.wikimedia.beta.wmflabs.org/xhgui/?url=' + reqId
            : 'https://performance.wikimedia.org/xhgui/?url=' + reqId
    } );
}

It would be great to add a link to tracing data when "Application tracing" is forced. Please update the ticket description and add a link that WikimediaDebug extension should point to per each request.

For future reference - https://gerrit.wikimedia.org/r/c/performance/WikimediaDebug/+/902566 is the ChangeId that added new "Excimer UI" option to the WikimediaDebug extension.

@CDanis FYI: when the extension is enabled for the current request - it adds the header X-Wikimedia-Debug. This header value is a list of attributes concatenated with ;.

Possible attributes can be found here: https://wikitech.wikimedia.org/wiki/WikimediaDebug#Options. We will add a new attribute tracing, that will be added to the header when tracing is enabled.
An example of a header when multiple options, including tracing, are enabled: X-Wikimedia-Debug: backend=mwdebug2001.codfw.wmnet; forceprofile; readonly; log; tracing.

Please note, that there is a space after ;, and the order of attributes might change with time (do not assume that tracing will be the last thing in the string).
In case you're interested - this is the code that builds the header: https://gerrit.wikimedia.org/r/plugins/gitiles/performance/WikimediaDebug/+/refs/heads/master/background.js#95

@Krinkle is there anything else we need to add/consider?

pmiazga triaged this task as Medium priority.Oct 20 2023, 2:27 PM

Thanks so much @pmiazga ! This is great to see and the spec chosen for the header sounds good.

@CDanis before I proceed with this work, I would need the URL template that the Debug Extension would point to. For example. when we enable the Profiler, there is a code in the extension that would add the URL to code: [...]
It would be great to add a link to tracing data when "Application tracing" is forced. Please update the ticket description and add a link that WikimediaDebug extension should point to per each request.

I'll need to get back to you about the URL. We don't have jaeger-ui wired up to the CDN yet, but hopefully will soon.

As a possible extra complication, it's also very likely that we're going to require Wikimedia developer SSO in order to interact with traces...

Let me move this to "Blocked/waiting" on the Platform Team Board. We need the prod/beta URL template to allow links to generated traces.

I'll need to get back to you about the URL. We don't have jaeger-ui wired up to the CDN yet, but hopefully will soon.

As a possible extra complication, it's also very likely that we're going to require Wikimedia developer SSO in order to interact with traces...

https://trace.wikimedia.org/ exists now and as foretold is using idp.wikimedia.org SSO for authentication.

Removing myself as I'm not actively working on it.