#configuring traces_sampler

1 messages · Page 1 of 1 (latest)

acoustic flax
#

I've got this config:


def sentry_traces_sampler(sampling_context):
    if tx_context := sampling_context.get("transaction_context"):
        if tx_context.get("name") == "/mqtt-sync/":
            return 0.01
    return 0.1


GITHUB_SHA = env("GITHUB_SHA", "")
RELEASE_VERSION = env("RELEASE_VERSION", "")
if RELEASE_VERSION == "main":
    RELEASE_VERSION = GITHUB_SHA
SENTRY_DSN = env("SENTRY_DSN", None)
SENTRY_ENV = env("SENTRY_ENVIRONMENT", "development")
if SENTRY_DSN:
    sentry_sdk.init(
        dsn=SENTRY_DSN,
        environment=SENTRY_ENV,
        release=RELEASE_VERSION,
        integrations=[
            DjangoIntegration(),
            StrawberryIntegration(
                async_execution=False,
            ),
        ],
        enable_tracing=True,
        traces_sampler=sentry_traces_sampler,
        send_default_pii=True,
    )

however, i'm still seeing a higher than expected volume come through for the mqtt-sync transaction. How can i be sure it's accurately filtering? it's blowing through my performance units. i think it's the only one but not sure.

short nimbus
#

Hi, Can you go to Explore->Discover->transactions - You can aggregate and find answers there

acoustic flax
#

thanks. they don't seem to be getting filtered in my sampler function based on the history i see there

#

i was assuming the value for the name was what i saw here but seems like maybe not

#

is there any documentation for the transaction_context data?

#

i debugged it locally, unfortunately it doesn't look like there is anything useful in the context, the transaction name is just "generic WSGI request"

#

no way to distinguish between requests to that endpoint and all the others

short nimbus
acoustic flax
#

found it after running things locally and printing output so i could see whaqt data was available

#
def sentry_traces_sampler(sampling_context):
    if path_info := sampling_context.get("wsgi_environ", {}).get("PATH_INFO"):
        if path_info == "/mqtt-sync/":
            return 0.01
    return 0.1
#

have to grab the PATH_INFO from the request context

short nimbus
#

Would love to understand how you're using tracing today and if you had a chance to look at our new capabilities that let you aggregate your spans as you'd like

Product Blog • Sentry

Slice and dice your trace data with Sentry's new Trace Explorer. Create custom span-based metrics, query custom attributes, and finally sort by timestamp. Give it a shot today.

acoustic flax
#

We are mostly focused on building a couple new internal tools. added tracing out of the box many months ago to just have, and after reviewing some monthly bills, it became obvious that i don't need certain endpoints traced at teh same level as others (iot data collection that gets blasted every few seconds versus user endpoints).

not paying too much attention to tracing stuff until we can get feature complete and fully launched, then will dedicate some time periodically to review performance and tighten things up

#

looks like a lot to read through and study

short nimbus
#

Thanks for this feedback 🙏

acoustic flax
#

Anytime. Long time fan of Sentry. I’m sure I’m under utilizing the available features. Do you offer anything like an account review?