使用OpenTelemetry代理与在Spring Boot中添加opentelemetry-exporter-otlp有什么区别?

huangapple go评论78阅读模式
英文:

What is the difference between using OpenTelemetry agent vs adding opentelemetry-exporter-otlp in Spring Boot?

问题

官方的 OpenTelemetry 文档鼓励使用 Java 代理来为应用程序添加仪表。

Spring Boot 文档未提及代理,他们表示在使用 io.micrometer:micrometer-tracing-bridge-otelio.opentelemetry:opentelemetry-exporter-otlp 时会自动配置 OTLP。

我正在尝试了解应该使用哪种方法:Spring Boot 是否也需要代理?如果没有代理,Spring Boot 是否会遵循用于配置 OTEL 的标准环境变量?Spring Boot 是否还会配置 OTel 代理功能,例如注入带有跨度和跟踪 ID 的 MDC 日志记录?

英文:

The official OpenTelemetry docs encourage using the Java agent to instrument applications.

The Spring boot docs don't mention the agent, and they say they autoconfigure OTLP when the io.micrometer:micrometer-tracing-bridge-otel and io.opentelemetry:opentelemetry-exporter-otlp.

I'm trying to understand which approach to use: Is the agent also required for Spring Boot? Without the agent will Spring Boot respect the standard environment variables for configuring OTEL? Will Spring Boot also configure OTel agent features such as injecting MDC logging with span and trace IDs?

答案1

得分: 2

在写作时,我也会建议大多数情况下使用Java代理 - 它比仅使用Spring Boot更容易设置,并支持的库更多(未来可能会有所改变,Spring中的OpenTelemetry支持刚刚添加到Spring Boot 3)。

何时应该使用Spring的本机OpenTelemetry支持?

  • 您使用Spring Boot 3+
  • 您希望避免Java代理的启动时间,例如在使用FaaS(函数即服务)时
  • 您想要使用本机映像

Spring Boot也需要代理吗?

不需要,您可以在不使用Java代理的情况下使用Spring Boot - 可以在Grafana OpenTelemetry starter中找到一个示例(完全披露:我是作者)。

没有代理,Spring Boot会尊重用于配置OTEL的标准环境变量吗?

最重要的标准环境变量得到了支持,但不是全部。

Spring Boot还会配置OTel代理功能,如在跨度和跟踪ID中注入MDC日志吗?

不会,但您可以通过添加额外的依赖项来配置这一点 - 请参阅https://stackoverflow.com/questions/76555166/logging-opentelemetry-tracid-in-spring-boot-reactive-server

英文:

At the time of writing, I would also agree recommend the Java agent for most use cases - it's easier to set up and supports more libraries than spring boot alone does (this may change in the future, the OpenTelemetry support in Spring has just been added in Spring Boot 3).

When should you use spring's native OpenTelemetry support?

  • You use Spring Boot 3+
  • You want to avoid the startup time of the Java agent, e.g. when you use FaaS (function as a service)
  • You want to use a native image

> Is the agent also required for Spring Boot?

No, you can use Spring boot without the java agent - an example can be found in the Grafana OpenTelemetry starter (full disclosure: I'm the author).

> Without the agent will Spring Boot respect the standard environment variables for configuring OTEL?

The most important standard environment variables are supported - but not all.

> Will Spring Boot also configure OTel agent features such as injecting MDC logging with span and trace IDs?

No, but you can configure this by adding an additional dependency - see https://stackoverflow.com/questions/76555166/logging-opentelemetry-tracid-in-spring-boot-reactive-server

huangapple
  • 本文由 发表于 2023年6月26日 20:44:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76556815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定