forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#9631] Record SpanEventException in SpanRecorder.recordE…
…xception()
- Loading branch information
Showing
28 changed files
with
1,021 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...in/java/com/navercorp/pinpoint/profiler/context/exception/AtomicExceptionIdGenerator.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,44 @@ | ||
/* | ||
* Copyright 2023 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.profiler.context.exception; | ||
|
||
import com.google.inject.Inject; | ||
|
||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public class AtomicExceptionIdGenerator implements ExceptionIdGenerator { | ||
|
||
public static final long INITIAL_EXCEPTION_ID = 1L; | ||
|
||
private final AtomicLong errorId = new AtomicLong(INITIAL_EXCEPTION_ID); | ||
|
||
@Inject | ||
public AtomicExceptionIdGenerator() { | ||
} | ||
|
||
@Override | ||
public long getCurrentExceptionId() { | ||
return this.errorId.get(); | ||
} | ||
|
||
@Override | ||
public long nextExceptionId() { | ||
return this.errorId.getAndIncrement(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...a/com/navercorp/pinpoint/profiler/context/exception/DefaultExceptionRecordingService.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 2023 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.profiler.context.exception; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public class DefaultExceptionRecordingService implements ExceptionRecordingService { | ||
|
||
private static final Logger logger = LogManager.getLogger(DefaultExceptionRecordingService.class); | ||
|
||
private static final boolean IS_DEBUG = logger.isDebugEnabled(); | ||
|
||
private final ExceptionIdGenerator exceptionIdGenerator; | ||
|
||
public DefaultExceptionRecordingService(ExceptionIdGenerator exceptionIdGenerator) { | ||
this.exceptionIdGenerator = exceptionIdGenerator; | ||
} | ||
|
||
@Override | ||
public SpanEventException recordException(ExceptionRecordingContext context, Throwable current, long startTime) { | ||
Objects.requireNonNull(context); | ||
|
||
ExceptionRecordingState state = ExceptionRecordingState.stateOf(context.getPrevious(), current); | ||
SpanEventException spanEventException = state.apply(context, current, startTime, exceptionIdGenerator); | ||
|
||
logException(spanEventException); | ||
|
||
return spanEventException; | ||
} | ||
|
||
private void logException(SpanEventException spanEventException) { | ||
if (IS_DEBUG && spanEventException != null) { | ||
logger.debug(spanEventException); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionIdGenerator.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,24 @@ | ||
/* | ||
* Copyright 2023 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.profiler.context.exception; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
public interface ExceptionIdGenerator { | ||
long getCurrentExceptionId(); | ||
long nextExceptionId(); | ||
} |
Oops, something went wrong.