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

DynamicTp可能出现的INTERNAL_LOGGING无法打印的问题 #531

Open
maosi opened this issue Feb 21, 2025 · 4 comments
Open

DynamicTp可能出现的INTERNAL_LOGGING无法打印的问题 #531

maosi opened this issue Feb 21, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@maosi
Copy link

maosi commented Feb 21, 2025

首先感谢您使用 DynamicTp,如果使用过程中有任何问题,请按照下述模板反馈问题,请使用 Markdown 语法

版本信息

  • Jdk版本:1.8
  • SpringBoot版本:2.7.18
  • DynamicTp版本:1.2.0
  • 配置中心类型:无

问题描述

dtp在以下运行环境下,会出现监控日志无法打印且没有相关的错误日志输出的问题:

  1. 与spring-boot集成但非spring-web环境
  2. 排除 spring-boot-starter-actuator
  3. 只使用 INTERNAL_LOGGING 方式监控信息

猜测可能原因:

在排除掉 spring-boot-starter-actuator 的同时,也会排除掉 jackson-datatype-jsr310,但 JacksonParser 中创建 mapper 的方法中使用到了 jackson-datatype-jsr310 中的类导致 mapper 的创建失败,引起 parser 创建失败导致。

代码

pom.xml:

	<properties>
		<maven.compiler.source>8</maven.compiler.source>
		<maven.compiler.target>8</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<dynamic-tp.version>1.2.0</dynamic-tp.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.dromara.dynamictp</groupId>
			<artifactId>dynamic-tp-spring-boot-starter-common</artifactId>
			<version>${dynamic-tp.version}</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-actuator</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>

application.yml:

dynamictp:
  collector-types: INTERNAL_LOGGING
  executors:
    - threadPoolName: dtpExecutor1
      corePoolSize: 2
      notifyEnabled: false

启动类:

@SpringBootApplication
@EnableDynamicTp
public class Main implements ApplicationRunner {

	public static void main(String[] args) {
		SpringApplication.run(Main.class, args);
	}

	@Override
	public void run(ApplicationArguments args) throws Exception {
		Thread.sleep(100000L);
	}
}

建议

dynamic-tp-core 添加依赖 jackson-datatype-jsr310

@maosi maosi added the bug Something isn't working label Feb 21, 2025
@KamToHung
Copy link
Collaborator

KamToHung commented Feb 22, 2025

为什么单独引入dynamic-tp-spring-boot-starter-common然后排除spring-boot-starter-actuator
如果这么操作的话,可以自己再次引入jackson-datatype-jsr310

@KamToHung KamToHung added question Further information is requested and removed bug Something isn't working labels Feb 22, 2025
@maosi
Copy link
Author

maosi commented Feb 22, 2025

为什么单独引入dynamic-tp-spring-boot-starter-common然后排除spring-boot-starter-actuator 如果这么操作的话,可以自己再次引入jackson-datatype-jsr310

因为我这只需要定时打印线程池的监控信息,不需要actuator。
我觉得关键点在于实际上是发生了异常 java.lang.NoClassDefFoundError: com/fasterxml/jackson/datatype/jsr310/JavaTimeModule ,但日志中没有相关异常信息输出,对使用者而言可能不大容易排查出这个问题,或者考虑把相关日志打印出来以便使用者定位问题。

@KamToHung
Copy link
Collaborator

为什么单独引入dynamic-tp-spring-boot-starter-common然后排除spring-boot-starter-actuator 如果这么操作的话,可以自己再次引入jackson-datatype-jsr310

因为我这只需要定时打印线程池的监控信息,不需要actuator。 我觉得关键点在于实际上是发生了异常 java.lang.NoClassDefFoundError: com/fasterxml/jackson/datatype/jsr310/JavaTimeModule ,但日志中没有相关异常信息输出,对使用者而言可能不大容易排查出这个问题,或者考虑把相关日志打印出来以便使用者定位问题。

如果正常使用是没问题,异常方面后续做一些处理

@KamToHung KamToHung added bug Something isn't working and removed question Further information is requested labels Feb 23, 2025
@KamToHung KamToHung self-assigned this Feb 23, 2025
KamToHung added a commit to KamToHung/dynamic-tp that referenced this issue Feb 23, 2025
KamToHung added a commit to KamToHung/dynamic-tp that referenced this issue Feb 23, 2025
KamToHung added a commit to KamToHung/dynamic-tp that referenced this issue Feb 23, 2025
@KamToHung
Copy link
Collaborator

#534 修复此问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants