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

Don't crash when a probe receives undefined #12

Closed
wants to merge 2 commits into from

Conversation

ajpalkovic
Copy link

I noticed my service is crashing from time to time because a probe gets an "undefined" value.
It looks like the prob is configured to call ETS.info(:size), which the erlang docs say can return :undefined. Since most services probably have this problem, figured it's best to just drop :undefined like we would nil in the probe.

I noticed my service is crashing from time to time because a probe gets an "undefined" value.
It looks like the prob is configured to call ETS.info(:size), which the erlang docs say can return :undefined.  Since most services probably have this problem, figured it's best to just drop :undefined like we would nil in the probe.
@ajpalkovic ajpalkovic requested a review from ihumanable August 13, 2019 00:07
@ajpalkovic
Copy link
Author

Polite ping :)

@ihumanable
Copy link
Contributor

I'm a bit confused here, probe_modules should implement the Instruments.Probe behaviour which specifies that probe_get_value should return {:ok, probe_value} where probe_value is defined as number | keyword.

It sounds like the probe module is returning {:ok, :undefined} which violates the behaviour contract, why not just fix the probe?

@ajpalkovic
Copy link
Author

I don't completely remember, but I'm pretty sure the problem was:
I have a probe definition in discord_lfg.ex:

    Probe.define!(
      "discord_lfg.guilds.count",
      :gauge,
      mfa: {DiscordLfg, :count_guilds, []},
      report_interval: 10_000
    )

count_guilds is defined as:

  def count_guilds() do
    @registry_module.count(GuildLfg)
  end

@registry_module is a GenRegistry

GenRegistry calls into ETS, and ETS returns :undefined if the "thing" has no entries yet

So, I figured other places probably have the same problem so rather than fix all of them, might as well just change the probe to accept :undefined and treat it the same as nil? I don't really feel that strongly about it though

@ihumanable
Copy link
Contributor

Since instruments is an open-source project that has many consumers, I think obeying the contract in this case instead of making an exception for GenRegistry / ETS is the correct course of action here.

@ihumanable ihumanable closed this Sep 10, 2019
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