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 #4055

Merged
merged 31 commits into from
Nov 9, 2021
Merged

Add Structured Logging #4055

merged 31 commits into from
Nov 9, 2021

Conversation

nathaniel-may
Copy link
Contributor

@nathaniel-may nathaniel-may commented Oct 13, 2021

resolves #3359

Description

The structured-logging branch is a feature branch and small incremental changes should be merged via PR into this branch. Tests need to pass for each merge into this feature branch. There are many integration tests that rely on certain wording of log messages, and it is important that these tests remain intact by converting them to use codes incrementally.

Phase 1:

Phase 2:

  • add additional log lines for node status reporting
  • create scalable in-memory event history
  • improve message wording
  • fine tune structlog configs including look and feel
  • add codes to each event
  • add thread id to each event
  • make sure we can distinguish logs from different runs (preserve process id like it is today, or allow some sort of user markers)
  • upgrade rpc backdoor away from env vars ala Add Structured Logging #4055

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change

@cla-bot cla-bot bot added the cla:yes label Oct 13, 2021
@nathaniel-may nathaniel-may force-pushed the feature/structured-logging branch 2 times, most recently from 496f54e to 5c9fd07 Compare October 26, 2021 17:57
@emmyoop emmyoop force-pushed the feature/structured-logging branch from 89e478f to 66cece0 Compare November 8, 2021 20:32
Copy link
Contributor

@kwigley kwigley left a comment

Choose a reason for hiding this comment

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

woo! left some questions for anyone who is familiar 😄

core/dbt/events/functions.py Outdated Show resolved Hide resolved
core/dbt/events/functions.py Show resolved Hide resolved
@@ -0,0 +1,213 @@

from colorama import Style
import dbt.events.functions as this # don't worry I hate it too.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it's not needed! But I couldn't get the my functions to set the global variables without it. Without this it created a new locally scoped variable which is obviously not what I want. Idk why but I have a lot of trouble with Python's variable scoping so there's probably a better way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I just tried deleting all the this calls, and flake8 gives me F841 local variable 'format_json' is assigned to but never used 🤷‍♂️

Nathaniel May and others added 22 commits November 9, 2021 11:26
add event type modeling and fire_event calls
* updated context dir to new structured logging
handle exec info
update log call sites with new event system
graph call sites for structured logging
* first pass adding structured logging
* use __post_init__() instead of fake dataclass member vars
* update config use structured logging

* WIP

* minor cleanup

* fixed merge error

* added in ShowException

* added todo to remove defaults after dropping 3.6

* removed todo that is obsolete
* convert generic_test to structured logging

* convert macros to structured logging

* add struc logging to most of manifest.py

* add struct logging to models.py

* added struct logging to partial.py

* finished conversion of manifest

* fixing errors

* fixed 1 todo and added another

* fixed bugs from merge
* add struct logging to base.py

* struct logging in run_operation

* add struct logging to base

* add struct logging to clean

* add struct logging to debug

* add struct logging to deps

* fix errors

* add struct logging to run.py

* fixed flake error

* add struct logging to geneerate

* added debug level stack trace

* fixed flake error

* added struct logging to compile

* added struct logging to freshness

* cleaned up errors

* resolved bug that broke everything

* removed accidental import

* fixed bug with unused args
scrub secrets in event module
* add struct logging to docs serve

* remove merge fluff

* struct logging to seed command

* converting print to use structured logging

* more structured logging print conversion

* pulling apart formatting more

* added struct logging by disecting printer.py

* add struct logging to runnable

* add struct logging to task init

* fixed formatting

* more formatting and moving things around
* add struct logging to base

* add struct logging to git

* add struct logging to deps

* remove blank line

* fixed stray merge error
* add struct logging to compilation

* add struct logging to tracking

* add struct logging to utils

* add struct logging to exceptions

* fixed some misc errors

* updated to send raw ex, removed resulting circ dep
* added struct logging to base

* fixed merge wierdness

* convert to use single type for integration tests

* converted to 3 reusable test types in sep module

* tweak message

* clean up and making test_types complete for future

* fix missed import
* switches on debug level to guard against expensive messages

* adds memoization to msg construction
- removed 3 new log call sites and replaced with structured logs
- removed 2 unused struc logs
emmyoop and others added 7 commits November 9, 2021 11:26
@nathaniel-may nathaniel-may force-pushed the feature/structured-logging branch from 3684a5f to 31acb95 Compare November 9, 2021 16:40
@nathaniel-may nathaniel-may marked this pull request as ready for review November 9, 2021 16:42
@nathaniel-may nathaniel-may mentioned this pull request Nov 9, 2021
26 tasks
* apply test fixes

* remove presto test
* Env var shim to reenable logbook

* Rename to ENABLE_LEGACY_LOGGER
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

One failing test, test_postgres_debug_with_profiles_separate_from_project_dir, that only fails on Windows. It's definitely related to changes here, but I don't think it's worth holding off on this PR any longer. @nathaniel-may and I have a hunch that it's more likely a symptom of our testing scaffold than it is representative of an actual issue in dbt-core.

Let's open a new issue to investigate further, and add to the phase 2 to-do list. In the meantime, let's move ahead with this change.

Amazing work @nathaniel-may @iknox-fa @emmyoop, and to everyone who helped along the way :)

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

Successfully merging this pull request may close these issues.

Stabilize structured logging
5 participants