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

fix: re-enable slog's envlogger #452

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions autoconnect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ serde_derive.workspace = true
serde_json.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-envlogger.workspace = true
slog-mozlog-json.workspace = true
slog-scope.workspace = true
slog-stdlog.workspace = true
Expand All @@ -53,4 +52,4 @@ docopt = "1.1"

[features]
emulator = ["bigtable"]
bigtable = ["autopush_common/bigtable", "autoconnect_settings/bigtable"]
bigtable = ["autopush_common/bigtable", "autoconnect_settings/bigtable"]
1 change: 0 additions & 1 deletion autoendpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ serde_dynamodb.workspace = true
serde_json.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-envlogger.workspace = true
slog-mozlog-json.workspace = true
slog-scope.workspace = true
slog-stdlog.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions autopush-common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ pub fn init_logging(json: bool) -> Result<()> {
.hostname(hostname)
.build()
.fuse();
let drain = slog_envlogger::new(drain);
let drain = slog_async::Async::new(drain).build().fuse();
slog::Logger::root(drain, slog_o!())
} else {
let decorator = slog_term::TermDecorator::new().build();
let drain = slog_term::FullFormat::new(decorator).build().fuse();
let drain = slog_envlogger::new(drain);
let drain = slog_async::Async::new(drain).build().fuse();
slog::Logger::root(drain, slog_o!())
};
Expand Down
1 change: 0 additions & 1 deletion autopush/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ serde_derive.workspace = true
serde_json.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-envlogger.workspace = true
slog-mozlog-json.workspace = true
slog-scope.workspace = true
slog-stdlog.workspace = true
Expand Down
39 changes: 29 additions & 10 deletions tests/test_integration_all_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def tearDown(self):

def host_endpoint(self, client):
parsed = urlparse(list(client.channels.values())[0])
"{}://{}".format(parsed.scheme, parsed.netloc)
return "{}://{}".format(parsed.scheme, parsed.netloc)

@inlineCallbacks
def quick_register(self):
Expand All @@ -844,7 +844,7 @@ def _ws_url(self):

@inlineCallbacks
@max_logs(conn=4)
def test_sentry_output(self):
def test_sentry_output_autoconnect(self):
if os.getenv("SKIP_SENTRY"):
SkipTest("Skipping sentry test")
return
Expand All @@ -859,15 +859,34 @@ def test_sentry_output(self):
requests.get(
"http://localhost:{}/v1/err/crit".format(CONNECTION_PORT)
)
event1 = MOCK_SENTRY_QUEUE.get(timeout=5)
# new autoconnect emits 2 events
try:
data = MOCK_SENTRY_QUEUE.get(timeout=5)
except ValueError as ex:
if not ex.contains("I/O operation on closed file"):
raise ex
# python2 on circleci will fail this test due to an IO error.
# Local testing shows that this test works.
# This may resolve by updating tests to python3 (see #334)
assert data["exception"]["values"][0]["value"] == "LogCheck"
maybe_event2 = MOCK_SENTRY_QUEUE.get(timeout=1)
except Empty:
pass
assert event1["exception"]["values"][0]["value"] == "LogCheck"

@inlineCallbacks
@max_logs(endpoint=1)
def test_sentry_output_autoendpoint(self):
if os.getenv("SKIP_SENTRY"):
SkipTest("Skipping sentry test")
return

client = yield self.quick_register()
endpoint = self.host_endpoint(client)
yield self.shut_down(client)

requests.get("{}/__error__".format(endpoint))
# 2 events excpted: 1 from a panic and 1 from a returned Error
event1 = MOCK_SENTRY_QUEUE.get(timeout=5)
event2 = MOCK_SENTRY_QUEUE.get(timeout=1)
values = (
event1["exception"]["values"][0]["value"],
event2["exception"]["values"][0]["value"],
)
assert sorted(values) == ["ERROR:Success", "LogCheck"]

@max_logs(conn=4)
def test_no_sentry_output(self):
Expand Down