Skip to content

Commit bcab2f6

Browse files
committed
[#10918] Backport: Increase the coverage of the apiId cache
1 parent 546a049 commit bcab2f6

File tree

89 files changed

+1166
-736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1166
-736
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.navercorp.pinpoint.bootstrap.context;
18+
19+
public class MethodDescriptorHelper {
20+
21+
public static MethodDescriptor apiId(final int apiId) {
22+
return new MethodDescriptor() {
23+
@Override
24+
public String getMethodName() {
25+
return "";
26+
}
27+
28+
@Override
29+
public String getClassName() {
30+
return "";
31+
}
32+
33+
@Override
34+
public String[] getParameterTypes() {
35+
return new String[0];
36+
}
37+
38+
@Override
39+
public String[] getParameterVariableName() {
40+
return new String[0];
41+
}
42+
43+
@Override
44+
public String getParameterDescriptor() {
45+
return "";
46+
}
47+
48+
@Override
49+
public int getLineNumber() {
50+
return 0;
51+
}
52+
53+
@Override
54+
public String getFullName() {
55+
return "";
56+
}
57+
58+
@Override
59+
public void setApiId(int apiId) {
60+
}
61+
62+
@Override
63+
public int getApiId() {
64+
return apiId;
65+
}
66+
67+
@Override
68+
public String getApiDescriptor() {
69+
return "";
70+
}
71+
72+
@Override
73+
public int getType() {
74+
return 0;
75+
}
76+
77+
@Override
78+
public String toString() {
79+
return "{" +
80+
"apiId=" + apiId +
81+
'}';
82+
}
83+
};
84+
}
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2019 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.navercorp.pinpoint.bootstrap.interceptor;
18+
19+
import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessorUtils;
20+
import com.navercorp.pinpoint.bootstrap.context.AsyncContext;
21+
import com.navercorp.pinpoint.bootstrap.context.AsyncContextUtils;
22+
import com.navercorp.pinpoint.bootstrap.context.Trace;
23+
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
24+
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
25+
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
26+
27+
import java.util.Objects;
28+
29+
/**
30+
* @author jaehong.kim
31+
*/
32+
public abstract class AbstractAsyncContextSpanEventEndPointInterceptor {
33+
protected final PLogger logger = PLoggerFactory.getLogger(getClass());
34+
protected final boolean isDebug = logger.isDebugEnabled();
35+
36+
protected final TraceContext traceContext;
37+
38+
public AbstractAsyncContextSpanEventEndPointInterceptor(TraceContext traceContext) {
39+
this.traceContext = Objects.requireNonNull(traceContext, "traceContext");
40+
}
41+
42+
protected AsyncContext getAsyncContext(Object target, Object[] args) {
43+
return AsyncContextAccessorUtils.getAsyncContext(target);
44+
}
45+
46+
protected AsyncContext getAsyncContext(Object target, Object[] args, Object result, Throwable throwable) {
47+
return AsyncContextAccessorUtils.getAsyncContext(target);
48+
}
49+
50+
protected Trace getAsyncTrace(AsyncContext asyncContext) {
51+
final Trace trace = asyncContext.continueAsyncTraceObject();
52+
if (trace == null) {
53+
return null;
54+
}
55+
56+
return trace;
57+
}
58+
59+
protected void deleteAsyncTrace(final Trace trace) {
60+
traceContext.removeTraceObject();
61+
trace.close();
62+
}
63+
64+
65+
protected void finishAsyncState(final AsyncContext asyncContext) {
66+
if (AsyncContextUtils.asyncStateFinish(asyncContext)) {
67+
if (isDebug) {
68+
logger.debug("finished asyncState. asyncTraceId={}", asyncContext);
69+
}
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2017 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.bootstrap.interceptor;
17+
18+
import com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessorUtils;
19+
import com.navercorp.pinpoint.bootstrap.context.AsyncContext;
20+
import com.navercorp.pinpoint.bootstrap.context.Trace;
21+
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
22+
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
23+
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
24+
25+
import java.util.Objects;
26+
27+
public abstract class AbstractAsyncContextSpanEventInterceptor {
28+
protected final PLogger logger = PLoggerFactory.getLogger(getClass());
29+
protected final boolean isDebug = logger.isDebugEnabled();
30+
protected final boolean isTrace = logger.isTraceEnabled();
31+
32+
public AbstractAsyncContextSpanEventInterceptor(TraceContext traceContext) {
33+
Objects.requireNonNull(traceContext, "traceContext");
34+
}
35+
36+
protected AsyncContext getAsyncContext(Object target, Object[] args) {
37+
return AsyncContextAccessorUtils.getAsyncContext(target);
38+
}
39+
40+
protected AsyncContext getAsyncContext(Object target, Object[] args, Object result, Throwable throwable) {
41+
return AsyncContextAccessorUtils.getAsyncContext(target);
42+
}
43+
44+
protected Trace getAsyncTrace(AsyncContext asyncContext) {
45+
final Trace trace = asyncContext.continueAsyncTraceObject();
46+
if (trace == null) {
47+
if (isDebug) {
48+
logger.debug("Failed to continue async trace. 'result is null'");
49+
}
50+
return null;
51+
}
52+
if (isDebug) {
53+
logger.debug("getAsyncTrace() trace {}, asyncContext={}", trace, asyncContext);
54+
}
55+
56+
return trace;
57+
}
58+
59+
protected void deleteAsyncContext(final Trace trace, AsyncContext asyncContext) {
60+
if (isDebug) {
61+
logger.debug("Delete async trace {}.", trace);
62+
}
63+
64+
trace.close();
65+
asyncContext.close();
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2014 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.navercorp.pinpoint.bootstrap.interceptor;
18+
19+
import com.navercorp.pinpoint.bootstrap.context.Trace;
20+
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
21+
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
22+
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
23+
24+
import java.util.Objects;
25+
26+
/**
27+
* @author emeroad
28+
* @author jaehong.kim
29+
*/
30+
public abstract class AbstractSpanEventInterceptorForPlugin {
31+
protected final PLogger logger = PLoggerFactory.getLogger(getClass());
32+
protected final boolean isDebug = logger.isDebugEnabled();
33+
34+
protected final TraceContext traceContext;
35+
36+
protected AbstractSpanEventInterceptorForPlugin(TraceContext traceContext) {
37+
this.traceContext = Objects.requireNonNull(traceContext, "traceContext");
38+
}
39+
40+
protected Trace currentTrace() {
41+
return traceContext.currentTraceObject();
42+
}
43+
44+
protected void logBeforeInterceptor(Object target, Object[] args) {
45+
logger.beforeInterceptor(target, args);
46+
}
47+
48+
protected void logAfterInterceptor(Object target, Object[] args, Object result, Throwable throwable) {
49+
logger.afterInterceptor(target, args, result, throwable);
50+
}
51+
52+
protected TraceContext getTraceContext() {
53+
return traceContext;
54+
}
55+
}

0 commit comments

Comments
 (0)