Open
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.27.0
Steps to Reproduce
- In my existing app (using Starlette 0.41.3) I enabled Sentry tracing by passing a
traces_sampler
function in the init call (see below) - I passed
starlette.StarletteIntegration(transaction_style="endpoint")
in theintegrations
list to work around the problem that with the default"url"
style, all transactions were showing up with the name<unlabeled transaction>
instead of a Starlette route binding likeGET /status
like I was hoping. So instead I getgrid.routes.status.StatusEndpoint.get
which is the name of theget
method in our routing class, and I can live with that ... - ... but then I made the
traces_sampler
function filter out that name (see function below) because it's just a Kubernetes health check endpoint ... but that didn't work, I still got status transactions ... so to troubleshot that I loggedsampling_context["transaction_context"]["name"]
and that turns out to be the raw URL,http://123.45.6.78:5001/status
def traces_sampler(sampling_context: SamplingContext):
if sampling_context["parent_sampled"] is not None:
return sampling_context["parent_sampled"]
if sampling_context["transaction_context"]["name"] == "grid.routes.status.StatusEndpoint.get":
return 0
return traces_sample_rate
sentry_sdk.init(
dsn=self._config.sentry_dsn,
integrations=[starlette.StarletteIntegration(transaction_style="endpoint"), sentry_logging],
release=self._config.app_version,
environment=self._config.release_stage,
before_send=self._before_send,
transport=custom_transport,
traces_sampler=traces_sampler,
)
Expected Result
- with the default
transaction_style="url"
I expected to get transactions named after the route paths automatically by the Starlette integration - once I switched to
transaction_style="endpoint"
and saw distinct transaction names appear in Sentry, I expected to be able to filter by those transaction names in the transaction context passed to thetraces_sampler
function
Actual Result
- with the default
transaction_style="url"
, the actual transaction names appearing in traces in Sentry are all<unlabeled transaction>
- after I switched to
transaction_style="endpoint"
, the actual transaction context passed to thetraces_sampler
function contains"name"
which is the full URL (including the pod IP address in my Kubernetes cluster so it's going to vary in ways that are not useful to make transaction names vary by)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Waiting for: Community