Skip to content

Getting stable worker id for instrumentation purposes #145

@errm

Description

@errm

I maintain a small library for doing instrumentation with prometheus (https://github.com/errm/promenade)

A feature of this library is that we label metrics exported from each worker of a multi process server like pitchfork or unicorn with a stable id.
On a sever where workers can be restarted (or reforked) it's not ideal to just use the pid for this label, as it causes us some implimentation problems, and increases the cardinality on prometheus...

In unicorn we parsed $0 to get a stable id for each worker, like $0.match(/worker\[([^\]]+)\]/)

I wanted to do something similar for pitchfork, but it seems that because you are using Process.setproctitle("foo") rather than $0 = "foo" I won't be able to do this (because Process.setproctitle by design doesn't change $0).

On linux I could just read /proc/self/cmdline, but I would rather not, because it isn't very portable (and I would like things to also work on OSX development machines).

Is it possible that pitchfork could just assign to $0? Or perhaps provide some other stable interface to give the current worker a stable identity?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions