-
Notifications
You must be signed in to change notification settings - Fork 9
Cdp use fixes #184
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
Cdp use fixes #184
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c7cf942
wip (attempt 0): don't enable rrweb if zone detected
dinmukhamedm fcb5a11
wip (attempt 1): isolated world
dinmukhamedm db44831
wip: isolated context continued
dinmukhamedm 2cd0a30
fix full snapshots, by not storing URL in key
dinmukhamedm 08eb9bf
bubus instrumentation to keep spans hierarchy correct
dinmukhamedm f636527
add about:blank, expose disabled_instruments in evaluate
dinmukhamedm 304506a
further safety and bump version
dinmukhamedm 9d95cef
also commit bumped pyproject.toml
dinmukhamedm ec9e390
further context id checks, Laminar.use_span
dinmukhamedm 5fec2b8
Update src/lmnr/sdk/evaluations.py
dinmukhamedm 1fdc895
return True from should skip in case of errors
dinmukhamedm 39f8795
Update src/lmnr/sdk/browser/cdp_utils.py
dinmukhamedm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| from typing import Collection | ||
|
|
||
| from lmnr import Laminar | ||
| from lmnr.opentelemetry_lib.tracing.context import get_current_context | ||
| from lmnr.sdk.log import get_default_logger | ||
|
|
||
| from opentelemetry.instrumentation.instrumentor import BaseInstrumentor | ||
| from opentelemetry.instrumentation.utils import unwrap | ||
| from opentelemetry.trace import NonRecordingSpan, get_current_span | ||
| from wrapt import wrap_function_wrapper | ||
|
|
||
|
|
||
| _instruments = ("bubus >= 1.3.0",) | ||
| event_id_to_span_context = {} | ||
| logger = get_default_logger(__name__) | ||
|
|
||
|
|
||
| def wrap_dispatch(wrapped, instance, args, kwargs): | ||
| event = args[0] if args and len(args) > 0 else kwargs.get("event", None) | ||
| if event and hasattr(event, "event_id"): | ||
| event_id = event.event_id | ||
| if event_id: | ||
| span = get_current_span(get_current_context()) | ||
| event_id_to_span_context[event_id] = span.get_span_context() | ||
| return wrapped(*args, **kwargs) | ||
|
|
||
|
|
||
| async def wrap_process_event(wrapped, instance, args, kwargs): | ||
| event = args[0] if args and len(args) > 0 else kwargs.get("event", None) | ||
| span_context = None | ||
| if event and hasattr(event, "event_id"): | ||
| event_id = event.event_id | ||
| if event_id: | ||
| span_context = event_id_to_span_context.get(event_id) | ||
| if not span_context: | ||
| return await wrapped(*args, **kwargs) | ||
| if not Laminar.is_initialized(): | ||
| return await wrapped(*args, **kwargs) | ||
| with Laminar.use_span(NonRecordingSpan(span_context)): | ||
| return await wrapped(*args, **kwargs) | ||
|
|
||
|
|
||
| class BubusInstrumentor(BaseInstrumentor): | ||
| def __init__(self): | ||
| super().__init__() | ||
|
|
||
| def instrumentation_dependencies(self) -> Collection[str]: | ||
| return _instruments | ||
|
|
||
| def _instrument(self, **kwargs): | ||
| try: | ||
| wrap_function_wrapper("bubus.service", "EventBus.dispatch", wrap_dispatch) | ||
| except (ModuleNotFoundError, ImportError): | ||
| pass | ||
| try: | ||
| wrap_function_wrapper( | ||
| "bubus.service", "EventBus.process_event", wrap_process_event | ||
| ) | ||
| except (ModuleNotFoundError, ImportError): | ||
| pass | ||
|
|
||
| def _uninstrument(self, **kwargs): | ||
| try: | ||
| unwrap("bubus.service", "EventBus.dispatch") | ||
| except (ModuleNotFoundError, ImportError): | ||
| pass | ||
| try: | ||
| unwrap("bubus.service", "EventBus.process_event") | ||
| except (ModuleNotFoundError, ImportError): | ||
| pass | ||
| event_id_to_span_context.clear() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.