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

Support disabling dbt "Anonymous usage stats" #724

Closed
ykuc opened this issue Nov 28, 2023 · 2 comments · Fixed by #768
Closed

Support disabling dbt "Anonymous usage stats" #724

ykuc opened this issue Nov 28, 2023 · 2 comments · Fixed by #768
Labels
area:config Related to configuration, like YAML files, environment variables, or executer configuration

Comments

@ykuc
Copy link
Contributor

ykuc commented Nov 28, 2023

How can I set send_anonymous_usage_stats=False?
https://docs.getdbt.com/reference/global-configs/usage-stats

Copy link

dosubot bot commented Nov 28, 2023

🤖

Hello @ykuc,

Nice to meet you! I'm Dosu, a helpful bot here to assist you with bugs, answer your questions, and guide you on contributing to the Cosmos repository. While we wait for a human maintainer, feel free to ask anything you need. Let's make your open-source journey smoother together!

To disable anonymous usage stats in dbt, you need to add the send_anonymous_usage_stats configuration to your dbt_project.yml file and set it to False. Here's how you can add it:

name: 'jaffle_shop'

config-version: 2
version: '0.1'

profile: 'jaffle_shop'

model-paths: ["models"]
seed-paths: ["seeds"]
test-paths: ["tests"]
analysis-paths: ["analysis"]
macro-paths: ["macros"]

target-path: "target"
clean-targets:
    - "target"
    - "dbt_modules"
    - "logs"

require-dbt-version: [">=1.0.0", "<2.0.0"]

models:
  jaffle_shop:
      materialized: table
      staging:
        materialized: view

quoting:
  identifier: true

send_anonymous_usage_stats: False

Please note that the send_anonymous_usage_stats configuration is not specific to the Cosmos tool you're using, but is a general dbt configuration.

Regarding your question about the Cosmos repository, it does not provide a way to configure dbt settings such as send_anonymous_usage_stats directly. The configuration classes provided in the cosmos/config.py file, such as RenderConfig, ProjectConfig, ProfileConfig, and ExecutionConfig, do not include any fields or methods for setting dbt configuration options like send_anonymous_usage_stats.

However, dbt settings are typically configured in the profiles.yml file or the dbt_project.yml file in your dbt project directory. In the ProfileConfig class, there is a profiles_yml_filepath parameter where you can specify the path to your profiles.yml file. Similarly, in the ProjectConfig class, there is a dbt_project_path parameter where you can specify the path to your dbt project directory, which should contain your dbt_project.yml file. Therefore, you can configure dbt settings in these files as per dbt's documentation, and Cosmos will use these settings when running your dbt project.

For more information, you can refer to the Cosmos repository and the dbt documentation.

I hope this helps! If you have any other questions, feel free to ask.

Best,
Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the area:config Related to configuration, like YAML files, environment variables, or executer configuration label Nov 28, 2023
@jbandoro
Copy link
Collaborator

jbandoro commented Dec 4, 2023

This is a great issue you brought up @ykuc since any cosmos profiles that are mapped from Airflow connections won't have the following block for dbt usage stats in the profiles.yml:

config:
  send_anonymous_usage_stats: False

which means it defaults to True when not used.

There are 2 workarounds you could have at the moment for preventing anonymous usage stats tracking:

  1. Supply your own profiles.yml file to cosmos, see docs here on using your own file where you could add the config above. Though the limitation of this is that you won't be able to use Airflow connections.
  2. As noted in dbt docs linked above you could also use the environment variables: DO_NOT_TRACK=1 or DBT_SEND_ANONYMOUS_USAGE_STATS=False. With cosmos currently you would have to use operator_args with either "append_env": True if you have the env var already set, or use "env": {"DO_NOT_TRACK": "1"}.

In Cosmos to add support for not sending usage stats, I think this could be added to BaseProfileMapping args and then it could be added to profile contents in the method below:

profile_contents = {
profile_name: {
"target": target_name,
"outputs": {target_name: profile_vars},
}
}

@ykuc if you would like to contribute to add this and improve Cosmos it would be much appreciated!

@jbandoro jbandoro changed the title Disable "Anonymous usage stats" Support disabling dbt "Anonymous usage stats" Dec 5, 2023
tatiana pushed a commit that referenced this issue Dec 15, 2023
)

Since dbt by default tracks events by sending anonymous statistic usage
when dbt is invoked, users who currently use Cosmos profile mapping can
only opt-out by setting environment variables as described in
#724 (comment)

This PR adds a new arg to the profile mapping so that the [dbt
recommended config
block](https://docs.getdbt.com/reference/global-configs/usage-stats) can
be added in the generated `profiles.yml` file:

```yaml
config:
  send_anonymous_usage_stats: False
```

Closes: #724
@ykuc ykuc mentioned this issue Dec 15, 2023
2 tasks
ykuc pushed a commit to ykuc/astronomer-cosmos that referenced this issue Dec 30, 2023
…stronomer#768)

Since dbt by default tracks events by sending anonymous statistic usage
when dbt is invoked, users who currently use Cosmos profile mapping can
only opt-out by setting environment variables as described in
astronomer#724 (comment)

This PR adds a new arg to the profile mapping so that the [dbt
recommended config
block](https://docs.getdbt.com/reference/global-configs/usage-stats) can
be added in the generated `profiles.yml` file:

```yaml
config:
  send_anonymous_usage_stats: False
```

Closes: astronomer#724
ykuc pushed a commit to ykuc/astronomer-cosmos that referenced this issue Jan 11, 2024
…stronomer#768)

Since dbt by default tracks events by sending anonymous statistic usage
when dbt is invoked, users who currently use Cosmos profile mapping can
only opt-out by setting environment variables as described in
astronomer#724 (comment)

This PR adds a new arg to the profile mapping so that the [dbt
recommended config
block](https://docs.getdbt.com/reference/global-configs/usage-stats) can
be added in the generated `profiles.yml` file:

```yaml
config:
  send_anonymous_usage_stats: False
```

Closes: astronomer#724
arojasb3 pushed a commit to arojasb3/astronomer-cosmos that referenced this issue Jul 14, 2024
…stronomer#768)

Since dbt by default tracks events by sending anonymous statistic usage
when dbt is invoked, users who currently use Cosmos profile mapping can
only opt-out by setting environment variables as described in
astronomer#724 (comment)

This PR adds a new arg to the profile mapping so that the [dbt
recommended config
block](https://docs.getdbt.com/reference/global-configs/usage-stats) can
be added in the generated `profiles.yml` file:

```yaml
config:
  send_anonymous_usage_stats: False
```

Closes: astronomer#724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:config Related to configuration, like YAML files, environment variables, or executer configuration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants