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 structured logging reports via new Erlang 21 logger #3526

Merged
merged 16 commits into from
Apr 30, 2021
Merged

Conversation

kocolosk
Copy link
Member

@kocolosk kocolosk commented Apr 23, 2021

Overview

This PR adds log statements as structured reports (i.e. Erlang maps) using the macros defined by Erlang itself as part of the new approach to logging implemented in Erlang 21. It does not introduce any handler configuration to actually process these reports; that will come in a subsequent PR.

Testing recommendations

You should observe any change in logging behavior.

Related Issues or Pull Requests

Initial discussion about structured logging dates to at least #1373

Checklist

The new logger only works in Erlang 21+, so we can start simplifying
the codebase by removing the macro that provides support for retrieving
stack traces the old way.
@@ -191,7 +191,7 @@ ErlOpts = case os:getenv("ERL_OPTS") of
end.

AddConfig = [
{require_otp_vsn, "20|21|22|23"},
{require_otp_vsn, "21|22|23"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't review the rest but wanted to explicitly say "+1 for dropping 20.x on main, -1 for dropping 20.x on 3.x."

That means this wouldn't easily be backported to 3.x, until such time as we can confirm >20.x on 3.x code is stable at scale.

what => invalid_transaction_option_value,
option => Option,
value => Val,
details => "string transaction option must be less than 16 bytes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be less than or less than or equal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case statement checks for < 16 so that's what I put into the log message. I know the previous log message said differently. I didn't check if a 16 byte was actually allowed by erlfdb or not; if it is, we should update the test in the case statement as well as the log message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think the check is wrong. I remember going by the other client's API docs (Python I think) https://apple.github.io/foundationdb/api-python.html#database-options and it said up to 16 hexadecimal digits. But we can fix it in a separate PR.

Out of curiosity, had actually disabled the check locally and set to a much higher value and nothing seems to have happened but it's better to just go by the documentation and stick to =< 16.

fdbserver --help also indicates the same:

 /usr/sbin/fdbserver --help | grep -A2 machine_id
  -i ID, --machine_id ID
                 Machine and zone identifier key (up to 16 hex characters).
                 Defaults to a random value shared by all fdbserver processes

src/chttpd/src/chttpd.erl Outdated Show resolved Hide resolved
@kocolosk kocolosk changed the title Adopt structured logging via new Erlang 21 logger Add structured logging reports via new Erlang 21 logger Apr 28, 2021
@kocolosk kocolosk marked this pull request as ready for review April 28, 2021 17:02
@kocolosk
Copy link
Member Author

All set from my perspective now. This is only adding the logging invocations; all the work of defining and configuring the handlers, formatters, and filters will come in a separate PR.

couch_log:info("Apache CouchDB ~s is starting.~n", [
couch_server:get_version()
]).


notify_started() ->
?LOG_INFO(#{
what => starting_couchdb_complete,
time_to_relax => true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

Copy link
Contributor

@iilyak iilyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me

Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Nice work!

@kocolosk kocolosk merged commit 720393b into main Apr 30, 2021
@kocolosk kocolosk deleted the new-logger branch April 30, 2021 17:56
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

Successfully merging this pull request may close these issues.

4 participants