GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tracesSampler "name" property missing route name with Fastify integration · Issue #12944 · getsentry/sentry-javascript

tracesSampler "name" property missing route name with Fastify integration #12944

New issue
Copy link
New issue
Copy link
Closed
#12945
Closed
tracesSampler "name" property missing route name with Fastify integration#12944
#12945
Copy link

Description

@MattJustMatt
MattJustMatt
opened on Jul 17, 2024
Issue body actions

Is there an existing issue for this?

  • I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • I have reviewed the documentation https://docs.sentry.io/
  • I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.18

Framework Version

Fastify v4

Link to Sentry event

No response

SDK Setup/Reproduction Example

Sentry.init({
dsn: "https://763f4daed63fb0d58072fa782c353c8d@o4505228622036992.ingest.us.sentry.io/4505903337570304",
debug: false,
integrations: [
nodeProfilingIntegration(),
],

tracesSampler: ({ name, attributes, parentSampled }) => {
// for fastify routes, name is always just the http method e.g. "GET"
}

Steps to Reproduce

See above ^

Expected Result

name should be the full route name e.g. POST /games/:gameId/join

Actual Result

The name returned is just "POST" I can get the url from attributes but this isn't ideal for parameterized routes.

Overall was a smooth experience upgrading from v7/fastify-sentry to native v8, great update otherwise! :)

Activity

  1. MattJustMatt
    added
    Type: Bug
    on Jul 17, 2024
  2. getsantry
    added
    Waiting for: Product Owner
    on Jul 17, 2024
  3. getsantry
    added this to GitHub Issues with 👀 3on Jul 17, 2024
  4. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 17, 2024
  5. github-actions
    added
    Package: node
    on Jul 17, 2024
  6. mydea commented on Jul 17, 2024

    @mydea
    mydea
    on Jul 17, 2024
    Member
    More actions

    hello, thanks for writing in!

    Sadly, this is a restriction we have right now with these http.server spans 😬 the problem is that these spans are created initially with just this name, and are later updated before we send them. Because of this, you'll have to make the sampling decision based on the attributes that are passed to the sampler, which should contain some more details.

    We could improve the name a bit, and I think it would be worthwhile to do that. But if may still not be the name that the span/transaction has at the very end, e.g. it may not be parametrized (e.g. GET /users/12 instead of GET /users/:id or something like this).

  7. getsantry
    removed
    Waiting for: Product Owner
    on Jul 17, 2024
  8. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 17, 2024
  9. mydea commented on Jul 17, 2024

    @mydea
    mydea
    on Jul 17, 2024
    Member
    More actions

    I opened a PR here: #12945 to improve this. You can read the PR description, this should make this much better than it is today, although there are still some caveats, but filtering should become way easier at least.

  10. MattJustMatt commented on Jul 18, 2024

    @MattJustMatt
    MattJustMatt
    on Jul 18, 2024
    Author
    More actions

    Thanks for this! Like you said things are easier now, but still a pain for some of the more complex parameterized items. Is there a path to getting the route name itself?

  11. getsantry
    added
    Waiting for: Product Owner
    on Jul 18, 2024
  12. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 18, 2024
  13. Lms24 commented on Jul 18, 2024

    @Lms24
    Lms24
    on Jul 18, 2024
    Member
    More actions

    @MattJustMatt unfortunately, there is not at span creation time due to a fundamental limitation how OpenTelemetry instrumentation works. Quoting @mydea's PR description from #12945:

    This means that we'll never have e.g. the http.route correctly there, because all http.server spans originate from the http instrumentation where they do not have a route yet, and then more specific instrumentation (e.g. express or fastify) add the http.route to that span later

    (Side note: Even if we didn't make the switch to Otel in v8, we invested a lot of time in obtaining a paramterized route name as early as possible and failed in a lot of cases. Many frameworks, for example express, were just not designed to support this use case)

    But: You can filter out the span or transaction in the beforeSendTransaction hook. At this time, its name will be parameterized. If you filter out the span, it won't be sent to Sentry or deplete your quota.

  14. getsantry
    removed
    Waiting for: Product Owner
    on Jul 18, 2024
  15. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 18, 2024
  16. Lms24 commented on Jul 18, 2024

    @Lms24
    Lms24
    on Jul 18, 2024
    Member
    More actions

    Another side note: The only way to theoretically get this working is to write a route matching algorithm where you give it the unparameterized route name and a set of available routes and you infer the right route name in return.

    We actually gave this a thought a while ago (#5510) but decided to abandon it due to usability and performance overhead concerns as well as route matching working slightly differently in different frameworks.

  17. mydea
    added a commit that references this issue on Jul 18, 2024

    fix(node): Pass inferred name & attributes to `tracesSampler` (#12945)

    ac6e2f1
  18. mydea
    closed this as completedin #12945on Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    • GitHub Issues with 👀 3
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.