-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace: add @span
macro
#1
Conversation
@NthPortal I moved the PR to the new repo. I also renamed |
ensureImplicitExist( | ||
q"_root_.org.typelevel.otel4s.AttributeKey.KeySelect[$tpt]", | ||
e => | ||
s"the argument [${name.decodedName}] cannot be used as an attribute. The type [$tpt] is not supported.${e.getMessage}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the custom name of the attribute to use. If not specified, the name of the parameter will be | ||
* used | ||
*/ | ||
class attribute(@unused name: String = "") extends StaticAnnotation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NthPortal I guess we can add @compileTimeOnly
annotation there, but then I need to change the expand logic slightly.
I will check.
An experimental implementation of the typelevel/otel4s#550.
OpenTelemetry Java offers similar functionality using reflections and AOP https://opentelemetry.io/docs/languages/java/automatic/annotations/.
Before we start
The functionality exists in a separate
otel4s-core-trace-experimental
module.How it works
The body of a method annotated with
@span
will be wrapped into a span:The macro works with variables too:
Summary
Pros
Cons
@attribute
contributes to the visual noiseQuestions
1) Why@withSpan
and@spanAttribute
instead of@span
and@attribute
?If I recall correctly, problems can arise in case-insensitive systems because we already haveSpan
andAttribute
.However, if that is not the case, I would prefer@span
and@attribute
.2) Should the macro capture source information?
We can easily add source attributes to the span, such as
Attribute("source.file", "some/path/Service.scala")
andAttribute("source.line", 123L)
.