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

support reactor #228

Closed
wants to merge 21 commits into from
Closed

support reactor #228

wants to merge 21 commits into from

Conversation

shengxiang205
Copy link

Motivation:

  1. add sofa tracer reactor plugin
  2. add tracer sample with webflux

Modification:

add reactor transaction to keep global sofa tracer span
and keep and restore global sofa tracer span

Result:

Fixes #227

@shengxiang205 shengxiang205 changed the title support webflux support reactor May 29, 2019
@glmapper glmapper requested review from glmapper and ujjboy May 29, 2019 11:54
@glmapper glmapper added the enhancement New feature or request label May 29, 2019
pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated Show resolved Hide resolved

<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-tracer-springmvc-plugin</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

这里感觉不用依赖 springmvc 的插件,部分重复代码冗余一份,既然分开两个插件,就应该相互独立开

Copy link
Author

Choose a reason for hiding this comment

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

复用度很高, 抽取一个sofa-tracer-web-base-plugin ?

tracer-core/pom.xml Outdated Show resolved Hide resolved
tracer-samples/tracer-sample-with-springwebflux/pom.xml Outdated Show resolved Hide resolved
@ConditionalOnMissingBean
static public HookRegisteringBeanDefinitionRegistryPostProcessor hookRegisteringBeanDefinitionRegistryPostProcessor(ConfigurableApplicationContext context) {
return new HookRegisteringBeanDefinitionRegistryPostProcessor(context);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

HookRegisteringBeanDefinitionRegistryPostProcessor 的作用域应该不仅仅是在WebfluxSofaTracerFilterConfiguration 中,应该对于 reactor 组件生效,然后通过例如 com.alipay.sofa.tracer.reactor.enabled 来控制是否启用 reactor 组件的埋点


import com.alipay.common.tracer.core.reactor.SofaTracerReactorSubscriber;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

无用的引入可以移除掉

import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

移除没有用到的引用

import org.springframework.context.ConfigurableApplicationContext;
import reactor.core.CoreSubscriber;
import reactor.core.Fuseable;
import reactor.core.Scannable;
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

import reactor.core.publisher.Hooks;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Operators;
import reactor.util.context.Context;
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

import reactor.core.publisher.Operators;
import reactor.util.context.Context;

import java.util.function.BooleanSupplier;
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Hooks.resetOnEachOperator(SOFA_TRACE_REACTOR_KEY);
}

private final ConfigurableApplicationContext context;
Copy link
Contributor

Choose a reason for hiding this comment

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

context 这里貌似没有什么具体的作用,是否可以考虑移除掉

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.server.WebFilter;
import reactor.core.publisher.Hooks;
Copy link
Contributor

Choose a reason for hiding this comment

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

无用引用

@ujjboy
Copy link
Member

ujjboy commented Jul 3, 2019

Hi, @shengxiang205 can you split this PR into two smaller PR? One is about the feature, and another is about code format.

public class SpringWebfluxJsonStatReporter extends SpringWebfluxStatReporter {

/***
* 输出拼接器
Copy link
Member

Choose a reason for hiding this comment

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

新的代码注释中不要添加中文,建议都以 English 描述

// 这里强制刷一次
appender.flush();
} catch (Throwable t) {
SelfLog.error("统计日志<" + statTracerName + ">输出异常", t);
Copy link
Member

Choose a reason for hiding this comment

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

换为 English 日志输出,还有注释也换为 English 吧。

// 这里强制刷一次
appender.flush();
} catch (Throwable t) {
SelfLog.error("统计日志<" + statTracerName + ">输出异常", t);
Copy link
Member

Choose a reason for hiding this comment

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

English

@@ -29,6 +29,10 @@
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-tracer-springmvc-plugin</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-tracer-webflux-plugin</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

另外,sofa-tracer-webflux-plugin 模块下需要补充一个 readme.md描述对该插件的使用方式,可以参考下其他插件的编写方式哈。 @glmapper 正式发布后,使用文档也记得放到 RELEASE Notes 里面。

Copy link
Contributor

Choose a reason for hiding this comment

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

另外,sofa-tracer-webflux-plugin 模块下需要补充一个 readme.md描述对该插件的使用方式,可以参考下其他插件的编写方式哈。 @glmapper 正式发布后,使用文档也记得放到 RELEASE Notes 里面。

文档部分随着发布报告一起同步,@shengxiang205 可以参考 https://github.com/glmapper/tarcer-test-samples 这个工程将 README 补充下

@@ -43,6 +44,7 @@

/**
* convent sofaTracerSpan model to zipKinSpan model
*
Copy link
Member

Choose a reason for hiding this comment

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

这次怎么这么多代码格式化哈?之前的代码格式化的插件是有什么问题吗?如果有的话,格式化也建议单独一个 PR 哈。

@glmapper
Copy link
Contributor

glmapper commented Jul 4, 2019

@ujjboy @guanchao-yang all requested changes has been solved

@glmapper
Copy link
Contributor

@shengxiang205 本周计划先发布 2.4.1-SNAPSHOT 版本,这个 PR 你看下还是否有修改或者优化

@glmapper
Copy link
Contributor

这个 PR 暂时先关闭,历史问题,暂无驱动

@glmapper glmapper closed this Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants