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

Add adapter telemetry to snowplow event. #10859

Merged
merged 13 commits into from
Oct 28, 2024
11 changes: 9 additions & 2 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import threading
from copy import deepcopy
from dataclasses import asdict
from datetime import datetime
from typing import AbstractSet, Any, Dict, Iterable, List, Optional, Set, Tuple, Type

Expand Down Expand Up @@ -98,7 +99,7 @@
return status, message


def track_model_run(index, num_nodes, run_model_result):
def track_model_run(index, num_nodes, run_model_result, adapter=BaseAdapter):
VersusFacit marked this conversation as resolved.
Show resolved Hide resolved
if tracking.active_user is None:
raise DbtInternalError("cannot track model run with no active user")
invocation_id = get_invocation_id()
Expand All @@ -114,6 +115,11 @@
contract_enforced = False
versioned = False
incremental_strategy = None

Check warning on line 118 in core/dbt/task/run.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/run.py#L118

Added line #L118 was not covered by tests
# Each adapter decides what adapter-specific fields will be included
# so this is a flexible dictionary.
adapter_info = adapter.get_adapter_run_info(run_model_result.node.config)

Check warning on line 122 in core/dbt/task/run.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/run.py#L122

Added line #L122 was not covered by tests
tracking.track_model_run(
{
"invocation_id": invocation_id,
Expand All @@ -133,6 +139,7 @@
"contract_enforced": contract_enforced,
"access": access,
"versioned": versioned,
"adapter_info": asdict(adapter_info),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that this should be something JSON safe, which a Python dict is 🫡

}
)

Expand Down Expand Up @@ -281,7 +288,7 @@
self.print_start_line()

def after_execute(self, result) -> None:
track_model_run(self.node_index, self.num_nodes, result)
track_model_run(self.node_index, self.num_nodes, result, adapter=self.adapter)
self.print_result_line(result)

def _build_run_model_result(self, model, context):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
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-4"
RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-5"
VersusFacit marked this conversation as resolved.
Show resolved Hide resolved
PLUGIN_GET_NODES = "iglu:com.dbt/plugin_get_nodes/jsonschema/1-0-0"

SNOWPLOW_TRACKER_VERSION = Version(snowplow_version)
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git+https://github.com/dbt-labs/dbt-adapters.git@main
git+https://github.com/dbt-labs/dbt-adapters.git@ADAP-301/add-adapter-telemetry
git+https://github.com/dbt-labs/dbt-adapters.git@main#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-common.git@main
git+https://github.com/dbt-labs/dbt-postgres.git@main
Expand Down
Loading