mirror of
https://github.com/apache/skywalking.git
synced 2026-11-06 10:07:51 +00:00
Page:
1.0 Develop Guide of Plugin
Pages
1.0 Develop Guide of Plugin
2.0 Demo Application Cluster chn
2.0 Demo Application Cluster
2.0 Deploy Cluster chn
2.0 Deploy Cluster
2.0 How to build chn
2.0 How to build
2.0 Quick Start chn
2.0 Quick Start
2.0 Run Server Docker Images chn
2.0 Run Server Docker Images
2.x Documents
2.x Supported components
3.0 Collector TraceSegment in JSON format
3.0 Deploy cluster
3.0 Deploy docker image
3.0 Deploy skywalking agent
3.0 Trace a distributed services chain
3.0 supported list
3.0 部署Collector镜像
3.0 部署collector
3.0 部署探针Agent
3.1 supported list
3.2 Deploy cluster
3.2 Deploy skywalking agent
3.2 supported list
3.2 部署Collector镜像
3.2 部署collector
3.2 部署探针Agent
3.2.1 supported list
3.2.2 Plugin list and how to disable plugin zh
3.2.2 Plugin list and how to disable plugin
3.2.3 Deploy cluster
3.2.3 Deploy collector in standalone mode
3.2.3 Deploy skywalking agent
3.2.3 supported list
3.2.3 单机模式部署Collector
3.2.3 部署Collector
3.2.3 部署collector生产模式
3.2.3 部署探针Agent
3.2.3 集群模式部署Collector
3.2.4 supported list
FAQ_docker pull failure
Home
How to build
How to communicate with the collector?
Memory Usage and GC info
Plugin Development Guide
Quick start chn
Quick start
Sky Walking 2.x Architecture
Skywalking 3 Cross Process Propagation Headers Protocol CN
Skywalking 3 Cross Process Propagation Headers Protocol
Span tags and logging keys sample tables
Test Cases chn
Test Cases
Trace查询有数据,但是没有拓扑图和JVM数据
change project version
sky walking application toolkit chn
sky walking application toolkit log4j 1.x chn
sky walking application toolkit log4j 1.x
sky walking application toolkit log4j 2.x chn
sky walking application toolkit log4j 2.x
sky walking application toolkit logback 1.x chn
sky walking application toolkit logback 1.x
sky walking application toolkit trace chn
sky walking application toolkit trace context chn
sky walking application toolkit trace context
sky walking application toolkit trace
sky walking application toolkit
sky walking config file walkthrough
sky walking doc_Sidebar
sky walking documents zh contents
skywalking opentracing chn
skywalking opentracing
加载探针,Console被GRPC日志刷屏
No results
Table of contents
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
本文档描述插件的开发方法
快速开发一个全新的RPC插件
- 本节将以Dubbo为例,快速开发一个RPC插件。完整源码参考dubbo-plugin工程
- 需要熟悉Dubbo源码,了解dubbo的客户端、服务端调用的主体逻辑。找到客户端和服务端一定会调用的类(客户端服务端可以不一样),并且类的方法参数中,有所需要监控的基本数据,如:RPC的url,RPC的context上下文,返回值,异常等。dubbo我们选用
com.alibaba.dubbo.monitor.support.MonitorFilter,其中包含所需的所有内容 - 定义插件定义类,此类需要扩展自标准底层实现
com.a.eye.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine,以及此子类。由于dubbo的插件,只需要拦截实例方法,则定义为public class DubboPluginDefine extends ClassInstanceMethodsEnhancePluginDefine - 实现抽象方法。定义拦截的类,方法(一个或多个),对应的拦截器类名(一定是字符串返回)。
public class DubboPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
@Override
protected MethodMatcher[] getInstanceMethodsMatchers() {
return new MethodMatcher[]{new SimpleMethodMatcher("invoke")};
}
@Override
protected String getInstanceMethodsInterceptor() {
return "com.a.eye.skywalking.plugin.dubbo.MonitorFilterInterceptor";
}
@Override
protected String enhanceClassName() {
return "com.alibaba.dubbo.monitor.support.MonitorFilter";
}
}
- 定义拦截器。实例方法拦截器,需要实现
InstanceMethodsAroundInterceptor接口。接口需实现如下方法。
public interface InstanceMethodsAroundInterceptor {
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext);
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result);
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext);
}
如果拦截静态方法,需要拦截器实现StaticMethodsAroundInterceptor接口。接口需实现如下方法
public interface StaticMethodsAroundInterceptor {
public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result);
public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret);
public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext);
}
- 实现拦截器逻辑。构建RPCClientInvokeMonitor.beforeInvoke/afterInvoke和RPCServerInvokeMonitor.beforeInvoke/afterInvoke,并利用RPC框架在客户端和服务端间传递上下文ContextData(RPCClientInvokeMonitor.beforeInvoke的返回值)。构建
MonitorFilterInterceptor。请直接参考工程源码
WIKI documents are maintained by @OpenSkywalking