Skip to content

Commit d6e4136

Browse files
JoshFergeandrewshie-sentry
authored andcommitted
chore: upgrade sentry_sdk for logging fix (#91900)
upgrade the sentry python sdk so we get some fixes for logging functionality. https://sentry.slack.com/archives/C081M1KEQ0L/p1747042396547599?thread_ts=1746721086.279279&cid=C081M1KEQ0L
1 parent 48e0e6c commit d6e4136

21 files changed

+63
-63
lines changed

requirements-base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ sentry-ophio>=1.1.3
7171
sentry-protos==0.2.0
7272
sentry-redis-tools>=0.5.0
7373
sentry-relay>=0.9.9
74-
sentry-sdk[http2]>=2.25.1
74+
sentry-sdk[http2]>=2.29.1
7575
slack-sdk>=3.27.2
7676
snuba-sdk>=3.0.43
7777
simplejson>=3.17.6

requirements-dev-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ sentry-ophio==1.1.3
192192
sentry-protos==0.2.0
193193
sentry-redis-tools==0.5.0
194194
sentry-relay==0.9.9
195-
sentry-sdk==2.27.0
195+
sentry-sdk==2.29.1
196196
sentry-usage-accountant==0.0.10
197197
simplejson==3.17.6
198198
six==1.16.0

requirements-frozen.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ sentry-ophio==1.1.3
130130
sentry-protos==0.2.0
131131
sentry-redis-tools==0.5.0
132132
sentry-relay==0.9.9
133-
sentry-sdk==2.27.0
133+
sentry-sdk==2.29.1
134134
sentry-usage-accountant==0.0.10
135135
simplejson==3.17.6
136136
six==1.16.0

src/sentry/api/bases/organization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from sentry.utils import auth
3838
from sentry.utils.hashlib import hash_values
3939
from sentry.utils.numbers import format_grouped_length
40-
from sentry.utils.sdk import bind_organization_context, set_measurement
40+
from sentry.utils.sdk import bind_organization_context, set_span_data
4141

4242

4343
class NoProjects(Exception):
@@ -566,7 +566,7 @@ def get_filter_params(
566566
len_projects = len(projects)
567567
sentry_sdk.set_tag("query.num_projects", len_projects)
568568
sentry_sdk.set_tag("query.num_projects.grouped", format_grouped_length(len_projects))
569-
set_measurement("query.num_projects", len_projects)
569+
set_span_data("query.num_projects", len_projects)
570570

571571
params: FilterParams = {
572572
"start": start,

src/sentry/api/endpoints/organization_event_details.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from datetime import datetime, timedelta
33
from typing import Any
44

5-
import sentry_sdk
65
from rest_framework.request import Request
76
from rest_framework.response import Response
87
from snuba_sdk import Column, Condition, Function, Op
@@ -23,6 +22,7 @@
2322
from sentry.snuba.dataset import Dataset
2423
from sentry.snuba.query_sources import QuerySource
2524
from sentry.snuba.referrer import Referrer
25+
from sentry.utils.sdk import set_span_data
2626

2727
VALID_AVERAGE_COLUMNS = {"span.self_time", "span.duration"}
2828

@@ -39,7 +39,7 @@ def add_comparison_to_event(event, average_columns, request: Request):
3939
group_to_span_map[group].append(span)
4040

4141
# Nothing to add comparisons to
42-
sentry_sdk.set_measurement("query.groups", len(group_to_span_map))
42+
set_span_data("query.groups", len(group_to_span_map))
4343
if len(group_to_span_map) == 0:
4444
return
4545

@@ -77,7 +77,7 @@ def add_comparison_to_event(event, average_columns, request: Request):
7777
),
7878
)
7979
)
80-
sentry_sdk.set_measurement("query.groups_found", len(result["data"]))
80+
set_span_data("query.groups_found", len(result["data"]))
8181
for row in result["data"]:
8282
group = row["span.group"]
8383
for span in group_to_span_map[group]:

src/sentry/api/endpoints/organization_events_trace.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from sentry.snuba.referrer import Referrer
3737
from sentry.utils.iterators import chunked
3838
from sentry.utils.numbers import base32_encode, format_grouped_length
39-
from sentry.utils.sdk import set_measurement
39+
from sentry.utils.sdk import set_span_data
4040
from sentry.utils.snuba import bulk_snuba_queries
4141
from sentry.utils.validators import INVALID_ID_DETAILS, is_event_id, is_span_id
4242

@@ -761,7 +761,7 @@ def build_span_query(trace_id: str, spans_params: SnubaParams, query_spans: list
761761
# Performance improvement, snuba's parser is extremely slow when we're sending thousands of
762762
# span_ids here, using a `splitByChar` means that snuba will not parse the giant list of spans
763763
span_minimum = options.get("performance.traces.span_query_minimum_spans")
764-
sentry_sdk.set_measurement("trace_view.spans.span_minimum", span_minimum)
764+
set_span_data("trace_view.spans.span_minimum", span_minimum)
765765
sentry_sdk.set_tag("trace_view.split_by_char.optimization", len(query_spans) > span_minimum)
766766
if len(query_spans) > span_minimum:
767767
# TODO: because we're not doing an IN on a list of literals, snuba will not optimize the query with the HexInt
@@ -813,14 +813,14 @@ def augment_transactions_with_spans(
813813
projects.add(error["project.id"])
814814
ts_params = find_timestamp_params(transactions)
815815
time_buffer = options.get("performance.traces.span_query_timebuffer_hours")
816-
sentry_sdk.set_measurement("trace_view.spans.time_buffer", time_buffer)
816+
set_span_data("trace_view.spans.time_buffer", time_buffer)
817817
if ts_params["min"]:
818818
params.start = ts_params["min"] - timedelta(hours=time_buffer)
819819
if ts_params["max"]:
820820
params.end = ts_params["max"] + timedelta(hours=time_buffer)
821821

822822
if ts_params["max"] and ts_params["min"]:
823-
sentry_sdk.set_measurement(
823+
set_span_data(
824824
"trace_view.trace_duration", (ts_params["max"] - ts_params["min"]).total_seconds()
825825
)
826826
sentry_sdk.set_tag("trace_view.missing_timestamp_constraints", False)
@@ -899,7 +899,7 @@ def augment_transactions_with_spans(
899899
total_chunks = 3
900900
else:
901901
total_chunks = 4
902-
sentry_sdk.set_measurement("trace_view.span_query.total_chunks", total_chunks)
902+
set_span_data("trace_view.span_query.total_chunks", total_chunks)
903903
chunks = chunked(list_spans, (len(list_spans) // total_chunks) + 1)
904904
queries = [build_span_query(trace_id, spans_params, chunk) for chunk in chunks]
905905
results = bulk_snuba_queries(
@@ -1046,15 +1046,16 @@ def record_analytics(
10461046
sentry_sdk.set_tag(
10471047
"trace_view.transactions.grouped", format_grouped_length(len_transactions)
10481048
)
1049-
set_measurement("trace_view.transactions", len_transactions)
1049+
set_span_data("trace_view.transactions", len_transactions)
1050+
10501051
projects: set[int] = set()
10511052
for transaction in transactions:
10521053
projects.add(transaction["project.id"])
10531054

10541055
len_projects = len(projects)
10551056
sentry_sdk.set_tag("trace_view.projects", len_projects)
10561057
sentry_sdk.set_tag("trace_view.projects.grouped", format_grouped_length(len_projects))
1057-
set_measurement("trace_view.projects", len_projects)
1058+
set_span_data("trace_view.projects", len_projects)
10581059

10591060
def get(self, request: Request, organization: Organization, trace_id: str) -> HttpResponse:
10601061
if not self.has_feature(organization, request):

src/sentry/api/endpoints/organization_profiling_functions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sentry.snuba.dataset import Dataset
2525
from sentry.snuba.referrer import Referrer
2626
from sentry.utils.dates import parse_stats_period, validate_interval
27-
from sentry.utils.sdk import set_measurement
27+
from sentry.utils.sdk import set_span_data
2828
from sentry.utils.snuba import bulk_snuba_queries
2929

3030
TOP_FUNCTIONS_LIMIT = 50
@@ -202,7 +202,7 @@ def get_trends_data(stats_data) -> list[BreakpointData]:
202202
trending_functions = get_trends_data(stats_data)
203203

204204
all_trending_functions_count = len(trending_functions)
205-
set_measurement("profiling.top_functions", all_trending_functions_count)
205+
set_span_data("profiling.top_functions", all_trending_functions_count)
206206

207207
# Profiling functions have a resolution of ~10ms. To increase the confidence
208208
# of the results, the caller can specify a min threshold for the trend difference.
@@ -215,9 +215,7 @@ def get_trends_data(stats_data) -> list[BreakpointData]:
215215
]
216216

217217
filtered_trending_functions_count = all_trending_functions_count - len(trending_functions)
218-
set_measurement(
219-
"profiling.top_functions.below_threshold", filtered_trending_functions_count
220-
)
218+
set_span_data("profiling.top_functions.below_threshold", filtered_trending_functions_count)
221219

222220
# Make sure to sort the results so that it's in order of largest change
223221
# to smallest change (ASC/DESC depends on the trend type)

src/sentry/api/endpoints/organization_tags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from sentry.api.utils import clamp_date_range, handle_query_errors
1616
from sentry.snuba.dataset import Dataset
1717
from sentry.utils.numbers import format_grouped_length
18-
from sentry.utils.sdk import set_measurement
18+
from sentry.utils.sdk import set_span_data
1919

2020

2121
@region_silo_endpoint
@@ -83,6 +83,6 @@ def get(self, request: Request, organization) -> Response:
8383
format_grouped_length(len(results), [1, 10, 50, 100]),
8484
)
8585
sentry_sdk.set_tag("dataset_queried", dataset.value)
86-
set_measurement("custom_tags.count", len(results))
86+
set_span_data("custom_tags.count", len(results))
8787

8888
return Response(serialize(results, request.user))

src/sentry/api/endpoints/organization_traces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from sentry.snuba.dataset import Dataset
5050
from sentry.snuba.referrer import Referrer
5151
from sentry.utils.numbers import clip
52-
from sentry.utils.sdk import set_measurement
52+
from sentry.utils.sdk import set_span_data
5353
from sentry.utils.snuba import bulk_snuba_queries_with_referrers
5454
from sentry.utils.snuba_rpc import get_traces_rpc
5555

@@ -1417,7 +1417,7 @@ def process_user_queries(
14171417
where, _ = resolve_conditions(user_query)
14181418
queries[user_query] = where
14191419

1420-
set_measurement("user_queries_count", len(queries))
1420+
set_span_data("user_queries_count", len(queries))
14211421
sentry_sdk.set_context("user_queries", {"raw_queries": user_queries})
14221422

14231423
return queries
@@ -1452,7 +1452,7 @@ def process_rpc_user_queries(
14521452
if where is not None:
14531453
queries[user_query] = where
14541454

1455-
set_measurement("user_queries_count", len(queries))
1455+
set_span_data("user_queries_count", len(queries))
14561456
sentry_sdk.set_context("user_queries", {"raw_queries": user_queries})
14571457

14581458
return queries

src/sentry/api/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from sentry.silo.base import SiloMode
4545
from sentry.types.region import get_local_region
4646
from sentry.utils.dates import parse_stats_period
47-
from sentry.utils.sdk import capture_exception, merge_context_into_scope
47+
from sentry.utils.sdk import capture_exception, merge_context_into_scope, set_span_data
4848
from sentry.utils.snuba import (
4949
DatasetSelectionError,
5050
QueryConnectionFailed,
@@ -454,7 +454,7 @@ def update_snuba_params_with_timestamp(
454454
# While possible, the majority of traces shouldn't take more than a week
455455
# Starting with 3d for now, but potentially something we can increase if this becomes a problem
456456
time_buffer = options.get("performance.traces.transaction_query_timebuffer_days")
457-
sentry_sdk.set_measurement("trace_view.transactions.time_buffer", time_buffer)
457+
set_span_data("trace_view.transactions.time_buffer", time_buffer)
458458
example_start = example_timestamp - timedelta(days=time_buffer)
459459
example_end = example_timestamp + timedelta(days=time_buffer)
460460
# If timestamp is being passed it should always overwrite the statsperiod or start & end

src/sentry/event_manager.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
from sentry.utils.performance_issues.performance_detection import detect_performance_problems
138138
from sentry.utils.performance_issues.performance_problem import PerformanceProblem
139139
from sentry.utils.safe import get_path, safe_execute, setdefault_path, trim
140-
from sentry.utils.sdk import set_measurement
140+
from sentry.utils.sdk import set_span_data
141141
from sentry.utils.tag_normalization import normalized_sdk_tag_from_event
142142

143143
from .utils.event_tracker import TransactionStageStatus, track_sampled_event
@@ -2587,9 +2587,8 @@ def save_transaction_events(
25872587
)
25882588
except KeyError:
25892589
continue
2590-
2591-
set_measurement(measurement_name="jobs", value=len(jobs))
2592-
set_measurement(measurement_name="projects", value=len(projects))
2590+
set_span_data("jobs", len(jobs))
2591+
set_span_data("projects", len(projects))
25932592

25942593
# NOTE: Keep this list synchronized with sentry/spans/consumers/process_segments/message.py
25952594

src/sentry/ingest/transaction_clusterer/rules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from sentry.ingest.transaction_clusterer.rule_validator import RuleValidator
1010
from sentry.models.project import Project
1111
from sentry.utils import metrics
12+
from sentry.utils.sdk import set_span_data
1213

1314
from .base import ReplacementRule
1415

@@ -145,7 +146,7 @@ def _trim_rules(self, rules: RuleSet) -> RuleSet:
145146
sorted_rules = [rule for rule in sorted_rules if rule[1] >= last_seen_deadline]
146147

147148
if self.MERGE_MAX_RULES < len(rules):
148-
sentry_sdk.set_measurement("discarded_rules", len(rules) - self.MERGE_MAX_RULES)
149+
set_span_data("discarded_rules", len(rules) - self.MERGE_MAX_RULES)
149150
sentry_sdk.Scope.get_isolation_scope().set_context(
150151
"clustering_rules_max",
151152
{

src/sentry/models/release.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from sentry.utils.db import atomic_transaction
4646
from sentry.utils.hashlib import hash_values, md5_text
4747
from sentry.utils.numbers import validate_bigint
48+
from sentry.utils.sdk import set_span_data
4849

4950
logger = logging.getLogger(__name__)
5051

@@ -644,7 +645,8 @@ def set_commits(self, commit_list):
644645
This will clear any existing commit log and replace it with the given
645646
commits.
646647
"""
647-
sentry_sdk.set_measurement("release.set_commits", len(commit_list))
648+
set_span_data("release.set_commits", len(commit_list))
649+
648650
from sentry.models.releases.set_commits import set_commits
649651

650652
set_commits(self, commit_list)

src/sentry/profiles/task.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from sentry.utils.kafka_config import get_kafka_producer_cluster_options, get_topic_definition
5454
from sentry.utils.locking import UnableToAcquireLock
5555
from sentry.utils.outcomes import Outcome, track_outcome
56-
from sentry.utils.sdk import set_measurement
56+
from sentry.utils.sdk import set_span_data
5757

5858
REVERSE_DEVICE_CLASS = {next(iter(tags)): label for label, tags in DEVICE_CLASS.items()}
5959

@@ -223,10 +223,9 @@ def process_profile_task(
223223
if "version" in profile:
224224
version = profile["version"]
225225
sentry_sdk.set_tag("format", f"sample_v{version}")
226-
227-
set_measurement("profile.samples", len(profile["profile"]["samples"]))
228-
set_measurement("profile.stacks", len(profile["profile"]["stacks"]))
229-
set_measurement("profile.frames", len(profile["profile"]["frames"]))
226+
set_span_data("profile.samples", len(profile["profile"]["samples"]))
227+
set_span_data("profile.stacks", len(profile["profile"]["stacks"]))
228+
set_span_data("profile.frames", len(profile["profile"]["frames"]))
230229
elif "profiler_id" in profile and profile["platform"] == "android":
231230
sentry_sdk.set_tag("format", "android_chunk")
232231
else:
@@ -252,9 +251,9 @@ def process_profile_task(
252251
_set_frames_platform(profile)
253252

254253
if "version" in profile:
255-
set_measurement("profile.samples.processed", len(profile["profile"]["samples"]))
256-
set_measurement("profile.stacks.processed", len(profile["profile"]["stacks"]))
257-
set_measurement("profile.frames.processed", len(profile["profile"]["frames"]))
254+
set_span_data("profile.samples.processed", len(profile["profile"]["samples"]))
255+
set_span_data("profile.stacks.processed", len(profile["profile"]["stacks"]))
256+
set_span_data("profile.frames.processed", len(profile["profile"]["frames"]))
258257

259258
if options.get("profiling.stack_trace_rules.enabled"):
260259
try:
@@ -372,8 +371,7 @@ def _symbolicate_profile(profile: Profile, project: Project) -> bool:
372371
raw_modules, raw_stacktraces, frames_sent = _prepare_frames_from_profile(
373372
profile, platform
374373
)
375-
376-
set_measurement(
374+
set_span_data(
377375
f"profile.frames.sent.{platform}",
378376
len(frames_sent),
379377
)

src/sentry/profiles/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from sentry.grouping.enhancer import Enhancements, keep_profiling_rules
1616
from sentry.net.http import connection_from_url
1717
from sentry.utils import json, metrics
18-
from sentry.utils.sdk import set_measurement
18+
from sentry.utils.sdk import set_span_data
1919

2020
Profile = MutableMapping[str, Any]
2121
CallTrees = Mapping[str, list[Any]]
@@ -113,8 +113,7 @@ def get_from_profiling_service(
113113
)
114114
with sentry_sdk.start_span(op="json.dumps"):
115115
data = json.dumps(json_data).encode("utf-8")
116-
117-
set_measurement("payload.size", len(data), unit="byte")
116+
set_span_data("payload.size", len(data))
118117
if metric:
119118
metric_name, metric_tags = metric
120119
metrics.distribution(metric_name, len(data), tags=metric_tags)

src/sentry/search/events/fields.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from sentry.search.events.types import NormalizedArg, ParamsType
4848
from sentry.search.utils import InvalidQuery, parse_duration
4949
from sentry.utils.numbers import format_grouped_length
50-
from sentry.utils.sdk import set_measurement
50+
from sentry.utils.sdk import set_span_data
5151
from sentry.utils.snuba import (
5252
SESSIONS_SNUBA_MAP,
5353
get_json_type,
@@ -135,15 +135,15 @@ def project_threshold_config_expression(
135135
"project_threshold.count.grouped",
136136
format_grouped_length(num_project_thresholds, [10, 100, 250, 500]),
137137
)
138-
set_measurement("project_threshold.count", num_project_thresholds)
138+
set_span_data("project_threshold.count", num_project_thresholds)
139139

140140
num_transaction_thresholds = transaction_threshold_configs.count()
141141
sentry_sdk.set_tag("txn_threshold.count", num_transaction_thresholds)
142142
sentry_sdk.set_tag(
143143
"txn_threshold.count.grouped",
144144
format_grouped_length(num_transaction_thresholds, [10, 100, 250, 500]),
145145
)
146-
set_measurement("txn_threshold.count", num_transaction_thresholds)
146+
set_span_data("txn_threshold.count", num_transaction_thresholds)
147147

148148
if num_project_thresholds + num_transaction_thresholds == 0:
149149
return ["tuple", [f"'{DEFAULT_PROJECT_THRESHOLD_METRIC}'", DEFAULT_PROJECT_THRESHOLD]]
@@ -283,7 +283,7 @@ def team_key_transaction_expression(organization_id, team_ids, project_ids):
283283
sentry_sdk.set_tag(
284284
"team_key_txns.count.grouped", format_grouped_length(count, [10, 100, 250, 500])
285285
)
286-
set_measurement("team_key_txns.count", count)
286+
set_span_data("team_key_txns.count", count)
287287

288288
# There are no team key transactions marked, so hard code false into the query.
289289
if count == 0:

0 commit comments

Comments
 (0)