likes
comments
collection
share

SkyWalking之P0核心业务场景输出调用链路应用

作者站长头像
站长
· 阅读数 31

延伸扩展:XX核心业务场景

路由标签打标、传播、检索

SkyWalking之P0核心业务场景输出调用链路应用

链路标签染色与传播

SW: SkyWalking的简写

  1. 用户请求携带HTTP头信息X-sw8-correlation
    • "X-sw8-correlation: key1=value1,key2=value2,key3=value3"
  2. 网关侧读取解析HTTP头信息X-sw8-correlation,然后通过SW的关联上下文传播
    • ContextManager.getCorrelationContext().put(key, value)
      • SW插件使用
    • TraceContext.putCorrelation(key, value)
      • 应用使用
  3. 上游业务应用通过SW的关联上下文传播路由标签
    • CorrelationContext

SkyWalking之P0核心业务场景输出调用链路应用

业务应用通过属性变量设置SW关联上下文的Span跨度标签键的集合,进行自动打标搜索

  • JVM启动参数属性: java -Dskywalking.correlation.auto_tag_keys=autotag1,autotag2
  • 环境变量: SW_CORRELATION_AUTO_TAG_KEYS=autotag1,autotag2

应用变更

  • apm-gateway-trace-plugin,SW插件,feature/guangyi/20240531_span_tag_sw8_correlation分支
    • 网关应用java代理
  • 链路标签染色与传播

使用示例

SkyWalking之P0核心业务场景输出调用链路应用 SkyWalking之P0核心业务场景输出调用链路应用

链路标签数据检索

{"query":"query queryTraces(condition: TraceQueryCondition) {\n data: queryBasicTraces(condition: condition) {\n traces {\n key: segmentId\n endpointNames\n duration\n start\n isError\n traceIds\n }\n }}","variables":{"condition":{"queryDuration":{"start":"2024-06-03 0624","end":"2024-06-03 0654","step":"MINUTE"},"traceState":"ALL","queryOrder":"BY_START_TIME","paging":{"pageNum":1,"pageSize":20},"tags":[{"key":"http.status_code","value":"200"}],"minTraceDuration":null,"maxTraceDuration":null,"serviceId":"bGVmaXQtdXNlcnx8cHJvZA==.1","serviceInstanceId":"bGVmaXQtdXNlcnx8cHJvZA==.1_YmRiZGU2MTMyM2NmNGVmMDhmNDYyNzQxOWY1MDg1ZDNAMTkyLjE2OC4xMDcuMjA4"}}}

参考

转载自:https://juejin.cn/post/7377561821220634624
评论
请登录