Skip to content
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
1 change: 1 addition & 0 deletions src/sentry/api/serializers/models/project_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def serialize(
"crons": obj.crons_endpoint,
"cdn": obj.js_sdk_loader_cdn_url,
"playstation": obj.playstation_endpoint,
"integration": obj.integration_endpoint,
"otlp_traces": obj.otlp_traces_endpoint,
"otlp_logs": obj.otlp_logs_endpoint,
},
Expand Down
1 change: 1 addition & 0 deletions src/sentry/apidocs/examples/project_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
"minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
"playstation": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/playstation/?sentry_key=a785682ddda719b7a8a4011110d75598",
"integration": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/",
"otlp_traces": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/otlp/v1/traces",
"otlp_logs": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/otlp/v1/logs",
"nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",
Expand Down
14 changes: 9 additions & 5 deletions src/sentry/models/projectkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,20 @@ def playstation_endpoint(self):
return f"{endpoint}/api/{self.project_id}/playstation/?sentry_key={self.public_key}"

@property
def otlp_traces_endpoint(self):
def integration_endpoint(self):
endpoint = self.get_endpoint()
return f"{endpoint}/api/{self.project_id}/integration/"

return f"{endpoint}/api/{self.project_id}/integration/otlp/v1/traces"
def build_integration_endpoint(self, integration_name: str, postfix: str = "") -> str:
return f"{self.integration_endpoint}/{integration_name}/{postfix}"

@property
def otlp_logs_endpoint(self):
endpoint = self.get_endpoint()
def otlp_traces_endpoint(self):
return self.build_integration_endpoint("otlp", "v1/traces")

return f"{endpoint}/api/{self.project_id}/integration/otlp/v1/logs"
@property
def otlp_logs_endpoint(self):
return self.build_integration_endpoint("otlp", "v1/logs")
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Double Slash URL Bug

The build_integration_endpoint method creates URLs with double slashes. The integration_endpoint property already returns a URL with a trailing slash, and build_integration_endpoint adds another, resulting in an incorrect format like /integration//otlp/v1/traces. This breaks existing OTLP endpoint URLs.

Fix in Cursor Fix in Web


@property
def unreal_endpoint(self) -> str:
Expand Down
15 changes: 15 additions & 0 deletions tests/sentry/core/endpoints/test_project_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ def test_playstation_dsn(self) -> None:
assert response.status_code == 200
assert response.data[0]["dsn"]["playstation"] == key.playstation_endpoint

def test_integration_endpoint(self) -> None:
project = self.create_project()
key = ProjectKey.objects.get_or_create(project=project)[0]
self.login_as(user=self.user)
url = reverse(
"sentry-api-0-project-keys",
kwargs={
"organization_id_or_slug": project.organization.slug,
"project_id_or_slug": project.slug,
},
)
response = self.client.get(url)
assert response.status_code == 200
assert response.data[0]["dsn"]["integration"] == key.integration_endpoint

def test_otlp_traces_endpoint(self) -> None:
project = self.create_project()
key = ProjectKey.objects.get_or_create(project=project)[0]
Expand Down
Loading