-
Notifications
You must be signed in to change notification settings - Fork 437
feat(profiling): add serverless scheduler and conditionally use it #3870
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 1.x #3870 +/- ##
==========================================
- Coverage 79.86% 79.06% -0.80%
==========================================
Files 717 719 +2
Lines 56347 56898 +551
==========================================
- Hits 45004 44989 -15
- Misses 11343 11909 +566
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
releasenotes/notes/feat-serverless-scheduler-31a819bc9eb4f332.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused on how this solves the problem. You write:
Based on Julien's feedback in our RFC, I've added a small scheduler which flushes after the periodic function is called 60 times. This ensures that profiles are sampled over the course of 60s of runtime instead of wallclock time.
You're still doing 60 × 1s which is 60s of runtime. It's just that this now sleeps 60 times 1 second, rather than 1 time 60 seconds.
How is that going to solve the "serverless" problem? (if that solves it we should write it in the commit/ PR body)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few changes but LGTM otherwise
ddtrace/profiling/profiler.py
Outdated
_scheduler = attr.ib( | ||
init=False, default=None, type=Union[scheduler.Scheduler, serverless_scheduler.ServerlessScheduler] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_scheduler = attr.ib( | |
init=False, default=None, type=Union[scheduler.Scheduler, serverless_scheduler.ServerlessScheduler] | |
) | |
_scheduler = attr.ib( | |
init=False, default=None, type=scheduler.Scheduler, | |
) |
The serverless scheduler is a subclass so that's ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried this, when combined with the comment to remove the Union at line 225, mypy still fails:
ddtrace/profiling/profiler.py:222: error: Incompatible types in assignment (expression has type "Type[Scheduler]", variable has type "Type[ServerlessScheduler]") [assignment]
Found 1 error in 1 file (checked 404 source files)
Test failed with exit code 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show line 225 when you have this error?
It seems that you are assigning a class rather than instance on L225.
ddtrace/profiling/profiler.py
Outdated
if self._lambda_function_name: | ||
scheduler_class = ( | ||
serverless_scheduler.ServerlessScheduler | ||
) # type: Union[type[scheduler.Scheduler], type[serverless_scheduler.ServerlessScheduler]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need type then here
otherwise typing.Type[serverless_scheduler.ServerlessScheduler]
or typing.Type[sscheduler.Scheduler]
should be what you want I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment, this fails mypy
…f we've acquired 60s of data before flushing
…m base scheduler and override periodic method
… as counting number of profiled seconds
…uce to once every minute. Test changes to match
7611d12
to
e2205ab
Compare
e2205ab
to
e600cbe
Compare
d6c96f1
to
528e325
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few nits
…ing utf-8 encoding explicitly
@Mergifyio backport 1.4 |
✅ Backports have been created
|
…3870) (#4058) Based on Julien's feedback in our RFC, I've added a small scheduler which flushes after the periodic function is called 60 times. This ensures that profiles are sampled over the course of 60s of runtime instead of wallclock time. (cherry picked from commit 83ce6ce) Co-authored-by: AJ Stuyvenberg <[email protected]>
Description
Based on Julien's feedback in our RFC, I've added a small scheduler which flushes after the periodic function is called 60 times. This ensures that profiles are sampled over the course of 60s of runtime instead of wallclock time.
Checklist
feat
andfix
pull requests.Motivation
Design
Testing strategy
Relevant issue(s)
Testing strategy
Reviewer Checklist
changelog/no-changelog
label added.