Skip to content

Implement telemetry types generator - #38

Merged
breedloj merged 8 commits into
mainfrom
breedloj/telemetryTypes
Oct 1, 2024
Merged

Implement telemetry types generator#38
breedloj merged 8 commits into
mainfrom
breedloj/telemetryTypes

Conversation

@breedloj

Copy link
Copy Markdown
Contributor

Description of changes:
Telemetry types generation, ported from Kotlin using JavaPoet and implemented as a Maven Mojo. Generator is run during plugin build and produces output in target/generated-sources. This is a first pass implementation and the types will likely change/expand as we integrate with telemetry and feedback sources in the codebase.

Example definition for a Q chat end chat event:

    public static class EndChatEventBuilder {
        private String amazonqConversationId;

        private Double amazonqEndOfTheConversationLatency;

        private String credentialStartUrl;

        private boolean passive;

        private Instant createTime;

        private Double value;

        private EndChatEventBuilder() {
        }

        /**
         * Uniquely identifies a message with which the user interacts.
         */
        public EndChatEventBuilder amazonqConversationId(String amazonqConversationId) {
            this.amazonqConversationId = amazonqConversationId;
            return this;
        }

        /**
         * Total time from start to end
         */
        public EndChatEventBuilder amazonqEndOfTheConversationLatency(
                Double amazonqEndOfTheConversationLatency) {
            this.amazonqEndOfTheConversationLatency = amazonqEndOfTheConversationLatency;
            return this;
        }

        /**
         * The start URL of current SSO connection
         */
        public EndChatEventBuilder credentialStartUrl(String credentialStartUrl) {
            this.credentialStartUrl = credentialStartUrl;
            return this;
        }

        /**
         * Indicates that the metric was not caused by an explicit user action.
         */
        public EndChatEventBuilder passive(boolean passive) {
            this.passive = passive;
            return this;
        }

        /**
         * The time that the event took place.
         */
        public EndChatEventBuilder createTime(Instant createTime) {
            this.createTime = createTime;
            return this;
        }

        /**
         * Value based on unit and call type.
         */
        public EndChatEventBuilder value(Double value) {
            this.value = value;
            return this;
        }

        public MetricDatum build() {
            List<MetadataEntry> metadata = new ArrayList<MetadataEntry>();
            metadata.add(MetadataEntry.builder().key("amazonqConversationId").value(String.valueOf(amazonqConversationId)).build());
            metadata.add(MetadataEntry.builder().key("amazonqEndOfTheConversationLatency").value(String.valueOf(amazonqEndOfTheConversationLatency)).build());
            metadata.add(MetadataEntry.builder().key("credentialStartUrl").value(String.valueOf(credentialStartUrl)).build());
            metadata.add(MetadataEntry.builder().key("passive").value(String.valueOf(passive)).build());
            metadata.add(MetadataEntry.builder().key("createTime").value(String.valueOf(createTime)).build());
            metadata.add(MetadataEntry.builder().key("value").value(String.valueOf(value)).build());

            return MetricDatum.builder()
                .metricName("amazonq_endChat")
                .epochTimestamp((createTime != null ? createTime : Instant.now()).toEpochMilli())
                .unit(Unit.NONE)
                .value(value != null ? value : 1.0)
                .passive(passive)
                .metadata(metadata)
                .build();
        }
    }

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@breedloj

breedloj commented Sep 30, 2024

Copy link
Copy Markdown
Contributor Author

Hydrated full telemetry payloads:

Sample Q metric event

{
    "AWSProduct": "AWS Toolkit For Eclipse",
    "AWSProductVersion": "1.0.0-snapshot",
    "ClientID": "8c230dd7-ffae-4889-9aa4-1b19af7c44ce",
    "OS": "Mac OS X",
    "OSVersion": "14.7",
    "ParentProduct": "Eclipse",
    "ParentProductVersion": "1.0",
    "MetricData": [
        {
            "MetricName": "amazonq_isAcceptedCodeChanges",
            "EpochTimestamp": 1727739729619,
            "Unit": "None",
            "Value": 1.0,
            "Metadata": [
                {
                    "Key": "amazonqConversationId",
                    "Value": "1234"
                },
                {
                    "Key": "amazonqNumberOfFilesAccepted",
                    "Value": "1.0"
                },
                {
                    "Key": "credentialStartUrl",
                    "Value": "null"
                },
                {
                    "Key": "enabled",
                    "Value": "false"
                },
                {
                    "Key": "passive",
                    "Value": "false"
                },
                {
                    "Key": "createTime",
                    "Value": "2024-09-30T23:42:09.619139Z"
                },
                {
                    "Key": "value",
                    "Value": "1.0"
                }
            ],
            "Passive": false
        }
    ]
}

Feedback payload

{
    "AWSProduct": "AWS Toolkit For Eclipse",
    "AWSProductVersion": "1.0.0-snapshot",
    "OS": "Mac OS X",
    "OSVersion": "14.7",
    "ParentProduct": "Eclipse",
    "ParentProductVersion": "1.0",
    "Metadata": [
        {
            "Key": "result",
            "Value": "Succeeded"
        },
        {
            "Key": "passive",
            "Value": "false"
        },
        {
            "Key": "createTime",
            "Value": "2024-09-30T23:46:32.215723Z"
        },
        {
            "Key": "value",
            "Value": "1.0"
        }
    ],
    "Sentiment": "Positive",
    "Comment": "This is test feedback sent from the Amazon Q for Eclipse plugin"
}

@breedloj
breedloj merged commit c8713d6 into main Oct 1, 2024
@breedloj
breedloj deleted the breedloj/telemetryTypes branch October 1, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant