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

delete MetricContext, populate sentry tags from LogContext #818

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Conversation

matt-codecov
Copy link
Contributor

@matt-codecov matt-codecov commented Oct 24, 2024

  • deletes MetricContext, cleans up usage of SQL metrics
    • this should also eliminate some metric_context.populate() db queries although there were not many
  • adds LogContext fields to sentry tags
  • makes LogContext the decider of how its fields are added to log records and sentry tags
  • cleans up the redundant task_id and task_name log fields

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #818   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files         442      442           
  Lines       36163    36113   -50     
=======================================
- Hits        35448    35402   -46     
+ Misses        715      711    -4     
Flag Coverage Δ
integration 98.03% <100.00%> (+<0.01%) ⬆️
unit 98.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 95.92% <100.00%> (+0.01%) ⬆️
OutsideTasks 98.02% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
conftest.py 94.73% <ø> (-0.27%) ⬇️
helpers/log_context.py 98.75% <100.00%> (+0.13%) ⬆️
helpers/logging_config.py 81.39% <100.00%> (-0.83%) ⬇️
helpers/telemetry.py 100.00% <100.00%> (+8.95%) ⬆️
helpers/tests/unit/test_log_context.py 100.00% <100.00%> (ø)
helpers/tests/unit/test_logging_config.py 100.00% <ø> (ø)
helpers/tests/unit/test_telemetry.py 100.00% <100.00%> (ø)
services/report/__init__.py 97.05% <100.00%> (-0.01%) ⬇️
tasks/base.py 95.80% <100.00%> (-0.10%) ⬇️
tasks/label_analysis.py 99.11% <100.00%> (-0.02%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

@codecov-qa
Copy link

codecov-qa bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (79f57df) to head (abce040).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #818   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files         442      442           
  Lines       36163    36113   -50     
=======================================
- Hits        35448    35402   -46     
+ Misses        715      711    -4     
Flag Coverage Δ
integration 98.03% <100.00%> (+<0.01%) ⬆️
unit 98.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 95.92% <100.00%> (+0.01%) ⬆️
OutsideTasks 98.02% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
conftest.py 94.73% <ø> (-0.27%) ⬇️
helpers/log_context.py 98.75% <100.00%> (+0.13%) ⬆️
helpers/logging_config.py 81.39% <100.00%> (-0.83%) ⬇️
helpers/telemetry.py 100.00% <100.00%> (+8.95%) ⬆️
helpers/tests/unit/test_log_context.py 100.00% <100.00%> (ø)
helpers/tests/unit/test_logging_config.py 100.00% <ø> (ø)
helpers/tests/unit/test_telemetry.py 100.00% <100.00%> (ø)
services/report/__init__.py 97.05% <100.00%> (-0.01%) ⬇️
tasks/base.py 95.80% <100.00%> (-0.10%) ⬇️
tasks/label_analysis.py 99.11% <100.00%> (-0.02%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (79f57df) to head (abce040).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #818   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files         442      442           
  Lines       36163    36113   -50     
=======================================
- Hits        35448    35402   -46     
+ Misses        715      711    -4     
Flag Coverage Δ
integration 98.03% <100.00%> (+<0.01%) ⬆️
unit 98.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 95.92% <100.00%> (+0.01%) ⬆️
OutsideTasks 98.02% <100.00%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
conftest.py 94.73% <ø> (-0.27%) ⬇️
helpers/log_context.py 98.75% <100.00%> (+0.13%) ⬆️
helpers/logging_config.py 81.39% <100.00%> (-0.83%) ⬇️
helpers/telemetry.py 100.00% <100.00%> (+8.95%) ⬆️
helpers/tests/unit/test_log_context.py 100.00% <100.00%> (ø)
helpers/tests/unit/test_logging_config.py 100.00% <ø> (ø)
helpers/tests/unit/test_telemetry.py 100.00% <100.00%> (ø)
services/report/__init__.py 97.05% <100.00%> (-0.01%) ⬇️
tasks/base.py 95.80% <100.00%> (-0.10%) ⬇️
tasks/label_analysis.py 99.11% <100.00%> (-0.02%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

Copy link

codecov-public-qa bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (79f57df) to head (abce040).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #818   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files         442      442           
  Lines       36163    36113   -50     
=======================================
- Hits        35448    35402   -46     
+ Misses        715      711    -4     
Flag Coverage Δ
integration 98.03% <100.00%> (+<0.01%) ⬆️
unit 98.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
NonTestCode 95.92% <100.00%> (+0.01%) ⬆️
OutsideTasks 98.02% <100.00%> (+0.02%) ⬆️
Files Coverage Δ
conftest.py 94.73% <ø> (-0.27%) ⬇️
helpers/log_context.py 98.75% <100.00%> (+0.13%) ⬆️
helpers/logging_config.py 81.39% <100.00%> (-0.83%) ⬇️
helpers/telemetry.py 100.00% <100.00%> (+8.95%) ⬆️
helpers/tests/unit/test_log_context.py 100.00% <100.00%> (ø)
helpers/tests/unit/test_logging_config.py 100.00% <ø> (ø)
helpers/tests/unit/test_telemetry.py 100.00% <100.00%> (ø)
services/report/__init__.py 97.05% <100.00%> (-0.01%) ⬇️
tasks/base.py 95.80% <100.00%> (-0.10%) ⬇️
tasks/label_analysis.py 99.11% <100.00%> (-0.02%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

@matt-codecov matt-codecov requested a review from a team October 24, 2024 18:23
def add_to_sentry(self):
d = self.as_dict()
d.pop("sentry_trace_id", None)
sentry_sdk.set_tags(d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, I see set_tags as a Scope API, but not as part of the top level APIs.

Maybe this is just an oversight in the docs? CC @antonpirker

Comment on lines +67 to 68
`log_simple_metric()`, meaning it will throw logging on the
asyncio queue and then immediately return without needing to be awaited. Can
Copy link
Contributor

Choose a reason for hiding this comment

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

as this is now using a ContextVar, is that guaranteed to be more consistent than a global which might change underneath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

y'know, good question. i think so; as i understand it the context will inherit a clone of the parent context so the parent context is free to change

@matt-codecov matt-codecov added this pull request to the merge queue Oct 28, 2024
Merged via the queue into main with commit f06e233 Oct 28, 2024
26 of 27 checks passed
@matt-codecov matt-codecov deleted the pr818 branch October 28, 2024 17:08
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.

2 participants