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

Fix conflict with newer versions of Snowplow tracker #9528

Closed
wants to merge 8 commits into from
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240206-152435.yaml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 12 additions & 2 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -104,7 +114,7 @@ def http_get(self, payload):

emitter = TimeoutEmitter()
tracker = Tracker(
emitter,
emitters=emitter,
namespace="cf",
app_id="dbt",
)
Expand Down
Loading