将追踪信息导出到 Zipkin
在 Zipkin 中可视化追踪信息
将追踪信息导出到 Zipkin 是 CoddyKit 上的免费 Spring Boot 4 Microservices & REST APIs 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Spring Boot 4 Microservices & REST APIs 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Spring Boot 4 Microservices & REST APIs 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Why an exporter is needed
Creating spans is not enough - they must be exported to a backend that stores and visualizes them. Zipkin is a popular, easy-to-run choice.
Running Zipkin
The simplest way to run Zipkin locally is its Docker image. It exposes a UI and an ingest API on port 9411.
// docker run -d -p 9411:9411 openzipkin/zipkin
// UI at http://localhost:9411Adding the Zipkin reporter
Add the reporter dependency so finished spans are sent to Zipkin.
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
</dependency>Configuring the endpoint
Tell Spring where Zipkin lives. The default endpoint is the local Zipkin ingest URL.
management:
zipkin:
tracing:
endpoint: http://localhost:9411/api/v2/spansSetting the sampling rate
Combine the exporter with a sampling probability. In development you often sample 100% to see every trace.
management:
tracing:
sampling:
probability: 1.0 # 100% in devService name in Zipkin
Spans are grouped by service. Zipkin uses spring.application.name as the service name, so set it meaningfully on each app.
spring:
application:
name: order-serviceHow spans reach Zipkin
Each service buffers finished spans and reports them to Zipkin asynchronously (over HTTP by default). Zipkin joins spans sharing a traceId into one trace.
Exploring traces in the UI
In the Zipkin UI you search by service, span name, tag or duration, then open a trace to see the waterfall of spans across all services.
Reading the dependency graph
Zipkin can render a service dependency diagram from collected traces, showing which services call which - a live map of your architecture.
Alternative backends
The same Micrometer setup can export elsewhere. With the OpenTelemetry bridge you can send to OTLP-compatible backends (Tempo, Jaeger, vendors) instead of Zipkin.
Production considerations
In production, lower the sampling rate, secure the Zipkin endpoint, and ensure the reporter's async queue does not drop too many spans under load. Tracing should never harm request latency.
Quick Check
Confirm your exporter knowledge.
Recap
You exported traces to Zipkin:
- Run Zipkin (port 9411) and add the Zipkin reporter
- Set the endpoint and a sampling probability
spring.application.nameis the Zipkin service name- Explore waterfalls and the service dependency graph in the UI
用 AI 导师学习 Java — 免费
在浏览器中编写并运行真实代码,获得全天候 AI 导师的即时帮助,并在网页或应用中继续学习。
- 课程
- 24
- 课程
- 93
常见问题解答
「将追踪信息导出到 Zipkin」课时是免费的吗?
是的 — 「将追踪信息导出到 Zipkin」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Spring Boot 4 Microservices & REST APIs 课程的其余内容,请升级到 CoddyKit PRO。 Spring Boot 4 Microservices & REST APIs 课程共包含 4 节课。
「将追踪信息导出到 Zipkin」这节课中我会学到什么?
在 Zipkin 中可视化追踪信息 你通过在浏览器中直接运行的动手代码来练习 Spring Boot 4 Microservices & REST APIs,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Spring Boot 4 Microservices & REST APIs 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Spring Boot 4 Microservices & REST APIs 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。
「将追踪信息导出到 Zipkin」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Spring Boot 4 Microservices & REST APIs 课中编写并运行代码吗?
能。每节 Spring Boot 4 Microservices & REST APIs 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 分布式追踪为何重要
- Micrometer Tracing
- 将追踪信息导出到 Zipkin
- 关联日志和追踪信息