-
Notifications
You must be signed in to change notification settings - Fork 5
Add OpenTelemetry tracing to EditorServiceManager and formatting #104
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
base: main
Are you sure you want to change the base?
Conversation
Extended EditorServiceManager and related classes with OpenTelemetry spans to track performance and debug issues effectively. Applied spans to key methods, such as service initialization, formatting, and cache priming, to capture execution details and errors comprehensively.
@@ -28,72 +38,143 @@ class DprintFormattingTask( | |||
) { | |||
private var formattingIds = mutableListOf<Int>() | |||
private var isCancelled = false | |||
private val tracer: Tracer = TelemetryManager.getInstance().getTracer(DprintScope.FormatterScope) |
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.
TelemetryManager
is technically annotated as internal API, but AFAICT the API hasn't really changed 🤷
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.
It should be fine and there is a IJ verify gradle task that makes sure it works with the configured IJ versions in the verifier
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.
Looking at the build, this blows up.
} else { | ||
mutableListOf( | ||
TextRange(0, content.length), | ||
val rootSpan = |
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.
Just as an FYI this class is only run for the replacement of the default IJ formatter. So when you run shift+cmd+option+L or whatever it is.
You probably want to have something that wraps the lower level activities that are shared between this and the code which runs if the user has configured format on save through the dprint config window. I believe that is the EditorServiceManager
or the Process
depending on what you want to capture in OTEL.
This is pretty gnarly, but chucking this up to get feedback. This uses IntelliJ's OpenTelemetry tracing support. The hard yards was authored by JetBrains AI Assistant with Claude 3.7 Sonnet.
You'll probably want to review this with "hide whitespace changes" on.
Happy to rename the spans if anyone has good suggestions.
The below description was generated by JetBrains AI Assistant:
Extended EditorServiceManager and related classes with OpenTelemetry spans to track performance and debug issues effectively. Applied spans to key methods, such as service initialization, formatting, and cache priming, to capture execution details and errors comprehensively.