-
Notifications
You must be signed in to change notification settings - Fork 251
feat(amazonq): LSP telemetry/event messages trigger client side telemetry service calls #5511
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
Changes from 1 commit
841947a
d660a3c
c880e8d
4831a5c
085e456
c3cd86f
6d97ddc
792b087
0e22516
37a0193
e97eb33
3219b41
e4309da
f2507f2
e6083d3
f3f6f6f
b698c0b
c545757
a0881c2
75c1a01
666437e
6b30379
1058210
ea52630
ac06230
ff7f920
3652c52
cab6460
77457f2
7d82d95
d8c3f12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,20 +11,55 @@ | |
import org.eclipse.lsp4j.MessageType | ||
import org.eclipse.lsp4j.PublishDiagnosticsParams | ||
import org.eclipse.lsp4j.ShowMessageRequestParams | ||
import software.amazon.awssdk.services.toolkittelemetry.model.MetricUnit | ||
import software.aws.toolkits.core.utils.getLogger | ||
import software.aws.toolkits.core.utils.warn | ||
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager | ||
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.ConnectionMetadata | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.SsoProfileData | ||
import software.aws.toolkits.jetbrains.services.telemetry.TelemetryService | ||
import software.aws.toolkits.jetbrains.settings.CodeWhispererSettings | ||
import java.time.Instant | ||
import java.util.concurrent.CompletableFuture | ||
|
||
/** | ||
* Concrete implementation of [AmazonQLanguageClient] to handle messages sent from server | ||
*/ | ||
class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageClient { | ||
override fun telemetryEvent(`object`: Any) { | ||
println(`object`) | ||
when (`object`) { | ||
Check warning on line 32 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
is MutableMap<*, *> -> handleTelemetryMap(`object`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warn for the other case?
samgst-amazon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
Check warning on line 35 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
|
||
private fun handleTelemetryMap(telemetryMap: MutableMap<*, *>) { | ||
try { | ||
Check warning on line 38 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
val name = telemetryMap["name"] as? String ?: return | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
Check warning on line 41 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
val data = telemetryMap["data"] as? MutableMap<String, Any> ?: return | ||
samgst-amazon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
TelemetryService.getInstance().record(project) { | ||
datum(name) { | ||
createTime(Instant.now()) | ||
Check warning on line 46 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. time should be extracted from the metric? |
||
unit(telemetryMap["unit"] as? MetricUnit ?: MetricUnit.NONE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does Flare model this event? i'm not sure if Gson will magically deserialize into these types |
||
value(telemetryMap["value"] as? Double ?: 1.0) | ||
passive(telemetryMap["passive"] as? Boolean ?: false) | ||
|
||
telemetryMap["result"]?.let { result -> | ||
metadata("result", result.toString()) | ||
Check warning on line 52 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
} | ||
|
||
data.forEach { (key, value) -> | ||
metadata(key, value.toString()) | ||
} | ||
} | ||
} | ||
} catch (e: Exception) { | ||
LOG.warn(e) { "Failed to process telemetry event: $telemetryMap" } | ||
Check warning on line 61 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
} | ||
} | ||
|
||
override fun publishDiagnostics(diagnostics: PublishDiagnosticsParams) { | ||
|
@@ -92,4 +127,8 @@ | |
} | ||
) | ||
} | ||
|
||
companion object { | ||
private val LOG = getLogger<AmazonQLanguageClientImpl>() | ||
Check warning on line 132 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.