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

Track group, contract, access, version in run_model; add metrics and groups to resource_counts #7309

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230411-114149.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Track data about group, access, contract, version usage
time: 2023-04-11T11:41:49.84883-04:00
custom:
Author: gshank
Issue: 7170 7171
22 changes: 18 additions & 4 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def track_model_run(index, num_nodes, run_model_result):
if tracking.active_user is None:
raise DbtInternalError("cannot track model run with no active user")
invocation_id = get_invocation_id()
node = run_model_result.node
has_group = True if hasattr(node, "group") and node.group else False
if node.resource_type == NodeType.Model:
access = node.access.value if node.access is not None else None
contract_enforced = node.contract.enforced
versioned = True if node.version else False
else:
access = None
contract_enforced = False
versioned = False
tracking.track_model_run(
{
"invocation_id": invocation_id,
Expand All @@ -117,11 +127,15 @@ def track_model_run(index, num_nodes, run_model_result):
"run_status": str(run_model_result.status).upper(),
"run_skipped": run_model_result.status == NodeStatus.Skipped,
"run_error": run_model_result.status == NodeStatus.Error,
"model_materialization": run_model_result.node.get_materialization(),
"model_id": utils.get_hash(run_model_result.node),
"hashed_contents": utils.get_hashed_contents(run_model_result.node),
"model_materialization": node.get_materialization(),
"model_id": utils.get_hash(node),
"hashed_contents": utils.get_hashed_contents(node),
"timing": [t.to_dict(omit_none=True) for t in run_model_result.timing],
"language": str(run_model_result.node.language),
"language": str(node.language),
"has_group": has_group,
"contract_enforced": contract_enforced,
"access": access,
"versioned": versioned,
}
)

Expand Down
4 changes: 2 additions & 2 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
PARTIAL_PARSER = "iglu:com.dbt/partial_parser/jsonschema/1-0-1"
PLATFORM_SPEC = "iglu:com.dbt/platform/jsonschema/1-0-0"
PROJECT_ID_SPEC = "iglu:com.dbt/project_id/jsonschema/1-0-1"
RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-0"
RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-1"
RPC_REQUEST_SPEC = "iglu:com.dbt/rpc_request/jsonschema/1-0-1"
RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0"
RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-2"
RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-3"


class TimeoutEmitter(Emitter):
Expand Down