Class: AppProfiler::ProfileId::Current
- Inherits:
-
Object
- Object
- AppProfiler::ProfileId::Current
- Defined in:
- lib/app_profiler/profile_id.rb
Constant Summary collapse
- PROFILE_ID_KEY =
:__app_profiler_profile_id__
Class Method Summary collapse
-
.id ⇒ Object
This is a thread local variable which gets reset by the middleware at the end of the request.
- .id=(id) ⇒ Object
- .reset ⇒ Object
Class Method Details
.id ⇒ Object
This is a thread local variable which gets reset by the middleware at the end of the request. Need to be mindful of the middleware order. If we try to access ProfileId after the middleware has finished, lets say in a middleware which runs before Profiling middleware, it will return a different value, as the middleware has already reset.
15 16 17 |
# File 'lib/app_profiler/profile_id.rb', line 15 def id Thread.current[PROFILE_ID_KEY] ||= SecureRandom.hex end |
.id=(id) ⇒ Object
19 20 21 |
# File 'lib/app_profiler/profile_id.rb', line 19 def id=(id) Thread.current[PROFILE_ID_KEY] = id end |
.reset ⇒ Object
23 24 25 |
# File 'lib/app_profiler/profile_id.rb', line 23 def reset Thread.current[PROFILE_ID_KEY] = nil end |