-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
751e796
commit 22c6802
Showing
11 changed files
with
319 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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 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
39 changes: 39 additions & 0 deletions
39
src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java
This file contains 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,39 @@ | ||
package com.alibaba.csp.sentinel.adapter.dubbo; | ||
|
||
|
||
import com.alibaba.csp.sentinel.AsyncEntry; | ||
import com.alibaba.csp.sentinel.Entry; | ||
import com.alibaba.csp.sentinel.Tracer; | ||
import com.alibaba.csp.sentinel.context.ContextUtil; | ||
import org.apache.dubbo.rpc.Filter; | ||
import org.apache.dubbo.rpc.Invocation; | ||
import org.apache.dubbo.rpc.Invoker; | ||
import org.apache.dubbo.rpc.Result; | ||
import org.apache.dubbo.rpc.RpcContext; | ||
|
||
public abstract class BaseSentinelDubboFilter implements Filter { | ||
|
||
@Override | ||
public Result onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) { | ||
//it's unnecessary to trace the business exception | ||
trace(null, invocation); | ||
return appResponse; | ||
} | ||
|
||
|
||
static void trace(Throwable throwable, Invocation invocation) { | ||
Entry interfaceEntry = (Entry) RpcContext.getContext().get(DubboUtils.DUBBO_INTERFACE_ENTRY_KEY); | ||
Entry methodEntry = (Entry) RpcContext.getContext().get(DubboUtils.DUBBO_METHOD_ENTRY_KEY); | ||
if (methodEntry != null) { | ||
Tracer.traceEntry(throwable, methodEntry); | ||
methodEntry.exit(); | ||
} | ||
if (interfaceEntry != null) { | ||
Tracer.traceEntry(throwable, interfaceEntry); | ||
interfaceEntry.exit(); | ||
} | ||
if (!(interfaceEntry instanceof AsyncEntry)) { | ||
ContextUtil.exit(); | ||
} | ||
} | ||
} |
This file contains 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 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 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,3 +1,3 @@ | ||
sentinel.dubbo.provider.filter=com.alibaba.csp.sentinel.adapter.dubbo.SentinelDubboProviderFilter | ||
sentinel.dubbo.consumer.filter=com.alibaba.csp.sentinel.adapter.dubbo.SentinelDubboConsumerFilter | ||
sentinel.dubbo.consumer.filter=com.alibaba.csp.sentinel.adapter.dubbo.BaseSentinelDubboConsumerFilter | ||
dubbo.application.context.name.filter=com.alibaba.csp.sentinel.adapter.dubbo.DubboAppContextFilter |
This file contains 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 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
Oops, something went wrong.