Skip to content
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

feat(profiling): pass internal (profile-scoped) dsn for function metrics ingestion to vroom #66300

Merged
merged 5 commits into from
Mar 6, 2024
Merged
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
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"
):
Comment on lines +141 to +145
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we should move this to a feature flag using the options backed rollout handler for a more incremental rollout.

But for initial testing, this is fine 👍

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)
Loading