Skip to content

Commit

Permalink
Fix conflict with newer versions of Snowplow tracker (#9680)
Browse files Browse the repository at this point in the history
Co-authored-by: Alik Kurdyukov <[email protected]>
  • Loading branch information
edgarrmondragon and akurdyukov authored Apr 15, 2024
1 parent 7e72cac commit 7e164e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 7e164e3

Please sign in to comment.