Skip to content

Pr#83 branch2 GLM-4.6#2

Open
Konuralpkilinc wants to merge 2 commits intotargetfrom
PR#83-branch2
Open

Pr#83 branch2 GLM-4.6#2
Konuralpkilinc wants to merge 2 commits intotargetfrom
PR#83-branch2

Conversation

@Konuralpkilinc
Copy link
Copy Markdown

Add support for returnedObj expression in apm-customize-enhance-plugin

This PR adds support for using returnedObj expression in the customize enhance plugin to access method return values in tags and logs. The plugin has also been updated to use the V2 API.

Files Changed:

  • CHANGES.md

    • Added release note for the new returnedObj expression support
  • apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/CustomizeExpressionTest.java

    • Moved test class to core util package for better organization
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java

    • Updated to use V2 API (ClassInstanceMethodsEnhancePluginDefineV2)
    • Changed intercept point type to InstanceMethodsInterceptV2Point
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java

    • Updated to use V2 API (ClassStaticMethodsEnhancePluginDefineV2)
    • Changed intercept point type to StaticMethodsInterceptV2Point
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java

    • Added support for returnedObj expression evaluation
    • Implemented span data holder for managing span lifecycle
    • Added methods to evaluate and populate return value expressions
    • Updated to work with MethodInvocationContext from V2 API
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java

    • Updated to implement InstanceMethodsAroundInterceptorV2
    • Added MethodInvocationContext parameter support
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java

    • Updated to implement StaticMethodsAroundInterceptorV2
    • Added MethodInvocationContext parameter support
  • docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md

    • Added documentation for returnedObj expression usage
    • Included examples showing how to use return values in tags and logs
  • test/plugin/scenarios/customize-scenario/config/customize_enhance.xml

    • Added test configurations for returnedObj expression scenarios
  • test/plugin/scenarios/customize-scenario/config/expectedData.yaml

    • Added expected test results for the new returnedObj expression tests
  • test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java

    • Added test method calls to verify returnedObj expression functionality
  • test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/service/TestService1.java

    • Added test methods that return values for testing returnedObj expression

deeployed-peer-dev[bot]

This comment was marked as outdated.

@Konuralpkilinc Konuralpkilinc changed the title Pr#83 branch2 Pr#83 branch2 GLM-4.6 Oct 28, 2025
@Deeployed-Peer Deeployed-Peer deleted a comment from deeployed-peer-dev bot Oct 29, 2025
@Deeployed-Peer Deeployed-Peer deleted a comment from deeployed-peer-dev bot Oct 29, 2025
@Deeployed-Peer Deeployed-Peer deleted a comment from deeployed-peer-dev bot Oct 29, 2025
@Deeployed-Peer Deeployed-Peer deleted a comment from deeployed-peer-dev bot Oct 29, 2025
@Konuralpkilinc
Copy link
Copy Markdown
Author

@deeployed-peer-dev review

@deeployed-peer-dev
Copy link
Copy Markdown

deeployed-peer-dev bot commented Oct 29, 2025

Walkthrough This PR updates the customize-enhance-plugin to support `returnedObj` expressions for accessing method return values in tags/logs and migrates to the V2 API. It also adds comprehensive test coverage for the new functionality.
Changes
File Summary
Customize Instrumentation & Interceptors Migrated to V2 API: CustomizeInstanceInstrumentation and CustomizeStaticInstrumentation now extend V2 plugin defines and implement V2 intercept points. CustomizeInstanceInterceptor and CustomizeStaticInterceptor implement V2 interfaces with updated method signatures including MethodInvocationContext.
BaseInterceptorMethods Enhanced with SpanDataHolder for span lifecycle management, updated method signatures for MethodInvocationContext, and added evalReturnAndPopulate method for handling return value expressions.
Test Implementation & Configuration Added CustomizeExpressionTest and new test methods (retString, retModel0) in TestService1. Updated CustomizeController to exercise new functionality. Added test configurations in customize_enhance.xml and expected data in expectedData.yaml for return value expressions in tags and logs.
Test Infrastructure Updated startup.sh to support new test scenarios. Test cases validate return value expressions ('str0' for string return, '100' for model return).
Sequence Diagram ```mermaid sequenceDiagram participant Client participant CustomizeController participant TestService1 participant CustomizeInstanceInterceptor participant BaseInterceptorMethods participant SpanDataHolder participant SkyWalkingCore
Client->>CustomizeController: HTTP Request (/retString or /retModel0)
CustomizeController->>TestService1: call method (retString/retModel0)

Note over TestService1: Method intercepted by CustomizeInstanceInterceptor
TestService1->>CustomizeInstanceInterceptor: beforeMethod(context)
CustomizeInstanceInterceptor->>BaseInterceptorMethods: beforeMethod(context, holder)
BaseInterceptorMethods->>SpanDataHolder: create/start span
SpanDataHolder-->>BaseInterceptorMethods: span
BaseInterceptorMethods-->>CustomizeInstanceInterceptor: span context
CustomizeInstanceInterceptor-->>TestService1: proceed with method execution

TestService1-->>CustomizeInstanceInterceptor: return value
CustomizeInstanceInterceptor->>CustomizeInstanceInterceptor: afterMethod(context, result)
CustomizeInstanceInterceptor->>BaseInterceptorMethods: afterMethod(context, result, holder)
BaseInterceptorMethods->>BaseInterceptorMethods: evalReturnAndPopulate(result, expressions)
BaseInterceptorMethods->>SpanDataHolder: add tags/logs with return value
SpanDataHolder->>SkyWalkingCore: report span data
SpanDataHolder-->>BaseInterceptorMethods: span completed
BaseInterceptorMethods-->>CustomizeInstanceInterceptor: processing complete
CustomizeInstanceInterceptor-->>TestService1: return result

TestService1-->>CustomizeController: method result
CustomizeController-->>Client: HTTP Response
</details>
<!-- This is an auto-generated comment: raw summary by Deeployed - Reviewed -->
<!--


apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java:
This PR updates the customize-enhance-plugin to support `returnedObj` expressions for accessing method return values in tags/logs and migrates to the V2 API. Key changes include:

- **Instrumentation Updates**: 
  - `CustomizeInstanceInstrumentation` now extends `ClassInstanceMethodsEnhancePluginDefineV2` and implements `getInstanceMethodsInterceptV2Points()`
  - `CustomizeStaticInstrumentation` now extends `ClassStaticMethodsEnhancePluginDefineV2` and implements `getStaticMethodsInterceptV2Points()`
  - Interceptor method names changed from `getMethodsInterceptor()` to `getMethodsInterceptorV2()`

- **Interceptor Updates**: 
  - `CustomizeInstanceInterceptor` now implements `InstanceMethodsAroundInterceptorV2`
  - `CustomizeStaticInterceptor` now implements `StaticMethodsAroundInterceptorV2`
  - Method signatures updated to include `MethodInvocationContext` parameter in `beforeMethod`, `afterMethod`, and `handleMethodException`

- **BaseInterceptorMethods Enhancements**: 
  - Added `SpanDataHolder` inner class to manage span lifecycle
  - Modified `beforeMethod` and `afterMethod` signatures to accept `MethodInvocationContext`
  - Added `evalReturnAndPopulate` for return value expressions and helper methods for span tagging
---
apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/CustomizeExpressionTest.java:
test/plugin/scenarios/customize-scenario/bin/startup.sh:
test/plugin/scenarios/customize-scenario/config/expectedData.yaml:
test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java:
test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/service/TestService1.java:
This PR adds comprehensive test support for the new `returnedObj` expression feature in the customize enhance plugin. Key changes include:

- **Test Implementation**:
  - Added `CustomizeExpressionTest` test class moved to `org.apache.skywalking.apm.agent.core.util`
  - Added `retString` and `retModel0` methods to `TestService1.java` for testing return value expressions
  - Updated `CustomizeController.java` to exercise the new functionality

- **Test Configuration**:
  - Updated `customize_enhance.xml` with configurations for `returnedObj` expressions
  - Added expected data in `expectedData.yaml` with two new span entries (spans 9 and 10) for `/retString` and `/retModel0` operations
  - Spans demonstrate how method return values are captured in both tags (`tag_ret`) and logs (`log_map`)

- **Test Infrastructure**:
  - Updated `startup.sh` to support the new test scenarios
  - Test cases validate return value expressions ('str0' for string return, '100' for model return)
-->
<!-- end of auto-generated comment: raw summary by Deeployed - Reviewed -->
<!-- This is an auto-generated comment: short summary by Deeployed - Reviewed -->
<!--


apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java:
This PR updates the customize-enhance-plugin to support `returnedObj` expressions for accessing method return values in tags/logs and migrates to the V2 API. Key changes include:

- **Instrumentation Updates**: 
  - `CustomizeInstanceInstrumentation` now extends `ClassInstanceMethodsEnhancePluginDefineV2` and implements `getInstanceMethodsInterceptV2Points()`
  - `CustomizeStaticInstrumentation` now extends `ClassStaticMethodsEnhancePluginDefineV2` and implements `getStaticMethodsInterceptV2Points()`
  - Interceptor method names changed from `getMethodsInterceptor()` to `getMethodsInterceptorV2()`

- **Interceptor Updates**: 
  - `CustomizeInstanceInterceptor` now implements `InstanceMethodsAroundInterceptorV2`
  - `CustomizeStaticInterceptor` now implements `StaticMethodsAroundInterceptorV2`
  - Method signatures updated to include `MethodInvocationContext` parameter in `beforeMethod`, `afterMethod`, and `handleMethodException`

- **BaseInterceptorMethods Enhancements**: 
  - Added `SpanDataHolder` inner class to manage span lifecycle
  - Modified `beforeMethod` and `afterMethod` signatures to accept `MethodInvocationContext`
  - Added `evalReturnAndPopulate` for return value expressions and helper methods for span tagging
---
apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/CustomizeExpressionTest.java:
test/plugin/scenarios/customize-scenario/bin/startup.sh:
test/plugin/scenarios/customize-scenario/config/expectedData.yaml:
test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java:
test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/service/TestService1.java:
This PR adds comprehensive test support for the new `returnedObj` expression feature in the customize enhance plugin. Key changes include:

- **Test Implementation**:
  - Added `CustomizeExpressionTest` test class moved to `org.apache.skywalking.apm.agent.core.util`
  - Added `retString` and `retModel0` methods to `TestService1.java` for testing return value expressions
  - Updated `CustomizeController.java` to exercise the new functionality

- **Test Configuration**:
  - Updated `customize_enhance.xml` with configurations for `returnedObj` expressions
  - Added expected data in `expectedData.yaml` with two new span entries (spans 9 and 10) for `/retString` and `/retModel0` operations
  - Spans demonstrate how method return values are captured in both tags (`tag_ret`) and logs (`log_map`)

- **Test Infrastructure**:
  - Updated `startup.sh` to support the new test scenarios
  - Test cases validate return value expressions ('str0' for string return, '100' for model return)
-->
<!-- end of auto-generated comment: short summary by Deeployed - Reviewed -->
<!-- This is an auto-generated comment: impact context by Deeployed - Reviewed -->
<!--
{"version":1,"files":[{"filename":"CHANGES.md","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/CustomizeExpressionTest.java","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java","symbolChanges":[{"id":"bafac44e-215c-455f-883f-668f6afbc743","symbol":"getInstanceMethodsInterceptV2Points","previousSymbol":"getInstanceMethodsInterceptPoints","kind":"method","changeType":"renamed","beforeSignature":"()","afterSignature":"()","notes":"Renamed from getInstanceMethodsInterceptPoints; no dependent updates detected in PR","summary":null,"bodyChanged":false},{"id":"60fc68a4-a9ef-431e-b936-b61ced3cad67","symbol":"getMethodsInterceptorV2","previousSymbol":"getMethodsInterceptor","kind":"method","changeType":"renamed","beforeSignature":"()","afterSignature":"()","notes":"Renamed from getMethodsInterceptor","summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"getMethodsInterceptorV2","symbolChangeId":"60fc68a4-a9ef-431e-b936-b61ced3cad67"}],"referenceSummaries":[]},{"filename":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java","symbolChanges":[{"id":"57a8675d-9b3f-4ddd-9121-d0c81fa123f9","symbol":"getStaticMethodsInterceptV2Points","previousSymbol":"getStaticMethodsInterceptPoints","kind":"method","changeType":"renamed","beforeSignature":"()","afterSignature":"()","notes":"Renamed from getStaticMethodsInterceptPoints; no dependent updates detected in PR","summary":null,"bodyChanged":false},{"id":"ffe36447-98ff-4fc5-9901-3b413d4a7933","symbol":"getMethodsInterceptorV2","previousSymbol":"getMethodsInterceptor","kind":"method","changeType":"renamed","beforeSignature":"()","afterSignature":"()","notes":"Renamed from getMethodsInterceptor","summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"getMethodsInterceptorV2","symbolChangeId":"ffe36447-98ff-4fc5-9901-3b413d4a7933"}],"referenceSummaries":[]},{"filename":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","symbolChanges":[{"id":"167b7529-65fb-48c0-8f08-9e0808365034","symbol":"afterMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(Method method)","afterSignature":"(Method method, Object ret, MethodInvocationContext miContext)","notes":null,"summary":null,"bodyChanged":false},{"id":"fff66078-e77a-49db-8a46-a23d6eca8950","symbol":"beforeMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(Method method, Object[] allArguments)","afterSignature":"(Method method, Object[] allArguments, MethodInvocationContext miContext)","notes":null,"summary":null,"bodyChanged":false},{"id":"fd711376-326a-410e-aac9-64dde2cf12c0","symbol":"isReturnedObjExpression","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(String expression)","notes":null,"summary":null,"bodyChanged":false},{"id":"00c197de-c1aa-4c8b-97c7-ed02960099ab","symbol":"tagSpanLogs","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(AbstractSpan span, Map<String, String> spanLogs)","notes":null,"summary":null,"bodyChanged":false},{"id":"a70e9928-94b0-4b33-b391-9b2f5cedd5a7","symbol":"tagSpanTags","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(AbstractSpan span, Map<String, String> spanTags)","notes":null,"summary":null,"bodyChanged":false},{"id":"3b11b5f3-a097-45e5-9062-8bd451eac5f6","symbol":"evalReturnAndPopulate","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(Map<String, Object> context, Map<String, String> exprMap,\n        Map<String, String> toMap)","notes":null,"summary":null,"bodyChanged":false},{"id":"9406ddb9-8090-44d4-99a1-d94e4f0a3da3","symbol":"evalAndPopulate","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(Map<String, Object> context, Map<String, String> exprMap, Map<String, String> toMap)","notes":null,"summary":null,"bodyChanged":false},{"id":"8bc0ad3b-d023-4c8f-8931-356e7e755f7b","symbol":"SpanDataHolder","previousSymbol":null,"kind":"class","changeType":"added","beforeSignature":null,"afterSignature":"class_declaration","notes":null,"summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"167b7529-65fb-48c0-8f08-9e0808365034"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"167b7529-65fb-48c0-8f08-9e0808365034"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"fff66078-e77a-49db-8a46-a23d6eca8950"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"fff66078-e77a-49db-8a46-a23d6eca8950"}],"referenceSummaries":[]},{"filename":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java","symbolChanges":[{"id":"41f2c92a-5fe1-47ef-a322-7126e388ed50","symbol":"handleMethodException","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments,\n        Class<?>[] argumentsTypes, Throwable t)","afterSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments,\n        Class<?>[] argumentsTypes, Throwable t, MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false},{"id":"15b9ac5f-42d5-49e4-9514-0c3eb82a65a2","symbol":"afterMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,\n        Object ret)","afterSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,\n        Object ret, MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false},{"id":"b9b796a7-4c49-4ee7-8951-8b1d8ca17e50","symbol":"beforeMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,\n        MethodInterceptResult result)","afterSignature":"(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,\n        MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"handleMethodException","symbolChangeId":"41f2c92a-5fe1-47ef-a322-7126e388ed50"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"15b9ac5f-42d5-49e4-9514-0c3eb82a65a2"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"15b9ac5f-42d5-49e4-9514-0c3eb82a65a2"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"b9b796a7-4c49-4ee7-8951-8b1d8ca17e50"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"b9b796a7-4c49-4ee7-8951-8b1d8ca17e50"}],"referenceSummaries":[]},{"filename":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java","symbolChanges":[{"id":"0e8a43c4-8632-46da-9494-bcf4e9c7db39","symbol":"handleMethodException","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        Throwable t)","afterSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        Throwable t, MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false},{"id":"b0f73b8c-73e0-4199-a23c-bdd618e2fc66","symbol":"afterMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        Object ret)","afterSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        Object ret, MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false},{"id":"223d2e88-6eae-4c70-a91d-94ae8dd0507a","symbol":"beforeMethod","previousSymbol":null,"kind":"method","changeType":"modified","beforeSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        MethodInterceptResult result)","afterSignature":"(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,\n        MethodInvocationContext context)","notes":null,"summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"handleMethodException","symbolChangeId":"0e8a43c4-8632-46da-9494-bcf4e9c7db39"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"b0f73b8c-73e0-4199-a23c-bdd618e2fc66"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"afterMethod","symbolChangeId":"b0f73b8c-73e0-4199-a23c-bdd618e2fc66"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"223d2e88-6eae-4c70-a91d-94ae8dd0507a"},{"path":"apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java","status":"updated_in_pr","reason":"references updated & old references removed","relatedSymbol":"beforeMethod","symbolChangeId":"223d2e88-6eae-4c70-a91d-94ae8dd0507a"}],"referenceSummaries":[]},{"filename":"docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"test/plugin/scenarios/customize-scenario/bin/startup.sh","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"test/plugin/scenarios/customize-scenario/config/customize_enhance.xml","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"test/plugin/scenarios/customize-scenario/config/expectedData.yaml","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java","symbolChanges":[],"impactedFiles":[],"referenceSummaries":[]},{"filename":"test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/service/TestService1.java","symbolChanges":[{"id":"2f77af8c-1559-48a1-9ec5-a69901a7880d","symbol":"retModel0","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(Model0 m0)","notes":null,"summary":null,"bodyChanged":false},{"id":"a9b0a6e7-8847-470b-9f90-21a693957f02","symbol":"retString","previousSymbol":null,"kind":"method","changeType":"added","beforeSignature":null,"afterSignature":"(String str0)","notes":null,"summary":null,"bodyChanged":false}],"impactedFiles":[{"path":"docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retModel0","symbolChangeId":"2f77af8c-1559-48a1-9ec5-a69901a7880d"},{"path":"test/plugin/scenarios/customize-scenario/config/customize_enhance.xml","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retModel0","symbolChangeId":"2f77af8c-1559-48a1-9ec5-a69901a7880d"},{"path":"test/plugin/scenarios/customize-scenario/config/expectedData.yaml","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retModel0","symbolChangeId":"2f77af8c-1559-48a1-9ec5-a69901a7880d"},{"path":"test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retModel0","symbolChangeId":"2f77af8c-1559-48a1-9ec5-a69901a7880d"},{"path":"docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retString","symbolChangeId":"a9b0a6e7-8847-470b-9f90-21a693957f02"},{"path":"test/plugin/scenarios/customize-scenario/config/customize_enhance.xml","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retString","symbolChangeId":"a9b0a6e7-8847-470b-9f90-21a693957f02"},{"path":"test/plugin/scenarios/customize-scenario/config/expectedData.yaml","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retString","symbolChangeId":"a9b0a6e7-8847-470b-9f90-21a693957f02"},{"path":"test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java","status":"updated_in_pr","reason":"references updated","relatedSymbol":"retString","symbolChangeId":"a9b0a6e7-8847-470b-9f90-21a693957f02"}],"referenceSummaries":[]}]}
-->
<!-- end of auto-generated comment: impact context by Deeployed - Reviewed -->
---
<summary>Uplevel your code reviews with Deeployed Peer!</summary>


<!-- commit_ids_reviewed_start -->
<!-- 86ff5ed93ee642e8857abc3264142adbfdf65939 -->
<!-- commit_ids_reviewed_end -->
  <!-- This is an auto-generated comment: learnings by Deeployed - Reviewed -->
<!--
  
  -->
<!-- end of auto-generated comment: learnings by Deeployed - Reviewed -->
 
 <!-- This is an auto-generated comment: summarize by Deeployed - Reviewed -->

Copy link
Copy Markdown

@deeployed-peer-dev deeployed-peer-dev bot left a comment

Choose a reason for hiding this comment

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

Commits Files that changed from the base of the PR and between Base and 86ff5ed commits: 13
Files Selected For Review: 10
  • apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/CustomizeExpressionTest.java with diff length 263.
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeInstanceInstrumentation.java with diff length 2438.
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/define/CustomizeStaticInstrumentation.java with diff length 2327.
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java with diff length 9156.
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeInstanceInterceptor.java with diff length 2007.
  • apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/CustomizeStaticInterceptor.java with diff length 1683.
  • test/plugin/scenarios/customize-scenario/bin/startup.sh with diff length 256.
  • test/plugin/scenarios/customize-scenario/config/expectedData.yaml with diff length 852.
  • test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/controller/CustomizeController.java with diff length 237.
  • test/plugin/scenarios/customize-scenario/src/main/java/test/apache/skywalking/apm/testcase/customize/service/TestService1.java with diff length 282.
Files excluded from review due to unsupported file extensions: 3
  • CHANGES.md
  • docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md
  • test/plugin/scenarios/customize-scenario/config/customize_enhance.xml
Review comments generated: (28)
  • Review: 5
  • LGTM: 23
  • Identified issue already discussed: 0

Tips

Chat with Deeployed Bot (@@deeployed-peer-dev)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @@deeployed-peer-dev in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @deeployed-peer-dev: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +137 to +139
void handleMethodException(Throwable t) {
ContextManager.activeSpan().log(t);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the handleMethodException method, there's a potential issue where ContextManager.activeSpan() is called without checking if the context is active first, which could lead to a NullPointerException if no span is active.

Suggested change
void handleMethodException(Throwable t) {
ContextManager.activeSpan().log(t);
}
void handleMethodException(Throwable t) {
if (ContextManager.isActive()) {
ContextManager.activeSpan().log(t);
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

BP

import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.InstanceMethodsAroundInterceptorV2;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2.MethodInvocationContext;

public class CustomizeInstanceInterceptor extends BaseInterceptorMethods implements InstanceMethodsAroundInterceptorV2 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The class now implements InstanceMethodsAroundInterceptorV2 instead of InstanceMethodsAroundInterceptor, which is consistent with the migration to the V2 API mentioned in the PR description.

Comment on lines 29 to 32
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
super.beforeMethod(method, allArguments);
MethodInvocationContext context) throws Throwable {
super.beforeMethod(method, allArguments, context);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The beforeMethod signature has been updated to include MethodInvocationContext parameter and the call to super.beforeMethod now passes this context instead of the previous parameters.

Comment on lines 35 to 39
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
super.afterMethod(method);
Object ret, MethodInvocationContext context) throws Throwable {
super.afterMethod(method, ret, context);
return ret;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The afterMethod signature has been updated to include MethodInvocationContext parameter and the call to super.afterMethod now passes the return value and context, which is necessary for the new returnedObj expression support.

Comment on lines 42 to 45
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
Class<?>[] argumentsTypes, Throwable t, MethodInvocationContext context) {
super.handleMethodException(t);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The handleMethodException signature has been updated to include MethodInvocationContext parameter, consistent with the V2 API migration.

@Konuralpkilinc
Copy link
Copy Markdown
Author

GLM-4.6
1 BP
4 FN

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