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

When client is disabled, but metrics are not, metrics are referenced but never initialized. #139

Closed
jdurkee-mdsol opened this issue May 1, 2023 · 0 comments · Fixed by #140
Labels
bug Something isn't working

Comments

@jdurkee-mdsol
Copy link
Contributor

Describe the bug

When disabling the client but not disabling metrics, the metrics attribute/container is never initialized. Yet, attempting to call enabled? on the client results in undefined method ... for nil:NilClass as it attempts to access metrics.

Steps to reproduce the bug

Unleash::Client.new(
  disable_client: true,
  url: 'https://example.com',
  bootstrap_config: Unleash::Bootstrap::Configuration.new(
    data: '{
      "version": 1,
      "features": [
        {
          "enabled": true,
          "name": "featureX"
        }
      ]
    }'
  )
).enabled?('featureX', nil)

Expected behavior

No runtime errors, and correct state of the feature.

Logs, error output, etc.

[2023-05-01T18:45:55.551253+00:00          Unleash WARN ] : Unleash::Client is disabled! Will only return default (or bootstrapped if available) results!
/shared/unleash/lib/unleash/feature_toggle.rb:30:in `is_enabled?': undefined method `increment' for nil:NilClass (NoMethodError)

      Unleash.toggle_metrics.increment(name, choice) unless Unleash.configuration.disable_metrics
                            ^^^^^^^^^^
        from /shared/unleash/lib/unleash/client.rb:50:in `is_enabled?'
        from unleash_client.rb:77:in `<main>'

Screenshots

No response

Additional context

No response

Unleash version

Ruby SDK 4.4.2

Subscription type

Enterprise

Hosting type

Hosted by Unleash

SDK information (language and version)

Ruby SDK 4.4.2

@jdurkee-mdsol jdurkee-mdsol added the bug Something isn't working label May 1, 2023
rarruda added a commit that referenced this issue May 2, 2023
Disabling the client is meant for when a user will be testing their code,
and no connection to a remote server is desired.

It is hard to see a use case for collecting and reporting metrics if the client is disabled.
Forcefully disabling metrics when disabling the client makes sense and is a more coherent behaviour.
sighphyre pushed a commit that referenced this issue May 11, 2023
* fix: forcefully disabling metrics when client is disabled (#139)

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant