MCPcopy Create free account
hub / github.com/github/gh-aw / buildExperimentAttributes

Function buildExperimentAttributes

actions/setup/js/send_otlp_span.cjs:691–709  ·  view source on GitHub ↗

* Build OTLP span attributes for the active experiment assignments. * * Adds one `gh-aw.experiment. ` attribute per experiment (carrying the * selected variant string) and a single `gh-aw.experiments` attribute with a * compact JSON string of only the valid emitted assignments (key-sorted f

(assignments)

Source from the content-addressed store, hash-verified

689 * @returns {Array<{key: string, value: object}>}
690 */
691function buildExperimentAttributes(assignments) {
692 if (!assignments || typeof assignments !== "object") return [];
693 const names = Object.keys(assignments).sort();
694 if (names.length === 0) return [];
695 const attrs = [];
696 /** @type {Record<string, string>} */
697 const validAssignments = {};
698 for (const name of names) {
699 const variant = assignments[name];
700 if (typeof variant === "string" && variant) {
701 attrs.push(buildAttr(`gh-aw.experiment.${name}`, variant));
702 validAssignments[name] = variant;
703 }
704 }
705 if (attrs.length > 0) {
706 attrs.push(buildAttr("gh-aw.experiments", JSON.stringify(validAssignments)));
707 }
708 return attrs;
709}
710
711// ---------------------------------------------------------------------------
712// Custom OTLP attributes (GH_AW_OTLP_ATTRIBUTES)

Callers 3

sendJobSetupSpanFunction · 0.85
sendJobConclusionSpanFunction · 0.85

Calls 1

buildAttrFunction · 0.85

Tested by

no test coverage detected