Skip to content

Rewrite plugin using new API#87

Merged
wu-sheng merged 12 commits into
apache:feature/3.0from
ascrutae:feature/3.0
Feb 25, 2017
Merged

Rewrite plugin using new API#87
wu-sheng merged 12 commits into
apache:feature/3.0from
ascrutae:feature/3.0

Conversation

@ascrutae

Copy link
Copy Markdown
Member

No description provided.

@ascrutae ascrutae changed the title rewrite plugin using new API Rewrite plugin using new API Feb 21, 2017
*/
private static String generateOperationName(Invoker<?> invoker, Invocation invocation) {
StringBuilder operationName = new StringBuilder();
operationName.append(invoker.getUrl().getPath());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Multi invocations about invoker.getUrl(), it may be a performance leak.

StringBuilder requestURL = new StringBuilder();
requestURL.append(invoker.getUrl().getProtocol() + "://");
requestURL.append(invoker.getUrl().getHost());
requestURL.append(":" + invoker.getUrl().getPort() + "/");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Three invoker.getUrl() invocations. same as above.

import javax.servlet.http.HttpServletResponse;

/**
* {@link TomcatInterceptor} fetch the serialized context data by use {@link HttpServletRequest#getHeader(String)}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Type, by using

HttpServletResponse response = (HttpServletResponse) interceptorContext.allArguments()[1];

Span span = ContextManager.INSTANCE.activeSpan();
Tags.STATUS_CODE.set(span, response.getStatus());

@wu-sheng wu-sheng Feb 21, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Miss Tags.ERROR.set, which based on response.status, 200 = false, otherwise true.

if (url != null) {
com.weibo.api.motan.rpc.Request request = (com.weibo.api.motan.rpc.Request) interceptorContext.allArguments()[0];
Span span = ContextManager.INSTANCE.createSpan(generateViewPoint(url, request));
Tags.COMPONENT.set(span, "Motan");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't use literal.

private static String generateOperationName(URL serviceURI, Request request) {
StringBuilder viewPoint = new StringBuilder(serviceURI.getPath());
viewPoint.append("." + request.getMethodName());
viewPoint.append("(" + request.getParamtersDesc() + ")");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why mix StringBuilder and + ?

Tags.SPAN_LAYER.asDB(span);
if (interceptorContext.allArguments().length > 0
&& interceptorContext.allArguments()[0] instanceof String) {
span.setTag("operation_key", (String) interceptorContext.allArguments()[0]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use this tag?

@wu-sheng wu-sheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments are not good enough, before merge.

* {@link DubboInterceptor#afterMethod(EnhancedClassInstanceContext, InstanceMethodInvokeContext, Object)} be executed after
* {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}, and it will check {@link Result#getException()} if is null.
* current active span will log the exception and set true to the value of error tag if the {@link Result#getException()} is not null.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Execute after {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(Invoker, Invocation)}, when dubbo instrumentation is active.

Check {@link Result#getException()} , if not NULL, log the exception and set tag error=true.

/**
* Active span will log the exception and set current span value of error tag.
*/
private void dealException(Throwable throwable) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Log the throwable, which occurs in Dubbo RPC service.


/**
* Generate operation name.
* the operation name should be like this <code>com.a.eye.skywalking.plugin.test.Test.test(String)</code>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Format operation name. e.g. com.a.eye.skywalking.plugin.test.Test.test(String)

*
* @return operation name.
*/
private static String generateOperationName(URL requestURL, Invocation invocation) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why static method?

/**
* Set the serialized context data to the first request param that extend {@link SWBaseBean} of dubbo service.
*
* @param contextDataStr serialized context data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@param contextDataStr {@link ContextCarrier.serialize()}

*/
private static final String ENHANCE_CLASS = "redis.clients.jedis.JedisCluster";
/**
* Class that intercept all constructors with arg.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment make no sense. Which methods will be intercepted should be commented on the real class.

private static final String KEY_NAME_OF_REQUEST_URL = "REQUEST_URL";

/**
* The key name that the serialized context data stored in {@link Request#getAttachments()}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The {@link Request#getAttachments()} key. It maps to the serialized {@link ContextCarrier}.

*/
private static final String ATTACHMENT_KEY_OF_CONTEXT_DATA = "contextData";
/**
* Motan component

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment make no sense. It is likely:

The 'componet' tag value of Motan RPC framework.

or

A constant for setting the span component name to indicate that it represents a motan client/server span.

*
* @author zhangxin
*/
public class ProviderInterceptor implements InstanceConstructorInterceptor, InstanceMethodsAroundInterceptor {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should have a naming policy, whether include the component name or not?

<dependency>
<groupId>com.a.eye</groupId>
<artifactId>skywalking-sniffer-mock</artifactId>
<version>3.0-2017</version>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not {project.version}?

@wu-sheng wu-sheng added this to the 3.0-2017 milestone Feb 25, 2017
@wu-sheng wu-sheng self-assigned this Feb 25, 2017

@wu-sheng wu-sheng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments need improve. I will try me best.

@wu-sheng wu-sheng merged commit 09f4081 into apache:feature/3.0 Feb 25, 2017
lu-xiaoshuang pushed a commit to lu-xiaoshuang/skywalking that referenced this pull request Aug 12, 2024
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