Skip to content
Open
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
11 changes: 11 additions & 0 deletions codecov_cli/opentelemetry.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import logging
import os
import random

import sentry_sdk

from codecov_cli import __version__

logger = logging.getLogger("codecovcli")

_SAMPLED_MESSAGES = [
"Token required",
"No JUnit XML reports found",
Expand Down Expand Up @@ -44,6 +47,14 @@ def init_telem(ctx):
if os.getenv("CODECOV_ENV", "production") == "test":
return

sdk_version = tuple(int(x) for x in sentry_sdk.VERSION.split(".")[:2])
if sdk_version < (2, 0):
logger.warning(
"sentry-sdk %s is installed but codecov-cli requires >=2.0. "
"Some telemetry features may not work correctly.",
sentry_sdk.VERSION,
)

sentry_sdk.init(
dsn="https://0bea75c61745c221a6ef1ac1709b1f4d@o26192.ingest.us.sentry.io/4508615876083713",
enable_tracing=True,
Expand Down
5 changes: 4 additions & 1 deletion codecov_cli/services/upload/upload_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def send_upload_data(
upload_coverage: bool = False,
args: dict = None,
) -> RequestResult:
current_transaction = sentry_sdk.get_current_scope().transaction
try:
current_transaction = sentry_sdk.get_current_scope().transaction
except AttributeError:
current_transaction = None
if current_transaction:
current_transaction.set_data("commit_sha", commit_sha)
current_transaction.set_data("slug", slug)
Expand Down
Loading