Skip to content

Lazy load samplers to speed up coldstart in a Lambda environment #312

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

Merged
merged 1 commit into from
Aug 25, 2021
Merged
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
4 changes: 2 additions & 2 deletions aws_xray_sdk/core/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from .models.default_dynamic_naming import DefaultDynamicNaming
from .models.dummy_entities import DummySegment, DummySubsegment
from .emitters.udp_emitter import UDPEmitter
from .sampling.sampler import DefaultSampler
from .sampling.local.sampler import LocalSampler
from .streaming.default_streaming import DefaultStreaming
from .context import Context
from .daemon_config import DaemonConfig
Expand Down Expand Up @@ -58,10 +56,12 @@ def __init__(self):
context = check_in_lambda()
if context:
# Special handling when running on AWS Lambda.
from .sampling.local.sampler import LocalSampler
self._context = context
self.streaming_threshold = 0
self._sampler = LocalSampler()
else:
from .sampling.sampler import DefaultSampler
self._context = Context()
self._sampler = DefaultSampler()

Expand Down