@SpanAttribute annotation with custom value resolver for an attribute #7484
-
Hello 👋 I was wondering if there was any value resolver kind of thing which is present for @SpanAttribute annotation for auto instrumentation. So that we could pass in something like Example:Adding a sample code for illustration. TestObject.java
Instrumented Method
I am looking for an option to record only the testObject.field1 property and leave out the rest two properties of the Span Attribute testObject as part of the span. I guess overriding the toString method will help achieve this but I cannot override toString in my actual codebase because it is also used in other places as well. Is there any way to achieve this with SpanAttribute? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey @ashwin-07 , Have you tried using @WithSpan("test method")
private void processChange(TestObject testObject) {
Span.current().setAttribute("my-custom-attr", testObject.field1);
/*business logic*/
} I believe it's a bit easier than implementing a custom resolver class (and takes less code). |
Beta Was this translation helpful? Give feedback.
Hey @ashwin-07 ,
Have you tried using
Span.current()
and just setting the value manually?I believe it's a bit easier than implementing a custom resolver class (and takes less code).