Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new header attribute for advanced logging information #21

Open
MephistosFaust opened this issue May 25, 2020 · 2 comments
Open

Add a new header attribute for advanced logging information #21

MephistosFaust opened this issue May 25, 2020 · 2 comments

Comments

@MephistosFaust
Copy link

MephistosFaust commented May 25, 2020

Hi folks,
I have the following problem. The information which will be logged into the remote_client_id field in kibana are either a uuid or an info_user_id.

morgan.token("remote_client_id", function getRemoteClientId(
      request,
      response
    ) {
      let rcId = "";

      try {
        rcId = request.headers.customeruuid;

        if (request.headers[CUSTOMER_UUID]) {
          rcId = request.headers[CUSTOMER_UUID];
        }

        if (request.headers[AUTH_INFO_USER_ID]) {
          rcId = request.headers[AUTH_INFO_USER_ID];
        }

        if (request.headers[AUTH_REMOTE_CLIENT_ID]) {
          rcId = request.headers[AUTH_REMOTE_CLIENT_ID];
        }

        if (!rcId) {
          rcId = "unknown";
        }
      } catch (e) {
        rcId = "error";
      }

      return rcId;
    });

Both of this informations are a little bit miss leading, since both are not the real client Id.
I want to write the real client Id (from an oauth token in my case) into this log field.

Unfortunately I cannot use these header attributes and just fill it with another information because other services reliant on the right UUID and an info_user_id.

So the only way to solve that problem I can imagine is to ad another if-clause and extend the logic in the method above with a new header attribute. Something like this:

if (request.headers[AUTH_REMOTE_CLIENT_ID])
 {
          rcId = request.headers[AUTH_REMOTE_CLIENT_ID];
        }

Is this an option for you?

@krystianity
Copy link
Member

sure why not :)

@MephistosFaust
Copy link
Author

Okay great. I raised a pull request to solve the issue fell free to have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants