-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/com/alipay/sofa/common/insight/NoopRecorder.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,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.common.insight; | ||
|
||
/** | ||
* @author muqingcai | ||
* @version 2024年4月19日 上午9:54:51 | ||
*/ | ||
public class NoopRecorder implements Recorder { | ||
public static final NoopRecorder INSTANCE = new NoopRecorder(); | ||
|
||
private NoopRecorder() { | ||
} | ||
|
||
@Override | ||
public void start(RecordScene scene, RecordContext context) { | ||
|
||
} | ||
|
||
@Override | ||
public void stop(RecordScene scene, RecordContext context) { | ||
|
||
} | ||
} |
222 changes: 222 additions & 0 deletions
222
src/main/java/com/alipay/sofa/common/insight/RecordContext.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,222 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.common.insight; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* @author muqingcai | ||
* @version 2024年4月19日 上午9:54:59 | ||
*/ | ||
public class RecordContext { | ||
private int requestId; | ||
private String traceId; | ||
private String rpcId; | ||
private String targetServiceUniqueName; | ||
private String methodName; | ||
private String moduleName; | ||
private String beanName; | ||
private Map<String, Object> extraInfo; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public RecordContext() { | ||
this.extraInfo = new ConcurrentHashMap<>(); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param requestId the request id | ||
*/ | ||
public RecordContext(int requestId) { | ||
this.requestId = requestId; | ||
this.extraInfo = new ConcurrentHashMap<>(); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param moduleName the module name | ||
* @param beanName the bean name | ||
*/ | ||
public RecordContext(String moduleName, String beanName) { | ||
this.extraInfo = new ConcurrentHashMap<>(); | ||
this.moduleName = moduleName; | ||
this.beanName = beanName; | ||
} | ||
|
||
/** | ||
* Gets get request id. | ||
* | ||
* @return the get request id | ||
*/ | ||
public int getRequestId() { | ||
return requestId; | ||
} | ||
|
||
/** | ||
* Sets set request id. | ||
* | ||
* @param requestId the request id | ||
*/ | ||
public void setRequestId(int requestId) { | ||
this.requestId = requestId; | ||
} | ||
|
||
/** | ||
* Gets get trace id. | ||
* | ||
* @return the get trace id | ||
*/ | ||
public String getTraceId() { | ||
return traceId; | ||
} | ||
|
||
/** | ||
* Sets set trace id. | ||
* | ||
* @param traceId the trace id | ||
*/ | ||
public void setTraceId(String traceId) { | ||
this.traceId = traceId; | ||
} | ||
|
||
/** | ||
* Gets get rpc id. | ||
* | ||
* @return the get rpc id | ||
*/ | ||
public String getRpcId() { | ||
return rpcId; | ||
} | ||
|
||
/** | ||
* Sets set rpc id. | ||
* | ||
* @param rpcId the rpc id | ||
*/ | ||
public void setRpcId(String rpcId) { | ||
this.rpcId = rpcId; | ||
} | ||
|
||
/** | ||
* Gets get target service unique name. | ||
* | ||
* @return the get target service unique name | ||
*/ | ||
public String getTargetServiceUniqueName() { | ||
return targetServiceUniqueName; | ||
} | ||
|
||
/** | ||
* Sets set target service unique name. | ||
* | ||
* @param targetServiceUniqueName the target service unique name | ||
*/ | ||
public void setTargetServiceUniqueName(String targetServiceUniqueName) { | ||
this.targetServiceUniqueName = targetServiceUniqueName; | ||
} | ||
|
||
/** | ||
* Gets get method name. | ||
* | ||
* @return the get method name | ||
*/ | ||
public String getMethodName() { | ||
return methodName; | ||
} | ||
|
||
/** | ||
* Sets set method name. | ||
* | ||
* @param methodName the method name | ||
*/ | ||
public void setMethodName(String methodName) { | ||
this.methodName = methodName; | ||
} | ||
|
||
/** | ||
* Gets get module name. | ||
* | ||
* @return the get module name | ||
*/ | ||
public String getModuleName() { | ||
return moduleName; | ||
} | ||
|
||
/** | ||
* Sets set module name. | ||
* | ||
* @param moduleName the module name | ||
*/ | ||
public void setModuleName(String moduleName) { | ||
this.moduleName = moduleName; | ||
} | ||
|
||
/** | ||
* Gets get bean name. | ||
* | ||
* @return the get bean name | ||
*/ | ||
public String getBeanName() { | ||
return beanName; | ||
} | ||
|
||
/** | ||
* Sets set bean name. | ||
* | ||
* @param beanName the bean name | ||
*/ | ||
public void setBeanName(String beanName) { | ||
this.beanName = beanName; | ||
} | ||
|
||
/** | ||
* Gets get extra info. | ||
* | ||
* @return the get extra info | ||
*/ | ||
public Map<String, Object> getExtraInfo() { | ||
return extraInfo; | ||
} | ||
|
||
/** | ||
* Sets set extra info. | ||
* | ||
* @param extraInfo the extra info | ||
*/ | ||
public void setExtraInfo(Map<String, Object> extraInfo) { | ||
this.extraInfo = extraInfo; | ||
} | ||
|
||
/** | ||
* To string string. | ||
* | ||
* @return the string | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "RecordContext{" + "requestId=" + requestId + ", traceId='" + traceId + '\'' | ||
+ ", rpcId='" + rpcId + '\'' + ", targetServiceUniqueName='" | ||
+ targetServiceUniqueName + '\'' + ", methodName='" + methodName + '\'' | ||
+ ", moduleName='" + moduleName + '\'' + ", beanName='" + beanName + '\'' | ||
+ ", extraInfo=" + extraInfo + '}'; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/alipay/sofa/common/insight/RecordScene.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,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.common.insight; | ||
|
||
/** | ||
* @author muqingcai | ||
* @version 2024年4月19日 上午9:55:54 | ||
*/ | ||
public enum RecordScene { | ||
/** | ||
* record 场景 | ||
*/ | ||
BOLT_REQUEST_HANDLE("boltRequestHandle", "bolt 协议 RPC 请求处理"), | ||
|
||
TR_REQUEST_HANDLE("trRequestHandle", "tr 协议 RPC 请求处理"), | ||
|
||
SOFA_STARTUP("sofaStartup", "应用启动"), | ||
|
||
SPRING_BEAN_REFRESH("springBeanRefresh", "应用 bean 刷新"); | ||
|
||
private final String scene; | ||
private final String desc; | ||
|
||
RecordScene(String scene, String desc) { | ||
this.scene = scene; | ||
this.desc = desc; | ||
} | ||
|
||
/** | ||
* Gets get scene. | ||
* | ||
* @return the get scene | ||
*/ | ||
public String getScene() { | ||
return scene; | ||
} | ||
|
||
/** | ||
* Gets get desc. | ||
* | ||
* @return the get desc | ||
*/ | ||
public String getDesc() { | ||
return desc; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/alipay/sofa/common/insight/Recorder.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,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alipay.sofa.common.insight; | ||
|
||
/** | ||
* @author muqingcai | ||
* @version 2024年4月11日 下午9:56:03 | ||
*/ | ||
public interface Recorder { | ||
|
||
/** | ||
* Start record | ||
* | ||
* @param scene the scene | ||
* @param context the context | ||
*/ | ||
void start(RecordScene scene, RecordContext context); | ||
|
||
/** | ||
* Stop record | ||
* | ||
* @param scene the scene | ||
* @param context the context | ||
*/ | ||
void stop(RecordScene scene, RecordContext context); | ||
} |
Oops, something went wrong.