Skip to content

Commit bd6aa2e

Browse files
authored
Use portable path for OTLP helper guidance (#62940)
1 parent 7334b08 commit bd6aa2e

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎.github/aw/syntax-agentic.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ description: Agentic workflow specific frontmatter fields for GitHub Agentic Wor
180180

181181
Every job emits setup and conclusion spans with rich attributes (`gh-aw.job.name`, `gh-aw.workflow.name`, `gh-aw.engine.id`, token usage). All jobs in a run share one trace ID. Dispatched child workflows inherit the parent's trace context via `aw_context`.
182182

183+
To emit a custom span from a `github-script` step, resolve the helper through `RUNNER_TEMP` rather than a hardcoded `/tmp` path:
184+
185+
```javascript
186+
const path = require('path');
187+
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
188+
```
189+
183190
- **`runtimes:`** - Runtime environment version overrides (object)
184191
- Allows customizing runtime versions (e.g., Node.js, Python) or defining new runtimes
185192
- Runtimes from imported shared workflows are also merged

‎.github/aw/token-optimization-observability.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ observability:
2323
2424
Setup, agent, and conclusion spans carry token usage attributes. See [Frontmatter syntax](syntax-agentic.md#agentic-workflow-specific-fields).
2525
26+
When a `github-script` step needs a custom span, load the helper from the portable runner temporary directory:
27+
28+
```javascript
29+
const path = require('path');
30+
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
31+
```
32+
2633
### Add AgenticOps token workflows
2734

2835
- `copilot-token-audit` — scheduled audit of token usage across workflows

‎actions/setup/js/otlp.cjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
*
1919
* Usage (in a `steps:` github-script step inside a shared import):
2020
*
21-
* const otlp = require('/tmp/gh-aw/actions/otlp.cjs');
21+
* const path = require('path');
22+
* const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
2223
* const start = Date.now();
2324
* // ... do work ...
2425
* await otlp.logSpan('my-tool', { 'my-tool.items_processed': 42, 'my-tool.result': 'ok' }, { startMs: start });

‎docs/src/content/docs/experimental/qmd.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ steps:
132132
with:
133133
script: |
134134
const fs = require('fs');
135-
const otlp = require('/tmp/gh-aw/actions/otlp.cjs');
135+
const path = require('path');
136+
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
136137
137138
// qmd writes index stats to /tmp/gh-aw/qmd/stats.json after indexing.
138139
let indexSize = 0;

‎docs/src/content/docs/reference/open-telemetry.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ steps:
170170
uses: actions/github-script@v8
171171
with:
172172
script: |
173-
const otlp = require('/tmp/gh-aw/actions/otlp.cjs');
173+
const path = require('path');
174+
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
174175
175176
const startMs = Date.now();
176177
// ... do your tool's work here (e.g. const result = await myTool.run()) ...
@@ -206,7 +207,8 @@ Run the daily report using my-tool results.
206207
**`logSpan` API**
207208

208209
```javascript
209-
const otlp = require('/tmp/gh-aw/actions/otlp.cjs');
210+
const path = require('path');
211+
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
210212
211213
await otlp.logSpan(toolName, attributes, options);
212214
```

0 commit comments

Comments
 (0)