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

Sentry transaction name #2351

Open
mbajur opened this issue Sep 20, 2023 · 2 comments
Open

Sentry transaction name #2351

mbajur opened this issue Sep 20, 2023 · 2 comments
Labels

Comments

@mbajur
Copy link

mbajur commented Sep 20, 2023

Hello! I'm using Grape gem in one of my production apps. This app also uses Sentry for error reporting and performance monitoring. This issue is not strictly tied to grape but - for some reason, Sentry transaction naming works fine for regular rails controllers and actions but not for grape ones. It uses request URL instead. So, for regular rails transactions i'm getting Doorkeeper::TokensController#create while for grape actions, i'm getting /api/v1/records/1 etc. This thing can be configured by using Sentry.configure_scope { |scope| scope.set_transaction_name("MyController#my_action") } before the actual transaction and i was wondering:

Is that possible to access current resource and action names in before filter of my grape api, globally? By globally i mean not separately in each resource but rather in the parent Base < Grape::API class.

Thanks in advance for any clues

@dblock
Copy link
Member

dblock commented Sep 20, 2023

It depends on what you mean by "resource". Grape generates anonymous methods when you write get do ..., so it's unlike Rails which has a controller class with a create method.

The current endpoint serving the request is self in the context of the request, and env[Grape::Env::API_ENDPOINT] elsewhere, so you should be able to get started with that. There might be some complications with multiple routes.

In general, I'd like to be able to add Sentry in the list of https://github.com/ruby-grape/grape#monitoring-products. Take a look at the implementations of those, maybe you'll find exactly what you're looking for or adapt something?

@numbata
Copy link
Contributor

numbata commented Jul 4, 2024

It looks feasible using the same approach as in Datadog Instrumentation. See the usage of the api_view method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants