8000 feat: telemetry on flow creation by deepankarm · Pull Request #2798 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: telemetry on flow creation #2798

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

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000 25 changes: 25 additions & 0 deletions jina/flow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import threading
import uuid
import warnings
import base64
import urllib
from collections import OrderedDict
from contextlib import ExitStack
from typing import Optional, Union, Tuple, List, Set, Dict, overload, Type
Expand All @@ -25,6 +27,7 @@
typename,
ArgNamespace,
download_mermaid_url,
get_full_version,
)
from ..jaml import JAMLCompatible
from ..logging.logger import JinaLogger
Expand Down Expand Up @@ -960,6 +963,8 @@ def start(self):

self._build_level = FlowBuildLevel.RUNNING
self._show_success_message()
if not self.args.no_telemetry:
self.register()

return self

Expand Down Expand Up @@ -1554,3 +1559,23 @@ def update_network_interface(self, **kwargs):
:param kwargs: new network settings
"""
self._common_kwargs.update(kwargs)

def register(self) -> None:
"""Register a Flow"""

def _register():
url = 'https://telemetry.jina.ai/'
try:
metas, envs = get_full_version()
data = base64.urlsafe_b64encode(
json.dumps({**metas, **envs}).encode('utf-8')
)
req = urllib.request.Request(
url, data=data, headers={'User-Agent': 'Mozilla/5.0'}
)
urllib.request.urlopen(req)

except:
pass

threading.Thread(target=_register, daemon=True).start()
7 changes: 7 additions & 0 deletions jina/parsers/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def mixin_flow_features_parser(parser):
''',
)

gp.add_argument(
52D1 '--no-telemetry',
action='store_true',
default=False,
help='If set, disable telemetry during the Flow creation.',
)


def set_flow_parser(parser=None, with_identity=False):
"""Set the parser for the flow
Expand Down
0