-
Notifications
You must be signed in to change notification settings - Fork 303
refactor: Resolve JSCPD errors #27
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
Closed
Closed
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8128e62
fix: JSCPD errors
holtskinner a2e070d
fix copy/paste errors in src/a2a/client
holtskinner 5b5851d
Set threshold to 0
holtskinner 7765856
Formatting
holtskinner 10a7b72
Merge branch 'main' into jscpd-fixes
holtskinner 0891528
Merge branch 'main' into jscpd-fixes
holtskinner df3ff43
Merge branch 'main' into jscpd-fixes
holtskinner e0b5d12
Merge branch 'main' into jscpd-fixes
holtskinner 5c67216
Merge branch 'main' into jscpd-fixes
holtskinner fea9162
Merge branch 'main' into jscpd-fixes
holtskinner 0033b82
Reset client changes
holtskinner 4696fd3
Merge branch 'main' into jscpd-fixes
holtskinner 39c4e72
Undo telemetry changes
holtskinner ff8c0e9
Merge branch 'jscpd-fixes' of https://github.com/google-a2a/a2a-pytho…
holtskinner 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "ignore": ["**/.github/**", "**/.git/**", "**/tests/**", "**/examples/**"], | ||
| "threshold": 3, | ||
| "threshold": 0, | ||
| "reporters": ["html", "markdown"] | ||
| } |
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 |
|---|---|---|
|
|
@@ -138,10 +138,7 @@ def trace_function( | |
| f'Start tracing for {actual_span_name}, is_async_func {is_async_func}' | ||
| ) | ||
|
|
||
| @functools.wraps(func) | ||
| async def async_wrapper(*args, **kwargs) -> any: | ||
| """Async Wrapper for the decorator.""" | ||
| logger.debug('Start async tracer') | ||
| async def _invoke_with_tracing(*args, **kwargs): | ||
| tracer = trace.get_tracer( | ||
| INSTRUMENTING_MODULE_NAME, INSTRUMENTING_MODULE_VERSION | ||
| ) | ||
|
|
@@ -155,7 +152,11 @@ async def async_wrapper(*args, **kwargs) -> any: | |
|
|
||
| try: | ||
| # Async wrapper, await for the function call to complete. | ||
| result = await func(*args, **kwargs) | ||
| if is_async_func: | ||
| result = await func(*args, **kwargs) | ||
| # Sync wrapper, execute the function call. | ||
| else: | ||
| result = func(*args, **kwargs) | ||
| span.set_status(StatusCode.OK) | ||
| return result | ||
|
|
||
|
|
@@ -175,39 +176,22 @@ async def async_wrapper(*args, **kwargs) -> any: | |
| f'attribute_extractor error in span {actual_span_name}: {attr_e}' | ||
| ) | ||
|
|
||
| @functools.wraps(func) | ||
| async def async_wrapper(*args, **kwargs): | ||
| """Async Wrapper for the decorator.""" | ||
| logger.debug('Start async tracer') | ||
| return await _invoke_with_tracing( | ||
| *args, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| @functools.wraps(func) | ||
| def sync_wrapper(*args, **kwargs): | ||
| """Sync Wrapper for the decorator.""" | ||
| tracer = trace.get_tracer(INSTRUMENTING_MODULE_NAME) | ||
| with tracer.start_as_current_span(actual_span_name, kind=kind) as span: | ||
| if attributes: | ||
| for k, v in attributes.items(): | ||
| span.set_attribute(k, v) | ||
|
|
||
| result = None | ||
| exception = None | ||
|
|
||
| try: | ||
| # Sync wrapper, execute the function call. | ||
| result = func(*args, **kwargs) | ||
| span.set_status(StatusCode.OK) | ||
| return result | ||
|
|
||
| except Exception as e: | ||
| exception = e | ||
| span.record_exception(e) | ||
| span.set_status(StatusCode.ERROR, description=str(e)) | ||
| raise | ||
| finally: | ||
| if attribute_extractor: | ||
| try: | ||
| attribute_extractor( | ||
| span, args, kwargs, result, exception | ||
| ) | ||
| except Exception as attr_e: | ||
| logger.error( | ||
| f'attribute_extractor error in span {actual_span_name}: {attr_e}' | ||
| ) | ||
| return _invoke_with_tracing( | ||
| *args, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| return async_wrapper if is_async_func else sync_wrapper | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what is the need for two wrappers now, since they internally call the same function. Maybe directly return the _invoke_with_tracing. @rajeshvelicheti could you confirm. |
||
|
|
||
|
|
||
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.