-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#10918] Backport: Increase the coverage of the apiId cache
- Loading branch information
1 parent
546a049
commit bcab2f6
Showing
89 changed files
with
1,166 additions
and
736 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...p-core/src/main/java/com/navercorp/pinpoint/bootstrap/context/MethodDescriptorHelper.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,85 @@ | ||
/* | ||
* Copyright 2024 NAVER Corp. | ||
* | ||
* Licensed 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.navercorp.pinpoint.bootstrap.context; | ||
|
||
public class MethodDescriptorHelper { | ||
|
||
public static MethodDescriptor apiId(final int apiId) { | ||
return new MethodDescriptor() { | ||
@Override | ||
public String getMethodName() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getClassName() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String[] getParameterTypes() { | ||
return new String[0]; | ||
} | ||
|
||
@Override | ||
public String[] getParameterVariableName() { | ||
return new String[0]; | ||
} | ||
|
||
@Override | ||
public String getParameterDescriptor() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public int getLineNumber() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String getFullName() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public void setApiId(int apiId) { | ||
} | ||
|
||
@Override | ||
public int getApiId() { | ||
return apiId; | ||
} | ||
|
||
@Override | ||
public String getApiDescriptor() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public int getType() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{" + | ||
"apiId=" + apiId + | ||
'}'; | ||
} | ||
}; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...corp/pinpoint/bootstrap/interceptor/AbstractAsyncContextSpanEventEndPointInterceptor.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,72 @@ | ||
/* | ||
* Copyright 2019 NAVER Corp. | ||
* | ||
* Licensed 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.navercorp.pinpoint.bootstrap.interceptor; | ||
|
||
import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessorUtils; | ||
import com.navercorp.pinpoint.bootstrap.context.AsyncContext; | ||
import com.navercorp.pinpoint.bootstrap.context.AsyncContextUtils; | ||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.TraceContext; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLogger; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author jaehong.kim | ||
*/ | ||
public abstract class AbstractAsyncContextSpanEventEndPointInterceptor { | ||
protected final PLogger logger = PLoggerFactory.getLogger(getClass()); | ||
protected final boolean isDebug = logger.isDebugEnabled(); | ||
|
||
protected final TraceContext traceContext; | ||
|
||
public AbstractAsyncContextSpanEventEndPointInterceptor(TraceContext traceContext) { | ||
this.traceContext = Objects.requireNonNull(traceContext, "traceContext"); | ||
} | ||
|
||
protected AsyncContext getAsyncContext(Object target, Object[] args) { | ||
return AsyncContextAccessorUtils.getAsyncContext(target); | ||
} | ||
|
||
protected AsyncContext getAsyncContext(Object target, Object[] args, Object result, Throwable throwable) { | ||
return AsyncContextAccessorUtils.getAsyncContext(target); | ||
} | ||
|
||
protected Trace getAsyncTrace(AsyncContext asyncContext) { | ||
final Trace trace = asyncContext.continueAsyncTraceObject(); | ||
if (trace == null) { | ||
return null; | ||
} | ||
|
||
return trace; | ||
} | ||
|
||
protected void deleteAsyncTrace(final Trace trace) { | ||
traceContext.removeTraceObject(); | ||
trace.close(); | ||
} | ||
|
||
|
||
protected void finishAsyncState(final AsyncContext asyncContext) { | ||
if (AsyncContextUtils.asyncStateFinish(asyncContext)) { | ||
if (isDebug) { | ||
logger.debug("finished asyncState. asyncTraceId={}", asyncContext); | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...om/navercorp/pinpoint/bootstrap/interceptor/AbstractAsyncContextSpanEventInterceptor.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,67 @@ | ||
/* | ||
* Copyright 2017 NAVER Corp. | ||
* | ||
* Licensed 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.navercorp.pinpoint.bootstrap.interceptor; | ||
|
||
import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessorUtils; | ||
import com.navercorp.pinpoint.bootstrap.context.AsyncContext; | ||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.TraceContext; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLogger; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class AbstractAsyncContextSpanEventInterceptor { | ||
protected final PLogger logger = PLoggerFactory.getLogger(getClass()); | ||
protected final boolean isDebug = logger.isDebugEnabled(); | ||
protected final boolean isTrace = logger.isTraceEnabled(); | ||
|
||
public AbstractAsyncContextSpanEventInterceptor(TraceContext traceContext) { | ||
Objects.requireNonNull(traceContext, "traceContext"); | ||
} | ||
|
||
protected AsyncContext getAsyncContext(Object target, Object[] args) { | ||
return AsyncContextAccessorUtils.getAsyncContext(target); | ||
} | ||
|
||
protected AsyncContext getAsyncContext(Object target, Object[] args, Object result, Throwable throwable) { | ||
return AsyncContextAccessorUtils.getAsyncContext(target); | ||
} | ||
|
||
protected Trace getAsyncTrace(AsyncContext asyncContext) { | ||
final Trace trace = asyncContext.continueAsyncTraceObject(); | ||
if (trace == null) { | ||
if (isDebug) { | ||
logger.debug("Failed to continue async trace. 'result is null'"); | ||
} | ||
return null; | ||
} | ||
if (isDebug) { | ||
logger.debug("getAsyncTrace() trace {}, asyncContext={}", trace, asyncContext); | ||
} | ||
|
||
return trace; | ||
} | ||
|
||
protected void deleteAsyncContext(final Trace trace, AsyncContext asyncContext) { | ||
if (isDebug) { | ||
logger.debug("Delete async trace {}.", trace); | ||
} | ||
|
||
trace.close(); | ||
asyncContext.close(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...a/com/navercorp/pinpoint/bootstrap/interceptor/AbstractSpanEventInterceptorForPlugin.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,55 @@ | ||
/* | ||
* Copyright 2014 NAVER Corp. | ||
* | ||
* Licensed 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.navercorp.pinpoint.bootstrap.interceptor; | ||
|
||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.TraceContext; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLogger; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author emeroad | ||
* @author jaehong.kim | ||
*/ | ||
public abstract class AbstractSpanEventInterceptorForPlugin { | ||
protected final PLogger logger = PLoggerFactory.getLogger(getClass()); | ||
protected final boolean isDebug = logger.isDebugEnabled(); | ||
|
||
protected final TraceContext traceContext; | ||
|
||
protected AbstractSpanEventInterceptorForPlugin(TraceContext traceContext) { | ||
this.traceContext = Objects.requireNonNull(traceContext, "traceContext"); | ||
} | ||
|
||
protected Trace currentTrace() { | ||
return traceContext.currentTraceObject(); | ||
} | ||
|
||
protected void logBeforeInterceptor(Object target, Object[] args) { | ||
logger.beforeInterceptor(target, args); | ||
} | ||
|
||
protected void logAfterInterceptor(Object target, Object[] args, Object result, Throwable throwable) { | ||
logger.afterInterceptor(target, args, result, throwable); | ||
} | ||
|
||
protected TraceContext getTraceContext() { | ||
return traceContext; | ||
} | ||
} |
Oops, something went wrong.