Skip to content

fix(grape): detect code namespace for API instance endpoints#2407

Merged
kaylareopelle merged 1 commit into
open-telemetry:mainfrom
thatch-health:fix-grape-code-namespace-for-instance-api
Jul 9, 2026
Merged

fix(grape): detect code namespace for API instance endpoints#2407
kaylareopelle merged 1 commit into
open-telemetry:mainfrom
thatch-health:fix-grape-code-namespace-for-instance-api

Conversation

@bdewater-thatch

@bdewater-thatch bdewater-thatch commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Direct Grape::API::Instance subclasses expose endpoint.options[:for] as the endpoint class itself rather than a generated mount instance with @base set. The previous instrumentation only read @base, which produced nil and caused the SDK to log invalid code.namespace attribute value errors.

We're subclassing Grape::API::Instance directly because we're using Sorbet in our Rails app, with our grape_sorbet gem for the signatures. The reason it works this way is documented here: https://github.com/thatch-health/grape_sorbet#subclassing-from-grapeapiinstance-instead-of-grapeapi

Direct Grape::API::Instance subclasses expose endpoint.options[:for] as the endpoint class itself rather than a generated mount instance with @base set. The previous instrumentation only read @base, which produced nil and caused the SDK to log invalid code.namespace attribute value errors. Fall back to the owner class name and omit code.namespace when no namespace can be derived.
@bdewater-thatch
bdewater-thatch force-pushed the fix-grape-code-namespace-for-instance-api branch from 3b10d39 to fe96ae7 Compare June 17, 2026 18:14
@bdewater-thatch bdewater-thatch changed the title Fix Grape code namespace for API instance endpoints fix(grape): detect code namespace for API instance endpoints Jun 17, 2026

@kaylareopelle kaylareopelle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you, @bdewater-thatch!

@kaylareopelle
kaylareopelle added this pull request to the merge queue Jul 9, 2026
Merged via the queue into open-telemetry:main with commit 969a3e6 Jul 9, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants