Skywalking内置Tags

Apache SkyWalking APM 的核心组件 Tags.java 文件中定义了用于跟踪和监控的关键标签,包括 url、status_code、db 类型和实例、SQL 语句、MQ 队列和主题等。这些标签对于理解应用程序的性能和行为至关重要,例如 HTTP 方法、请求参数和响应状态码,以及数据库和消息队列交互的详细信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 定义所在源代码文件:
/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/Tags.java
取值对应Tag
1url
2status_code
3db.type
4db.instance
5db.statement
6db.bind_vars
7mq.queue
8mq.broker
9mq.topic
10http.method
11http.params
12x-le
13http.body
14http.headers
### SkyWalking Tags Usage and Examples In the context of SkyWalking, tags are utilized extensively within tracing mechanisms to provide additional metadata about spans or traces. The `IgnoredException` annotation mentioned serves as one method for configuring which exceptions should be disregarded during trace processing[^1]. This functionality allows developers to control how certain exceptional flows impact monitoring data. For tagging operations specifically: When using SkyWalking's API directly, one can add custom tags to a span with methods provided by the tracer interface. Below demonstrates adding simple key-value pairs that describe aspects of service interactions more precisely. ```java Span span = tracer.createExitSpan("/service/method", destination); span.setTag("http.status_code", "200"); span.setTag("db.instance", "main_db"); ``` Additionally, when integrating via instrumentation modules (like Spring Boot), annotations play a significant role in specifying behavior without modifying application logic explicitly. For instance, marking services or methods so they automatically report specific metrics upon invocation. #### Using Annotations for Tagging To apply predefined sets of tags consistently across multiple endpoints, consider leveraging built-in or custom annotations supported by SkyWalking APM. An example might involve annotating REST controller actions to include operation names automatically. ```java @Tag(key="operation.name", value="${method.name}") @GetMapping("/api/resource/{id}") public ResponseEntity<Resource> getResource(@PathVariable String id) { // Method implementation... } ``` This approach ensures every request handled through this endpoint will carry along useful contextual information like its name, aiding later analysis efforts significantly. --related questions-- 1. How does setting up ignored exceptions influence overall system observability? 2. What other types of metadata besides HTTP status codes could enhance trace diagnostics? 3. Can you explain how to create custom annotations tailored for specialized tagging needs? 4. In what scenarios would it be beneficial to use programmatic tag addition over declarative approaches?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值