java - Spring Boot 容器应用程序上的 Datadog 检测 - 找不到类
问题描述
我目前正在将 Spring Boot 应用程序作为容器运行到 Kubernetes 集群中。Datadog 代理在集群上作为容器运行。
在运行应用程序之前,我已修改容器映像构建以包含 datadog 代理:
CMD ["/bin/sh","-c","java -javaagent:dd-java-agent.jar -Ddd.trace.config=datadog.properties -Dlogging.config=/logback.xml -jar service.jar"]
我还设置了环境变量以通过部署文件将代理的主机 IP 指示给我的容器。
现在的问题是我在应用程序启动时遇到此类未找到异常:
java.lang.NoClassDefFoundError: datadog/trace/instrumentation/springscheduling/SpringSchedulingInstrumentation
at java.lang.Class.getDeclaringClass0(Native Method)
at java.lang.Class.getDeclaringClass(Class.java:1235)
at java.lang.Class.getEnclosingClass(Class.java:1277)
at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:233)
at org.springframework.core.annotation.AnnotationsScanner.processClassHierarchy(AnnotationsScanner.java:194)
at org.springframework.core.annotation.AnnotationsScanner.processClass(AnnotationsScanner.java:128)
at org.springframework.core.annotation.AnnotationsScanner.process(AnnotationsScanner.java:107)
at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:97)
at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:78)
at org.springframework.core.annotation.TypeMappedAnnotations.scan(TypeMappedAnnotations.java:242)
at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:149)
at org.springframework.core.annotation.TypeMappedAnnotations.get(TypeMappedAnnotations.java:131)
at org.springframework.core.annotation.AnnotationUtils.findAnnotation(AnnotationUtils.java:581)
at org.springframework.cloud.sleuth.DefaultSpanNamer.annotation(DefaultSpanNamer.java:71)
at org.springframework.cloud.sleuth.DefaultSpanNamer.name(DefaultSpanNamer.java:58)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:59)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.<init>(TraceRunnable.java:51)
at org.springframework.cloud.sleuth.instrument.async.LazyTraceThreadPoolTaskScheduler.scheduleWithFixedDelay(LazyTraceThreadPoolTaskScheduler.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.cloud.sleuth.instrument.async.ExecutorMethodInterceptor.invoke(ExecutorBeanPostProcessor.java:328)
相当直截了当,我需要在应用程序包中包含一些依赖项。但是我在 datadog 网站和 maven 中央存储库上找不到任何有用的东西。包括代理本身或 api 库无法解决任何问题。此类存在于代理上,但在不同的路径下。
有谁知道应用程序的类路径中应该包含哪些依赖项来解决这个问题?
解决方案
Spring 正在扫描您似乎不完整的类路径。也许它与Spring的类加载机制有关。有问题的类存在并且似乎是代理的一部分。
您可能使用的是过时版本的代理。
推荐阅读
- python-3.x - 如何将 dask 数据帧转换为 scipy csr 矩阵?
- android - FlutterDriver:使用 Android 后退按钮
- typo3 - 如何修复自 TYPO3 6.2.47 ELTS 以来的错误邮件格式输出?
- java - Spring Boot 后休息调用“缺少所需的请求正文”
- spring - 如何使用 Spring 配置文件设置 Flyway 迁移文件位置
- python - 刷新整个 tkinter gui?
- php - 使用 laravel 发送多张图片
- python - Python Pandas 重塑数据框
- typescript - 在打字稿中使用扩展类型进行类型推断
- javascript - 如何从 webstor 节目中获取有关参数来源的信息