Skip to content

make environment configuration more flexible #41

@ghost

Description

I would like to set Notice.env to the hostname (I realise that the host is already available in Notice.hostname, but this field is not displayed on Errbit's error list screen, whereas the environment is).

AFAIK, the only reliable way to get the hostname is from the request object, e.g.

RequestContextHolder.requestAttributes?.currentRequest?.getHeader('X-Forwarded-Host')

However, if I configure

grails.plugins.airbrake.env = RequestContextHolder.requestAttributes?.currentRequest?.getHeader('X-Forwarded-Host')

this won't work, because there is no request object when this configuration is read. Instead, I would like to be able to do this

grails.plugins.airbrake.env = { RequestAttributes webRequest ->
    webRequest?.currentRequest?.getHeader('X-Forwarded-Host')
}

@cavneb if you've no objection to this (and are willing to release a new version that includes this change), could you let me know, and I'll send a pull-request with the relevant code changes?

I'll make this change such that it's backwards compatible, i.e. the environment will be resolved by passing the current request into the closure above only if a closure is assigned to grails.plugins.airbrake.env.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions