Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#10866] Increase the coverage of the apiId cache #10867

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
</dependency>

<dependency>
<groupId>io.projectreactor.netty</groupId>
Expand Down
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 +
'}';
}
};
}
}
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.PluginLogManager;
import com.navercorp.pinpoint.bootstrap.logging.PluginLogger;

import java.util.Objects;

/**
* @author jaehong.kim
*/
public abstract class AbstractAsyncContextSpanEventEndPointInterceptor {
protected final PluginLogger logger = PluginLogManager.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);
}
}
}
}
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.PluginLogManager;
import com.navercorp.pinpoint.bootstrap.logging.PluginLogger;

import java.util.Objects;

public abstract class AbstractAsyncContextSpanEventInterceptor {
protected final PluginLogger logger = PluginLogManager.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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.context.Trace;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.logging.PluginLogManager;
import com.navercorp.pinpoint.bootstrap.logging.PluginLogger;

import java.util.Objects;

/**
* @author emeroad
* @author jaehong.kim
*/
public abstract class AbstractSpanEventInterceptorForPlugin {
protected final PluginLogger logger = PluginLogManager.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;
}
}
Loading
Loading