最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring boot - How to put argument values to traces of method annotated with @Observed - Stack Overflow

programmeradmin1浏览0评论

I have a method annotated with @Observed annotation:

@Observed(
    name = "foo",
    contextualName = "foo",
)
fun foo(arg1: String, arg2: Integer){...}

When I go to Zipkin I see corresponding trace but it contains only method name and information about spring boot version:

It would be useful to have argument values in the trace. Is there way to achieve it ?

I have a method annotated with @Observed annotation:

@Observed(
    name = "foo",
    contextualName = "foo",
)
fun foo(arg1: String, arg2: Integer){...}

When I go to Zipkin I see corresponding trace but it contains only method name and information about spring boot version:

It would be useful to have argument values in the trace. Is there way to achieve it ?

Share Improve this question asked Mar 3 at 14:18 gstackoverflowgstackoverflow 36.6k138 gold badges419 silver badges786 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1 +50

You can do this:

@Observed(
    name = "test.call",
    contextualName = "test#call",
    lowCardinalityKeyValues = { "abc", "123", "test", "42" }
)

See the docs: https://docs.micrometer.io/micrometer/reference/observation/components.html#micrometer-observation-annotations

If you want to attach key-values dynamically, you cannot use the annotation:

Observation.createNotStarted("foo", registry)
                .lowCardinalityKeyValue("lowTag", "lowTagValue")
                .highCardinalityKeyValue("highTag", "highTagValue")
                .observe(() -> System.out.println("Hello"));

See the docs: https://docs.micrometer.io/micrometer/reference/observation/introduction.html

发布评论

评论列表(0)

  1. 暂无评论