Skip to content

Commit

Permalink
feat(profiling): pass internal (profile-scoped) dsn for function metr…
Browse files Browse the repository at this point in the history
…ics ingestion to vroom (#66300)
  • Loading branch information
viglia authored and aliu39 committed Mar 6, 2024
1 parent 1445beb commit de9eedd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/sentry/profiles/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections.abc import Mapping, MutableMapping
from copy import deepcopy
from datetime import datetime, timezone
from functools import lru_cache
from time import time
from typing import Any

Expand All @@ -21,6 +22,7 @@
from sentry.models.eventerror import EventError
from sentry.models.organization import Organization
from sentry.models.project import Project
from sentry.models.projectkey import ProjectKey, UseCase
from sentry.profiles.device import classify_device
from sentry.profiles.java import deobfuscate_signature, format_signature
from sentry.profiles.utils import get_from_profiling_service
Expand Down Expand Up @@ -136,6 +138,20 @@ def process_profile_task(
set_measurement("profile.stacks.processed", len(profile["profile"]["stacks"]))
set_measurement("profile.frames.processed", len(profile["profile"]["frames"]))

if options.get(
"profiling.generic_metrics.functions_ingestion.enabled"
) and project.organization_id in options.get(
"profiling.generic_metrics.functions_ingestion.allowed_org_ids"
):
try:
with metrics.timer("process_profile.get_metrics_dsn"):
dsn = get_metrics_dsn(project.id)
profile["options"] = {
"dsn": dsn,
}
except Exception as e:
sentry_sdk.capture_exception(e)

if not _push_profile_to_vroom(profile, project):
return

Expand Down Expand Up @@ -898,3 +914,11 @@ def clean_android_js_profile(profile: Profile):
del p["event_id"]
del p["release"]
del p["dist"]


@lru_cache(maxsize=100)
def get_metrics_dsn(project_id: int) -> str:
project_key, _ = ProjectKey.objects.get_or_create(
project_id=project_id, use_case=UseCase.PROFILING.value
)
return project_key.get_dsn(public=True)

0 comments on commit de9eedd

Please sign in to comment.