Skip to content

@SpanAttribute annotation with custom value resolver for an attribute #7484

Answered by mateuszrzeszutek
ashwin-07 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ashwin-07 ,

Have you tried using Span.current() and just setting the value manually?

@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).

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ashwin-07
Comment options

@mateuszrzeszutek
Comment options

@ashwin-07
Comment options

@trask
Comment options

trask Jan 3, 2023
Maintainer

@ashwin-07
Comment options

Answer selected by ashwin-07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants