ScoutApm.Logging.ContextExtractor (scout_apm v2.0.0)
Copy MarkdownExtracts Scout APM context from the current process for log enrichment.
Reads from Process.get(:scout_apm_request) to extract:
- scout_transaction_id - TrackedRequest.id
- scout_start_time - Root layer start time (ISO 8601)
- scout_end_time - Root layer end time (ISO 8601, if completed)
- scout_duration - Request duration in seconds (if completed)
- scout_current_operation - Current span's type/name
- controller_entrypoint / job_entrypoint / custom_entrypoint - Entrypoint name
- scouttag{key} - Custom tags from ScoutApm.Context
- user.{key} - User context (excluding ip)
- service.name - From config
Summary
Functions
Extracts Scout APM context from the current process. Returns a list of {key, value} tuples suitable for log enrichment.
Extracts context from a specific TrackedRequest struct.
Stashes Scout context into Logger metadata so it survives TrackedRequest cleanup.
Functions
Extracts Scout APM context from the current process. Returns a list of {key, value} tuples suitable for log enrichment.
Extracts context from a specific TrackedRequest struct.
Stashes Scout context into Logger metadata so it survives TrackedRequest cleanup.
Call this when a Controller or Job layer starts. The metadata persists on the process for the entire request lifetime, so logs emitted after TrackedRequest is cleaned up (e.g., Phoenix endpoint stop logs) still get Scout context.