Commit 729e277c authored by Stan Hu's avatar Stan Hu

Squelch Snowplow tracker log messages

These log messages often pollute structured log streams and do not
provide useful information. We tweak the log level to FATAL to suppress
all output.

https://github.com/snowplow/snowplow-ruby-tracker/pull/109
would make it possible to configure this logger directly.

Closes https://gitlab.com/gitlab-org/gitlab/issues/204755
parent 6bfe46fe
---
title: Squelch Snowplow tracker log messages
merge_request: 24809
author:
type: fixed
...@@ -3,21 +3,12 @@ ...@@ -3,21 +3,12 @@
# Gitlab.com uses Snowplow for identifying users and events. # Gitlab.com uses Snowplow for identifying users and events.
# https://gitlab.com/gitlab-org/gitlab/issues/6329 # https://gitlab.com/gitlab-org/gitlab/issues/6329
# #
# SnowplowTracker write log into STDERR # SnowplowTracker writes logs to STDERR:
# https://github.com/snowplow/snowplow-ruby-tracker/blob/39fcfa2be793f2e25e73087a9700abc93f43b5e8/lib/snowplow-tracker/emitters.rb#L23 # https://github.com/snowplow/snowplow-ruby-tracker/blob/39fcfa2be793f2e25e73087a9700abc93f43b5e8/lib/snowplow-tracker/emitters.rb#L23
# `LOGGER = Logger.new(STDERR)` if defined?(::SnowplowTracker::LOGGER)
# # This squelches the output of the logger since it doesn't really
# In puma.rb, if `stdout_redirect` specify stderr, Puma will overwrite STDERR in: # provide useful information.
# https://github.com/puma/puma/blob/b41205f5cacbc2ad0060472bdce68ba636f42175/lib/puma/runner.rb#L134 # https://github.com/snowplow/snowplow-ruby-tracker/pull/109
# `STDERR.reopen stderr, (append ? "a" : "w")` # would make it possible to configure this logger directly.
# As a result, SnowplowTracker will log into Puma stderr, when Puma enabled. ::SnowplowTracker::LOGGER.level = Logger::FATAL
#
# By default, SnowplowTracker uses default log formatter.
# When enable Puma, SnowplowTracker log is expected to be JSON format, as part of puma_stderr.log.
# Hence overwrite ::SnowplowTracker::LOGGER.formatter to JSON formatter
if defined?(::Puma) && defined?(::SnowplowTracker::LOGGER)
::SnowplowTracker::LOGGER.formatter = proc do |severity, datetime, progname, msg|
{ severity: severity, timestamp: datetime.utc.iso8601(3), pid: $$, progname: progname, message: msg }.to_json << "\n"
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment