[CT-3525] [Bug] Option `--no-send-anonymous-usage-stats` creates different behavior compared to `DBT_SEND_ANONYMOUS_USAGE_STATS=false`
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
Running `time dbt ls -s something --no-send-anonymous-usage-stats` generates these logs:
```
[0m19:46:13.215433 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'start', 'context': [, , ]}
============================== 19:46:13.217242 | 57017d07-14d8-4178-884f-d2cdeda0a998 ==============================
[0m19:46:13.217242 [info ] [MainThread]: Running with dbt=1.7.4
[0m19:46:13.217977 [debug] [MainThread]: running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'log_cache_events': 'False', 'write_json': 'True', 'partial_parse': 'True', 'cache_selected_only': 'False', 'warn_error': 'None', 'fail_fast': 'False', 'version_check': 'True', 'log_path': '/usr/local/dbt_snowflake/logs', 'profiles_dir': '/usr/local/airflow/.dbt', 'debug': 'False', 'use_colors': 'True', 'use_experimental_parser': 'False', 'no_print': 'None', 'quiet': 'False', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'static_parser': 'True', 'log_format': 'default', 'invocation_command': 'dbt ls -s something --no-send-anonymous-usage-stats', 'target_path': 'None', 'introspect': 'True', 'send_anonymous_usage_stats': 'True'}
[0m19:46:13.409792 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'project_id', 'label': '57017d07-14d8-4178-884f-d2cdeda0a998', 'context': []}
[0m19:46:13.456307 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'adapter_info', 'label': '57017d07-14d8-4178-884f-d2cdeda0a998', 'context': []}
[0m19:46:13.457063 [info ] [MainThread]: Registered adapter: snowflake=1.7.1
[0m19:46:13.518584 [debug] [MainThread]: checksum: 248e8aba381ba2d577dce7ab50d2010c2aac45d2b27e6e6214cdd96d2d41fabc, vars: {}, profile: , target: , version: 1.7.4
[0m19:46:14.017287 [debug] [MainThread]: Partial parsing enabled: 0 files deleted, 0 files added, 0 files changed.
[0m19:46:14.017913 [debug] [MainThread]: Partial parsing enabled, no changes found, skipping parsing
[0m19:46:14.075769 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'load_project', 'label': '57017d07-14d8-4178-884f-d2cdeda0a998', 'context': []}
[0m19:46:14.194683 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'resource_counts', 'label': '57017d07-14d8-4178-884f-d2cdeda0a998', 'context': []}
[0m19:46:14.195421 [info ] [MainThread]: Found 337 models, 11 snapshots, 444 tests, 10 seeds, 2 operations, 145 sources, 0 exposures, 0 metrics, 683 macros, 0 groups, 0 semantic models
[0m19:46:14.196130 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'runnable_timing', 'label': '57017d07-14d8-4178-884f-d2cdeda0a998', 'context': []}
[0m19:46:14.199641 [warn ] [MainThread]: The selection criterion 'something' does not match any nodes
[0m19:46:14.200179 [warn ] [MainThread]: No nodes selected!
[0m19:46:14.201185 [debug] [MainThread]: Resource report: {"command_name": "list", "command_success": true, "command_wall_clock_time": 1.0115864, "process_user_time": 1.816159, "process_kernel_time": 0.270297, "process_mem_max_rss": "137156", "process_in_blocks": "0", "process_out_blocks": "0"}
[0m19:46:14.201706 [debug] [MainThread]: Command `dbt ls` succeeded at 19:46:14.201608 after 1.01 seconds
[0m19:46:14.202355 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [, , ]}
[0m19:46:14.203033 [debug] [MainThread]: Flushing usage events
```
and the `time` output is:
```
real 0m3.561s
user 0m2.040s
sys 0m0.281s
```
Whereas running `time DBT_SEND_ANONYMOUS_USAGE_STATS=false dbt ls -s something` generates these logs:
```
============================== 19:48:04.896626 | 66292a5a-377e-4a8a-a374-91bea051e347 ==============================
[0m19:48:04.896626 [info ] [MainThread]: Running with dbt=1.7.4
[0m19:48:04.898463 [debug] [MainThread]: running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'write_json': 'True', 'log_cache_events': 'False', 'partial_parse': 'True', 'cache_selected_only': 'False', 'profiles_dir': '/usr/local/airflow/.dbt', 'fail_fast': 'False', 'version_check': 'True', 'log_path': '/usr/local/dbt_snowflake/logs', 'debug': 'False', 'warn_error': 'None', 'use_colors': 'True', 'use_experimental_parser': 'False', 'no_print': 'None', 'quiet': 'False', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'static_parser': 'True', 'log_format': 'default', 'invocation_command': 'dbt ls -s something', 'target_path': 'None', 'introspect': 'True', 'send_anonymous_usage_stats': 'False'}
[0m19:48:05.135858 [info ] [MainThread]: Registered adapter: snowflake=1.7.1
[0m19:48:05.187251 [debug] [MainThread]: checksum: 248e8aba381ba2d577dce7ab50d2010c2aac45d2b27e6e6214cdd96d2d41fabc, vars: {}, profile: , target: , version: 1.7.4
[0m19:48:05.519577 [debug] [MainThread]: Partial parsing enabled: 0 files deleted, 0 files added, 0 files changed.
[0m19:48:05.520165 [debug] [MainThread]: Partial parsing enabled, no changes found, skipping parsing
[0m19:48:05.703670 [info ] [MainThread]: Found 337 models, 11 snapshots, 444 tests, 10 seeds, 2 operations, 145 sources, 0 exposures, 0 metrics, 683 macros, 0 groups, 0 semantic models
[0m19:48:05.707770 [warn ] [MainThread]: The selection criterion 'something' does not match any nodes
[0m19:48:05.708355 [warn ] [MainThread]: No nodes selected!
[0m19:48:05.709225 [debug] [MainThread]: Resource report: {"command_name": "list", "command_success": true, "command_wall_clock_time": 0.8377126, "process_user_time": 1.595339, "process_kernel_time": 0.210098, "process_mem_max_rss": "137264", "process_in_blocks": "0", "process_out_blocks": "0"}
[0m19:48:05.709759 [debug] [MainThread]: Command `dbt ls` succeeded at 19:48:05.709641 after 0.84 seconds
[0m19:48:05.710292 [debug] [MainThread]: Flushing usage events
```
And `time` output is:
```
real 0m2.220s
user 0m1.814s
sys 0m0.219s
```
So using the env var config actually results in fewer events logged and a large improvement in runtime.
### Expected Behavior
As I understand it, `--no-send-anonymous-usage-stats` and `DBT_SEND_ANONYMOUS_USAGE_STATS=false` should be identical.
### Steps To Reproduce
Run:
`time dbt ls -s something --no-send-anonymous-usage-stats`
and
`time DBT_SEND_ANONYMOUS_USAGE_STATS=false dbt ls -s something`
Compare the logs and runtime.
### Relevant log output
_No response_
### Environment
```markdown
- OS:
- Python:
- dbt:
```
### Which database adapter are you using with dbt?
snowflake
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.