Skip to content
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

Param args missing in fireExit of StatisticSlot | StatisticSlot fireExit 参数传递丢失 args #2374

Closed
Tank-zhu opened this issue Sep 15, 2021 · 4 comments · Fixed by #2523 · May be fixed by #2402
Closed

Param args missing in fireExit of StatisticSlot | StatisticSlot fireExit 参数传递丢失 args #2374

Tank-zhu opened this issue Sep 15, 2021 · 4 comments · Fixed by #2523 · May be fixed by #2402
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Milestone

Comments

@Tank-zhu
Copy link

前置

sentinel 版本1.8.1

类名:com.alibaba.csp.sentinel.slots.statistic.StatisticSlot

@Override
    public void exit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) {
        Node node = context.getCurNode();

        if (context.getCurEntry().getBlockError() == null) {
            // Calculate response time (use completeStatTime as the time of completion).
            long completeStatTime = TimeUtil.currentTimeMillis();
            context.getCurEntry().setCompleteTimestamp(completeStatTime);
            long rt = completeStatTime - context.getCurEntry().getCreateTimestamp();

            Throwable error = context.getCurEntry().getError();

            // Record response time and success count.
            recordCompleteFor(node, count, rt, error);
            recordCompleteFor(context.getCurEntry().getOriginNode(), count, rt, error);
            if (resourceWrapper.getEntryType() == EntryType.IN) {
                recordCompleteFor(Constants.ENTRY_NODE, count, rt, error);
            }
        }

        // Handle exit event with registered exit callback handlers.
        Collection<ProcessorSlotExitCallback> exitCallbacks = StatisticSlotCallbackRegistry.getExitCallbacks();
        for (ProcessorSlotExitCallback handler : exitCallbacks) {
            handler.onExit(context, resourceWrapper, count, args);
        }
      // 为何这里不将args传递。。。
        fireExit(context, resourceWrapper, count);
    }

fireExit(context, resourceWrapper, count); args为何不传递给下面的slot呢。。。

@Tank-zhu
Copy link
Author

除了以下两种方式外还有没有办法可以解决这个问题呢。
1、不能去修改源码
2、不能用同包名的方式去覆盖他

@sczyh30
Copy link
Member

sczyh30 commented Sep 15, 2021

I think it's a bug here. Would you like to contribute a PR to fix it?

@sczyh30 sczyh30 added the kind/bug Category issues or prs related to bug. label Sep 15, 2021
@Tank-zhu
Copy link
Author

ok

@sczyh30 sczyh30 changed the title StatisticSlot 参数传递 Param args missing in fireExit of StatisticSlot | StatisticSlot fireExit 参数传递丢失 args Sep 15, 2021
@sczyh30 sczyh30 added this to the 1.8.3 milestone Sep 15, 2021
@Tank-zhu
Copy link
Author

自己定义的slot 需要这个args
临时解决方案:
我将自己的slot 提前到StatisticSlot前执行。
是可以拿到args。
但是不太清楚这会不会造成什么其他问题

GeorgeAnson added a commit to GeorgeAnson/Sentinel that referenced this issue Sep 26, 2021
GeorgeAnson added a commit to GeorgeAnson/Sentinel that referenced this issue Sep 26, 2021
GeorgeAnson added a commit to GeorgeAnson/Sentinel that referenced this issue Sep 26, 2021
@sczyh30 sczyh30 added the good first issue Good for newcomers label Nov 29, 2021
@sczyh30 sczyh30 modified the milestones: 1.8.3, 2.0.0 Dec 31, 2021
@sczyh30 sczyh30 modified the milestones: 2.0.0, 1.8.4 Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Projects
None yet
2 participants