Skip to content

add /.export-stats endpoint to dump stats table #169

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged

Conversation

willnorris
Copy link
Member

This is really bare bones, but at least lets us get the stats data out. This also made it clear to me how brittle some of our tests are because of how much global state we have in the top-level golink package. We should probably move all of that into a server type or something similar before too long.

Updates #168

Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d

@willnorris willnorris requested review from mikeodr and patrickod April 18, 2025 21:58
@willnorris
Copy link
Member Author

Also worth noting that the stats are aggregate (within their time periods) and do not include any user data about who clicked on which links. Hence why this is fine to expose to all users that can access the golink instance.

http.Error(w, err.Error(), http.StatusInternalServerError)
}
}()

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the header be added to the output?

Suggested change
fmt.Fprint(w, "link ID, UNIX timestamp, and click count")

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe? The data is pretty simple, and I'm not sure what this is going to get imported into and whether it can easily ignore header rows. I'll probably leave it off for now, and just document it on the help page once we're sure this works how we need. We can always add the header later as well.

This is really bare bones, but at least lets us get the stats data out.
This also made it clear to me how brittle some of our tests are because
of how much global state we have in the top-level golink package. We
should probably move all of that into a server type or something similar
before too long.

Updates #168

Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d
Signed-off-by: Will Norris <will@tailscale.com>
@willnorris willnorris merged commit b0360a9 into main Apr 22, 2025
4 checks passed
@willnorris willnorris deleted the will/export-stats branch April 22, 2025 13:38
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.

2 participants