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 method for core model run snowplow event. #328

Merged
merged 13 commits into from
Oct 28, 2024
Merged
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20241016-033159.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add adapter telemetry.
time: 2024-10-16T03:31:59.334011-07:00
custom:
Author: versusfacit
Issue: "301"
1 change: 1 addition & 0 deletions dbt/adapters/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
BaseRelation,
RelationType,
SchemaSearchMap,
AdapterTrackingRelationInfo,
)
12 changes: 12 additions & 0 deletions dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from contextlib import contextmanager
from datetime import datetime
from enum import Enum
from importlib import import_module
from multiprocessing.context import SpawnContext
from typing import (
Any,
Expand Down Expand Up @@ -61,12 +62,14 @@
ComponentName,
InformationSchema,
SchemaSearchMap,
AdapterTrackingRelationInfo,
)
from dbt.adapters.cache import RelationsCache, _make_ref_key_dict
from dbt.adapters.capability import Capability, CapabilityDict
from dbt.adapters.contracts.connection import Credentials
from dbt.adapters.contracts.macros import MacroResolverProtocol
from dbt.adapters.contracts.relation import RelationConfig

from dbt.adapters.events.types import (
CacheMiss,
CatalogGenerationError,
Expand Down Expand Up @@ -1743,6 +1746,15 @@ def capabilities(cls) -> CapabilityDict:
def supports(cls, capability: Capability) -> bool:
return bool(cls.capabilities()[capability])

@available
VersusFacit marked this conversation as resolved.
Show resolved Hide resolved
@classmethod
def get_adapter_run_info(cls, config: RelationConfig) -> AdapterTrackingRelationInfo:
VersusFacit marked this conversation as resolved.
Show resolved Hide resolved
return AdapterTrackingRelationInfo(
VersusFacit marked this conversation as resolved.
Show resolved Hide resolved
adapter_name="base_adapter",
version=import_module("dbt.adapters.__about__").version,
adapter_details={},
)


COLUMNS_EQUAL_SQL = """
with diff_count as (
Expand Down
7 changes: 7 additions & 0 deletions dbt/adapters/base/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,10 @@ def flatten(self, allow_multiple_databases: bool = False) -> "SchemaSearchMap":
)

return new


@dataclass(frozen=True, eq=False, repr=False)
class AdapterTrackingRelationInfo(FakeAPIObject, Hashable):
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
adapter_name: str
version: str
adapter_details: Any
Loading