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

expvar: add Map.Delete #13491

Closed
jacksontj opened this issue Dec 5, 2015 · 8 comments
Closed

expvar: add Map.Delete #13491

jacksontj opened this issue Dec 5, 2015 · 8 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal Proposal-Accepted
Milestone

Comments

@jacksontj
Copy link

I've been using expvar for a few metrics related cases, and its great. The one thing I really see as missing is that there is no mechanism to remove items from an expvar.Map. I had created a PR with a simple Remove method which returns the Var associated with key-- or nil. I don't see any reason that it shouldn't-- so I created a simple patch (#13490) which adds a Remove method to expvar.Map

@ianlancetaylor ianlancetaylor changed the title Add Remove method to expvar.Map expvar: Add Remove method to expvar.Map Dec 5, 2015
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Dec 5, 2015
@ianlancetaylor
Copy link
Contributor

Thanks. We don't take github pull requests. To contribute your patch please follow the procedure at https://golang.org/doc/contribute.html . Note that at this point it will have to wait for the Go 1.7 release.

@dsymonds
Copy link
Contributor

dsymonds commented Feb 5, 2016

The Remove method was not in the original API because monitoring software of the kind that scrapes such output can often get confused by a disappearing map key.

I think any change to add a Remove method would need to justify its usefulness as outweighing potentially malfunctioning monitoring.

@jacksontj
Copy link
Author

Well, the particular use case I have highlights this fairly well IMO. I have a service which maintains state of downstream services. The list of all downstream services is fluid-- since it is determined by a source of truth service. As such my service has some metrics for each downstream. Since I cannot call "remove" i effectively leak N metrics per service that appears and then gets removed, since I cannot remove the metrics associated with that service.

I don't think adding a Remove method immediately constitutes "breaking monitoring" as it would still require the developer to actually call Remove.

@jonsyu1
Copy link

jonsyu1 commented Dec 5, 2016

Is there any disagreement with or recommended workaround for @jacksontj's use case?

@tsuna
Copy link
Contributor

tsuna commented Sep 19, 2017

I have exactly the same issue as @jacksontj. I don't buy the "borgmon can't handle it so we didn't add this API" argument. We expose a wealth of information over expvar that is useful for troubleshooting problems, how this gets consumed/stored by a particular monitoring backend isn't really the point.

Looks like the Kapacitor project already forked the code of expvar for this reason https://github.com/influxdata/kapacitor/blob/master/expvar/expvar.go (and made some other nice improvements such as influxdata/kapacitor#394). See this post for more info: https://www.influxdata.com/blog/influxdb-debugvars-endpoint/

The first reason they give why they forked the code:

it does not allow you to remove published variables.

@agnivade agnivade changed the title expvar: Add Remove method to expvar.Map proposal: expvar: Add Remove method to expvar.Map Sep 30, 2018
@agnivade
Copy link
Contributor

Moving this to proposal so that it gets some visibility.

@rsc
Copy link
Contributor

rsc commented Oct 3, 2018

OK, it does seem like this is missing from expvar.Map's methods.
It should be called Delete though (like the builtin).

@rsc rsc changed the title proposal: expvar: Add Remove method to expvar.Map expvar: add Map.Delete Oct 3, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 3, 2018
@gopherbot
Copy link

Change https://golang.org/cl/139537 mentions this issue: expvar: add Map.Delete

@golang golang locked and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal Proposal-Accepted
Projects
None yet
Development

No branches or pull requests

8 participants