Skip to content

Sentry & Metric Improvements #4322

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 5 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions src/classes/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@
CURRENT_LANGUAGE = 'en_US'
SUPPORTED_LANGUAGES = ['en_US']

# Sentry.io error reporting rate (0.0 TO 1.0)
# 0.0 = no error reporting to Sentry
# 0.5 = 1/2 of errors reported to Sentry
# 1.0 = all errors reporting to Sentry
# STABLE: If this version matches the current version (reported on openshot.org)
# UNSTABLE: If this version does not match the current version (reported on openshot.org)
# STABLE_VERSION: This is the current stable release reported by openshot.org
ERROR_REPORT_RATE_STABLE = 0.0
ERROR_REPORT_RATE_UNSTABLE = 0.0
ERROR_REPORT_STABLE_VERSION = None

try:
from language import openshot_lang
language_path = ":/locale/"
Expand Down
17 changes: 11 additions & 6 deletions src/classes/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import platform

from classes.logger import log
from classes import info

try:
Expand All @@ -47,12 +48,16 @@ def init_tracing():
return

# Determine sample rate for exceptions
traces_sample_rate = 0.1
environment = "production"
if "-dev" in info.VERSION:
# Dev mode, trace all exceptions
traces_sample_rate = 1.0
environment = "development"
traces_sample_rate = 0.0
if info.VERSION == info.ERROR_REPORT_STABLE_VERSION:
traces_sample_rate = info.ERROR_REPORT_RATE_STABLE
environment = "production"
else:
traces_sample_rate = info.ERROR_REPORT_RATE_UNSTABLE
environment = "unstable"

if info.ERROR_REPORT_STABLE_VERSION:
log.info("Sentry initialized with %s error reporting rate (%s)" % (traces_sample_rate, environment))

# Initialize sentry exception tracing
sdk.init(
Expand Down
9 changes: 6 additions & 3 deletions src/classes/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from classes.app import get_app
from classes import info
from classes.logger import log
import json


def get_current_Version():
"""Get the current version """
Expand All @@ -46,10 +46,13 @@ def get_version_from_http():
# Send metric HTTP data
try:
r = requests.get(url, headers={"user-agent": "openshot-qt-%s" % info.VERSION}, verify=False)
log.info("Found current version: %s" % r.text)
log.info("Found current version: %s" % r.json())

# Parse version
openshot_version = r.json()["openshot_version"]
openshot_version = r.json().get("openshot_version")
info.ERROR_REPORT_STABLE_VERSION = r.json().get("openshot_version")
info.ERROR_REPORT_RATE_STABLE = r.json().get("error_rate_stable")
info.ERROR_REPORT_RATE_UNSTABLE = r.json().get("error_rate_unstable")

# Emit signal for the UI
get_app().window.FoundVersionSignal.emit(openshot_version)
Expand Down