- Decision on query parameters and how exactly this endpoint is called (outside this task, conversation happening)
- Heartbeat monitor for this to make sure it's up and serving config to Varnish config fetcher. Alerts set up to fix if not
- Integration tests to validate format
- Assign bin ranges in Varnish format in a simple greedy algorithm
- xLab experiments API should include recently concluded (<24h) experiments
Some details here (for the first approach we will use directly the full group names because features won’t be added to the events for now)
const fs = require('fs') const path = require('path') const yaml = require('yaml') const dayjs = require('dayjs') const rawContents = fs.readFileSync(path.resolve(__dirname, 'input.yaml'), 'utf-8') const { experiments } = yaml.parse(rawContents) const dbnameToDomainNameMap = require(path.resolve(__dirname, 'dbname_to_domain_name_map.json')) const result = Object.entries(experiments) .reduce( (acc, [experimentName, experimentConfig]) => { const { groups, projects } = experimentConfig const domains = Object.entries(projects).reduce( (acc, [project, projectConfig]) => { const sampleSizePerGroup = projectConfig.sample_size / groups.length const binRangeSizePerGroup = sampleSizePerGroup * 100_000 const entry = {} entry.groups = {} for (let i = 0; i < groups.length; ++i) { let group = groups[i] if (typeof group === 'object') { const t = Object.entries(group)[0] group = t[0] entry.groups[`_comment_${t[0]}`] = t[1].description } entry.groups[group] = [ i * binRangeSizePerGroup, (i + 1) * binRangeSizePerGroup - 1 ] } const { domain_name: domainName, mobile_domain_name: mobileDomainName } = dbnameToDomainNameMap[project] acc[mobileDomainName] = acc[domainName] = entry return acc }, {} ) const entry = {} if (experimentConfig.description) { entry._comment = experimentConfig.description } entry.start = dayjs(experimentConfig.utc_start_date).format('YYYY-MM-DDTHH:mm:ss[Z]') entry.end = dayjs(experimentConfig.utc_end_date).format('YYYY-MM-DDTHH:mm:ss[Z]') entry.domains = domains acc[experimentName] = entry return acc }, {} ) console.log(JSON.stringify(result, null, 2))
