diff --git a/.changes/unreleased/Fixes-20240206-152435.yaml b/.changes/unreleased/Fixes-20240206-152435.yaml new file mode 100644 index 00000000000..d5cecf873fd --- /dev/null +++ b/.changes/unreleased/Fixes-20240206-152435.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix conflict with newer versions of Snowplow tracker +time: 2024-02-06T15:24:35.778891-06:00 +custom: + Author: edgarrmondragon akurdyukov + Issue: "8719" diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index e73a089154b..ff7b9e7ebb9 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -9,7 +9,9 @@ import logbook import pytz import requests +from packaging.version import Version from snowplow_tracker import Emitter, SelfDescribingJson, Subject, Tracker +from snowplow_tracker import __version__ as snowplow_version # type: ignore from snowplow_tracker import logger as sp_logger from dbt import version as dbt_version @@ -49,17 +51,25 @@ RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-3" PLUGIN_GET_NODES = "iglu:com.dbt/plugin_get_nodes/jsonschema/1-0-0" +SNOWPLOW_TRACKER_VERSION = Version(snowplow_version) + +# workaround in case real snowplow tracker is in the env +# the argument was renamed in https://github.com/snowplow/snowplow-python-tracker/commit/39fd50a3aff98a5efdd5c5c7fb5518fe4761305b +INIT_KW_ARGS = ( + {"buffer_size": 30} if SNOWPLOW_TRACKER_VERSION < Version("0.13.0") else {"batch_size": 30} +) + class TimeoutEmitter(Emitter): def __init__(self) -> None: super().__init__( COLLECTOR_URL, protocol=COLLECTOR_PROTOCOL, - buffer_size=30, on_failure=self.handle_failure, method="post", # don't set this. byte_limit=None, + **INIT_KW_ARGS, ) @staticmethod @@ -104,7 +114,7 @@ def http_get(self, payload): emitter = TimeoutEmitter() tracker = Tracker( - emitter, + emitters=emitter, namespace="cf", app_id="dbt", )