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

[Bug] v.1.0.0-rc1 doesn't count metrics #4290

Closed
1 task done
joellabes opened this issue Nov 17, 2021 · 1 comment · Fixed by #4292
Closed
1 task done

[Bug] v.1.0.0-rc1 doesn't count metrics #4290

joellabes opened this issue Nov 17, 2021 · 1 comment · Fixed by #4292
Labels
bug Something isn't working

Comments

@joellabes
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm experimenting with metrics, and noticed that after creating one and running dbt compile that it was not being counted.

Expected Behavior

Found 477 models, [...], 1 metric

Steps To Reproduce

Create this file:

#/models/metrics/metrics_definitions.yml
version: 2 
metrics:
    - name: slack_joiners
      label: Members of Community Slack
      model: ref('dim_slack_users')

      type: count
      timestamp: joined_at
      time_grains: [day, week, month] #does it make sense to have num weekly active members over a month?

      dimensions:
        - has_messaged
        - is_active_past_quarter

then run dbt compile

Relevant log output

(dbt-preprod) joel@Joel-Labes internal-analytics % dbt compile
17:19:10 | [ info  ] | Running with dbt=1.0.0-rc1
17:19:10 | [ warn  ] | * Deprecation Warning: The `source-paths` config has been deprecated in favor of
`model-paths`. Please update your `dbt_project.yml` configuration to reflect
this change.
17:19:10 | [ info  ] | Found 477 models, 732 tests, 4 snapshots, 5 analyses, 572 macros, 1 operation, 19 seed files, 719 sources, 7 exposures, 0 metrics
17:19:10 | [ info  ] | 
17:19:10 | [ error ] | Encountered an error:
Database Error
  250001 (08001): Failed to connect to DB: kw27752.snowflakecomputing.com:443. IP 151.210.160.244 is not allowed to access Snowflake.  Contact your local security administrator.

^^ I wasn't on the VPN, but the node enumeration happens without that

Environment

- OS: macOS 11.6.1
- Python: Python 3.8.10
- dbt: installed version: 1.0.0-rc1
Plugins:
  - snowflake: 1.0.0rc1
  - postgres: 1.0.0rc1

What database are you using dbt with?

snowflake

Additional Context

manifest.json contains the metric:

{
  "metric.fishtown_internal_analytics.slack_joiners": {
    "fqn": [
      "fishtown_internal_analytics",
      "metrics",
      "slack_joiners"
    ],
    "unique_id": "metric.fishtown_internal_analytics.slack_joiners",
    "package_name": "fishtown_internal_analytics",
    "root_path": "/Users/joel/Documents/GitHub/internal-analytics",
    "path": "metrics/metrics_definitions.yml",
    "original_file_path": "models/metrics/metrics_definitions.yml",
    "model": "ref('dim_slack_users')",
    "name": "slack_joiners",
    "description": "",
    "label": "Members of Community Slack",
    "type": "count",
    "sql": null,
    "timestamp": "joined_at",
    "filters": [],
    "time_grains": [
      "day",
      "week",
      "month"
    ],
    "dimensions": [
      "has_messaged",
      "is_active_past_quarter"
    ],
    "resource_type": "metric",
    "meta": {},
    "tags": [],
    "sources": [],
    "depends_on": {
      "macros": [],
      "nodes": [
        "model.fishtown_internal_analytics.dim_slack_users"
      ]
    },
    "refs": [
      [
        "dim_slack_users"
      ]
    ],
    "created_at": 1637122496
  }
}```
@joellabes joellabes added bug Something isn't working triage labels Nov 17, 2021
@jtcohen6 jtcohen6 removed the triage label Nov 17, 2021
@jtcohen6
Copy link
Contributor

@joellabes Nice catch!! Metrics are missing here:

def _generate_stats(manifest: Manifest):
stats: Dict[NodeType, int] = defaultdict(int)
for node in manifest.nodes.values():
if _node_enabled(node):
stats[node.resource_type] += 1
for source in manifest.sources.values():
stats[source.resource_type] += 1
for exposure in manifest.exposures.values():
stats[exposure.resource_type] += 1
for macro in manifest.macros.values():
stats[macro.resource_type] += 1
return stats

We need this to include:

    for metric in manifest.metrics.values():
        stats[metric.resource_type] += 1

Then I get:

06:52:38 | [ info  ] | Found 1 model, 2 tests, 0 snapshots, 0 analyses, 353 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 1 metric

@jtcohen6 jtcohen6 self-assigned this Nov 17, 2021
@jtcohen6 jtcohen6 removed their assignment Nov 14, 2022
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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants