Skip to content

feat: add instrumentation to address error rates#600

Merged
zimeg merged 5 commits intomainfrom
zimeg-feat-instrument
May 1, 2026
Merged

feat: add instrumentation to address error rates#600
zimeg merged 5 commits intomainfrom
zimeg-feat-instrument

Conversation

@zimeg
Copy link
Copy Markdown
Member

@zimeg zimeg commented May 1, 2026

Summary

This PR adds instrumentation to address error rates with a User-Agent header added to requests 🎹

Preview

With additional logging in development to reveal we find these headers for different techniques:

API Method

@slack:slack-github-action/3.0.2 @slack:web-api/7.15.0 node/24.15.0 linux/6.12.76-linuxkit

Webhook

@slack:slack-github-action/3.0.2 axios/1.15.0 node/24.15.0 linux/6.12.76-linuxkit

CLI

🎺 Instrumentation is left to adjacent implementations for installations and particular command usage.

Requirements

@zimeg zimeg added this to the 3.1 milestone May 1, 2026
@zimeg zimeg self-assigned this May 1, 2026
@zimeg zimeg added enhancement New feature or request semver:patch labels May 1, 2026
@zimeg zimeg requested a review from a team as a code owner May 1, 2026 03:28
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 709a4d6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/slack-github-action Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (feba1e2) to head (709a4d6).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #600   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files           7        7           
  Lines         718      736   +18     
=======================================
+ Hits          717      735   +18     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member Author

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏛️ A few comments follow for the amazing reviewers!

Comment thread src/config.js
Comment on lines +140 to +144
this.axios.defaults.headers.common["User-Agent"] =
`${packageJson.name.replace("/", ":")}/${packageJson.version} ` +
`axios/${this.axios.VERSION} ` +
`node/${process.version.replace("v", "")} ` +
`${os.platform()}/${os.release()}`;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪬 thought: We should prefer the @slack/webhook package if support is added for Workflow Builder but for now we match the format:

https://github.com/slackapi/node-slack-sdk/blob/4af912df43532331d17bddfd4f9c47157e5160ea/packages/webhook/src/instrument.ts#L12-L15

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 💯 recently we had to update the user agent from the web-api so that it is compliant with latin1, but I think this implementation does not need this patch since we aren't including the process.title

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilliamBergamin For this implementation let's keep node fixed instead of the process title but I do think we should mirror these changes upstream to @slack/webhook in future improvements 🎁

Comment thread test/config.spec.js
Comment on lines +164 to +185
it("adds metadata to webapi with package name and version", async () => {
const stub = sinon.stub();
const original = Object.getOwnPropertyDescriptor(
webapi,
"addAppMetadata",
);
Object.defineProperty(webapi, "addAppMetadata", {
value: stub,
configurable: true,
});
try {
mocks.core.getInput.withArgs("method").returns("chat.postMessage");
mocks.core.getInput.withArgs("token").returns("xoxb-example");
new Config(mocks.core);
assert.ok(stub.calledOnce);
const { name, version } = stub.firstCall.args[0];
assert.equal(name, "@slack/slack-github-action");
assert.ok(version);
} finally {
Object.defineProperty(webapi, "addAppMetadata", original);
}
});
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 note: We don't capture actual requests in tests at the moment so this is our current approach to checking expected behavior.

🔭 thought: Recent node improvements might allow us to improve how we test overall:

A little-known fact is that there is a builtin way to mock fetch.

📚 https://nodejs.org/learn/test-runner/mocking#apis

Comment thread package.json
@@ -1,5 +1,5 @@
{
"name": "slack-github-action",
"name": "@slack/slack-github-action",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 💯 praise 🙏

Copy link
Copy Markdown
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job 💯

Comment thread package.json
@@ -1,5 +1,5 @@
{
"name": "slack-github-action",
"name": "@slack/slack-github-action",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 💯 praise 🙏

Comment thread src/config.js
Comment on lines +140 to +144
this.axios.defaults.headers.common["User-Agent"] =
`${packageJson.name.replace("/", ":")}/${packageJson.version} ` +
`axios/${this.axios.VERSION} ` +
`node/${process.version.replace("v", "")} ` +
`${os.platform()}/${os.release()}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 💯 recently we had to update the user agent from the web-api so that it is compliant with latin1, but I think this implementation does not need this patch since we aren't including the process.title

@zimeg
Copy link
Copy Markdown
Member Author

zimeg commented May 1, 2026

@WilliamBergamin Thank you for taking the time to review this PR 🙏 ✨ I'll merge this alongside recent package updates in #604 for upcoming release! 🚀

@zimeg zimeg merged commit 66834e4 into main May 1, 2026
13 checks passed
@zimeg zimeg deleted the zimeg-feat-instrument branch May 1, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants