Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture action plugin metrics #971

Merged
merged 9 commits into from
Oct 18, 2023
Merged

Conversation

zikaari
Copy link
Contributor

@zikaari zikaari commented Oct 16, 2023

Just like how we capture metrics relating to performance of classic integrations, this patch now enables capturing of metrics related to action destinations as well.

@zikaari zikaari requested review from oscb and silesky October 16, 2023 22:50
@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2023

🦋 Changeset detected

Latest commit: 27ca0dd

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

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Minor

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

Copy link
Contributor

@oscb oscb left a comment

Choose a reason for hiding this comment

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

just a very minor comment, every thing else looks good!

packages/browser/src/plugins/remote-loader/index.ts Outdated Show resolved Hide resolved
@@ -79,7 +79,21 @@ export class ActionDestination implements DestinationPlugin {
transformedContext = await this.transform(ctx)
}

await this.action[methodName]!(transformedContext)
try {
ctx.stats.increment('analytics_js.action_plugin.invoke', 1, [
Copy link
Contributor

Choose a reason for hiding this comment

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

This will let us easily aggregate these on datadog??? Sweet


await this.action[methodName]!(transformedContext)
} catch (error) {
ctx.stats.increment('analytics_js.action_plugin.invoke.error', 1, [
Copy link
Contributor

@silesky silesky Oct 17, 2023

Choose a reason for hiding this comment

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

We are repeating these strings / args . Can we save on bundle size through helper functions? Ditto elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gzip is extremely good at handling repeating strings, I've verified it - sometimes placing the strings inline yields a smaller size than storing it in a variable.

Copy link
Contributor

@silesky silesky Oct 17, 2023

Choose a reason for hiding this comment

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

Even so, I still think DRY would be an improvement here for the usual reasons (eg less code/ease of update)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's like this all across the codebase, we should refactor them all at once so that the declaration and usage is standardized all across, and not fragment it even further.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the benefit of storing in a variable more that we have 1 place to update/less chance of a typo/forgetting to update the value if we change it in the future. Won't block, but that would be my general guidance when we've got a string value that acts as a key in downstream.

@zikaari zikaari requested a review from silesky October 17, 2023 19:48
@@ -0,0 +1,5 @@
---
'@segment/analytics-next': minor
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a patch, since it's not a user-facing feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw it more as a "non-breaking enhancement" than a bug fix - so went with it

Copy link
Contributor

Choose a reason for hiding this comment

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

Would vote for patch since it isn't a user-facing change to any API/API behavior.

@zikaari zikaari merged commit 2f1ae75 into master Oct 18, 2023
5 checks passed
@zikaari zikaari deleted the capture_action_plugin_metrics branch October 18, 2023 22:35
@github-actions github-actions bot mentioned this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants