Skip to content
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

Send telemetry events to telemetry plugin #115

Merged
merged 4 commits into from
Oct 7, 2022

Conversation

dkwon17
Copy link
Contributor

@dkwon17 dkwon17 commented Sep 22, 2022

Signed-off-by: David Kwon [email protected]

Part of eclipse-che/che#21661

This PR introduces a new built-in extension:
image

Which sends telemetry events to http://localhost:${DEVWORKSPACE_TELEMETRY_BACKEND_PORT}

Compared to Che-theia telemetry, the Che-code telemetry:

To test this PR:

  1. Start a workspace with this URL
{CHE_HOST}/#https://github.com/dkwon17/che-code/tree/telemetryService
  1. After the workspace starts, add the following telemetry plugin under the DevWorkspace's spec.template.components:
- attributes:
  name: telemetry
  plugin:
    uri: https://gist.githubusercontent.com/dkwon17/d2f800494959dadd1106512b0c56275e/raw/5fada3206ee6dba868fd73086acc21d46682cce8/woopra-test.yaml

This telemetry plugin will log the received events.
3. Start the workspace again
4. Run yarn && yarn watch and then run yarn server to install dependencies and start up a new instance of VS Code.
5. Click on Open In New Tab to open the new instance
image
6. View the container logs for the telemetry plugin. You could try to send and verify that the Start Workspace in Che, Open Workspace in Che, and Edit Workspace File in Che events are being sent:

Start Workspace in Che log (when opening the workspace)

2022-10-03 21:40:14,489 DEBUG [com.red.dev.ser.tel.woo.AnalyticsManager] (executor-thread-0) sending Start Workspace in Che (ip=null - userAgent=null) with properties: {creation time=1664830321000, devworkspace id=workspaceec5d20f7242b499b, devworkspace name=che-code, start time=1664833044918, age=2723}

Refresh Workspace in Che log (you should see this when you refresh the page with F5 for example)

2022-10-03 21:51:09,529 DEBUG [com.red.dev.ser.tel.woo.AnalyticsManager] (executor-thread-0) sending Refresh Workspace in Che (ip=null - userAgent=null) with properties: {creation time=1664830321000, devworkspace id=workspaceec5d20f7242b499b, devworkspace name=che-code, start time=1664833044918, age=2723}

Edit Workspace File in Che log (when editing a file)

2022-10-03 21:40:50,852 DEBUG [com.red.dev.ser.tel.woo.AnalyticsManager] (executor-thread-0) sending Edit Workspace File in Che (ip=null - userAgent=null) with properties: {creation time=1664830321000, devworkspace id=workspaceec5d20f7242b499b, devworkspace name=che-code, start time=1664833044918, age=2723, programming language=json}

There are more telemetry events, but the Keep Workspace Inactive in Che and Stop Workspace in Che events are handled form the plugin side and not the VS Code extension side (See 1, 2).

@dkwon17 dkwon17 changed the title WIP WIP - Send telemetry events to telemetry plugin Sep 22, 2022
@dkwon17 dkwon17 marked this pull request as draft September 22, 2022 13:14
@dkwon17 dkwon17 force-pushed the telemetryService branch 4 times, most recently from 6269afb to f4bf54f Compare September 26, 2022 20:26
@dkwon17 dkwon17 requested a review from ibuziuk October 3, 2022 21:55
@dkwon17 dkwon17 marked this pull request as ready for review October 3, 2022 21:56
@dkwon17 dkwon17 changed the title WIP - Send telemetry events to telemetry plugin Send telemetry events to telemetry plugin Oct 4, 2022
Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the code/extensions/che-telemetry/telemetry-0.0.1.vsix build artefact is not need there.

code/extensions/che-telemetry/extension.ts Outdated Show resolved Hide resolved
code/extensions/che-telemetry/package.json Outdated Show resolved Hide resolved
code/extensions/che-telemetry/package.json Outdated Show resolved Hide resolved
code/extensions/che-telemetry/package.nls.json Outdated Show resolved Hide resolved
code/extensions/che-telemetry/src/extension.ts Outdated Show resolved Hide resolved
code/extensions/che-telemetry/telemetry-event-service.ts Outdated Show resolved Hide resolved
code/extensions/che-telemetry/constants.ts Outdated Show resolved Hide resolved
Signed-off-by: dkwon17 <[email protected]>
@dkwon17
Copy link
Contributor Author

dkwon17 commented Oct 6, 2022

Thank you for the review @azatsarynnyy , I removed the duplicate files, updated the dependencies & extension description, and addressed the other feedback

@azatsarynnyy
Copy link
Member

@dkwon17 there are still a couple of redundant files:

  • code/extensions/che-telemetry/telemetry-0.0.1.vsix
  • code/extensions/che-telemetry/telemetry-event-service.ts

@azatsarynnyy
Copy link
Member

azatsarynnyy commented Oct 7, 2022

I tried to test it following the provided steps. I added the telemetry plugin to DevWorkspace.

Here's how it looks after adding the plugin.
apiVersion: workspace.devfile.io/v1alpha1
kind: DevWorkspace
metadata:
  annotations:
    controller.devfile.io/timing.deployment.ready: '1665137399262'
    controller.devfile.io/timing.deployment.created: '1665137389988'
    che.eclipse.org/last-updated-timestamp: '2022-10-07T10:09:49.785Z'
    controller.devfile.io/timing.routing.ready: '1665137389986'
    controller.devfile.io/timing.components.ready: '1665137389922'
    controller.devfile.io/timing.routing.created: '1665137389923'
    controller.devfile.io/timing.started: '1665137389902'
    che.eclipse.org/devfile-source: |
      scm:
        repo: 'https://github.com/dkwon17/che-code.git'
        revision: telemetryService
        fileName: devfile.yaml
      factory:
        params: 'url=https://github.com/dkwon17/che-code/tree/telemetryService'
    controller.devfile.io/timing.components.created: '1665137389902'
    che.eclipse.org/che-editor: che-incubator/che-code/insiders
  resourceVersion: '929547384'
  name: che-code
  uid: 528ff176-15e9-4208-891c-6fd120a3bd9e
  creationTimestamp: '2022-10-07T09:44:34Z'
  generation: 8
  managedFields:
    - apiVersion: workspace.devfile.io/v1alpha2
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:che.eclipse.org/che-editor': {}
            'f:che.eclipse.org/devfile-source': {}
            'f:che.eclipse.org/last-updated-timestamp': {}
        'f:spec':
          .: {}
          'f:routingClass': {}
          'f:started': {}
          'f:template':
            .: {}
            'f:attributes':
              .: {}
              'f:controller.devfile.io/devworkspace-config':
                .: {}
                'f:name': {}
                'f:namespace': {}
              'f:controller.devfile.io/storage-type': {}
              'f:dw.metadata.annotations':
                .: {}
                'f:che.eclipse.org/che-editor': {}
                'f:che.eclipse.org/devfile-source': {}
                'f:che.eclipse.org/last-updated-timestamp': {}
            'f:commands': {}
            'f:projects': {}
      manager: unknown
      operation: Update
      time: '2022-10-07T09:44:37Z'
    - apiVersion: workspace.devfile.io/v1alpha1
      fieldsType: FieldsV1
      fieldsV1:
        'f:spec':
          'f:template':
            'f:components': {}
      manager: Mozilla
      operation: Update
      time: '2022-10-07T10:05:45Z'
    - apiVersion: workspace.devfile.io/v1alpha2
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          'f:conditions': {}
          'f:message': {}
      manager: devworkspace-controller
      operation: Update
      time: '2022-10-07T10:10:01Z'
  namespace: artem-che
  finalizers:
    - storage.controller.devfile.io
  labels:
    controller.devfile.io/creator: 42925d7d-de9b-4bec-853b-f9a607279489
spec:
  routingClass: che
  started: true
  template:
    commands:
      - exec:
          commandLine: |
            yarn prepare
          component: dev
          group:
            kind: build
          id: prepare
          workingDir: '${PROJECTS_ROOT}/che-code'
      - exec:
          commandLine: |
            yarn watch
          component: dev
          group:
            isDefault: true
            kind: build
          id: build
          workingDir: '${PROJECTS_ROOT}/che-code'
      - exec:
          commandLine: |
            yarn server
          component: dev
          group:
            isDefault: true
            kind: run
          id: run
          workingDir: '${PROJECTS_ROOT}/che-code'
    components:
      - plugin:
          name: telemetry
          uri: >-
            https://gist.githubusercontent.com/dkwon17/d2f800494959dadd1106512b0c56275e/raw/5fada3206ee6dba868fd73086acc21d46682cce8/woopra-test.yaml
      - container:
          command:
            - /checode/entrypoint-volume.sh
          endpoints:
            - exposure: public
              name: dev
              protocol: http
              secure: true
              targetPort: 8000
            - attributes:
                contributed-by: che-code.eclipse.org
                cookiesAuthEnabled: ''
                discoverable: ''
                type: main
                urlRewriteSupported: ''
              exposure: public
              name: che-code
              path: '?tkn=eclipse-che'
              protocol: https
              targetPort: 3100
            - attributes:
                contributed-by: che-code.eclipse.org
                discoverable: ''
                urlRewriteSupported: ''
              exposure: public
              name: code-redirect-1
              protocol: http
              targetPort: 13131
            - attributes:
                contributed-by: che-code.eclipse.org
                discoverable: ''
                urlRewriteSupported: ''
              exposure: public
              name: code-redirect-2
              protocol: http
              targetPort: 13132
            - attributes:
                contributed-by: che-code.eclipse.org
                discoverable: ''
                urlRewriteSupported: ''
              exposure: public
              name: code-redirect-3
              protocol: http
              targetPort: 13133
          env:
            - name: CHE_DASHBOARD_URL
              value: 'https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com'
            - name: CHE_PLUGIN_REGISTRY_URL
              value: >-
                https://che-dogfooding.apps.che-dev.x6e0.p1.openshiftapps.com/plugin-registry/v3
            - name: CHE_PLUGIN_REGISTRY_INTERNAL_URL
              value: 'http://plugin-registry.dogfooding.svc:8080/v3'
            - name: OPENVSX_REGISTRY_URL
              value: 'https://open-vsx.org'
          image: 'quay.io/che-incubator/che-code-dev:insiders'
          memoryLimit: 8Gi
          name: dev
          sourceMapping: /projects
          volumeMounts:
            - name: checode
              path: /checode
      - volume:
          name: projects
          size: 3Gi
      - plugin:
          kubernetes:
            name: che-code-workspace528ff17615e94208
            namespace: artem-che
          name: che-code-workspace528ff17615e94208
    projects:
      - git:
          checkoutFrom:
            revision: telemetryService
          remotes:
            origin: 'https://github.com/dkwon17/che-code.git'
        name: che-code
status:
  conditions:
    - lastTransitionTime: '2022-10-07T10:09:49Z'
      message: DevWorkspace is starting
      status: 'True'
      type: Started
    - lastTransitionTime: '2022-10-07T10:09:49Z'
      message: Resolved plugins and parents from DevWorkspace
      status: 'True'
      type: DevWorkspaceResolved
    - lastTransitionTime: '2022-10-07T10:09:49Z'
      message: Storage ready
      status: 'True'
      type: StorageReady
    - lastTransitionTime: '2022-10-07T10:09:50Z'
      message: Networking ready
      status: 'True'
      type: RoutingReady
    - lastTransitionTime: '2022-10-07T10:09:50Z'
      message: DevWorkspace serviceaccount ready
      status: 'True'
      type: ServiceAccountReady
    - lastTransitionTime: '2022-10-07T10:09:50Z'
      message: DevWorkspace secrets ready
      status: 'True'
      type: PullSecretsReady
    - lastTransitionTime: '2022-10-07T10:10:01Z'
      message: DevWorkspace deployment ready
      status: 'True'
      type: DeploymentReady
    - lastTransitionTime: '2022-10-07T10:10:01Z'
      message: Waiting for editor to start
      status: 'False'
      type: Ready
  ideUrl: >-
    https://workspace528ff17615e94208-2.apps.che-dev.x6e0.p1.openshiftapps.com/?tkn=eclipse-che
  message: Waiting for editor to start
  phase: Starting
  workspaceId: workspace528ff17615e94208

After restarting the workspace, I got:
image

The logs from Che Dashboard:

Initializing DevWorkspace
Preparing networking
Waiting for workspace deployment
Waiting for editor to start
devworkspace failed to progress past phase 'Starting' for longer than timeout (5m)
Initializing DevWorkspace
Preparing networking
Waiting for workspace deployment
Waiting for editor to start

From the containers logs, I see that all containers are started.
Am I doing something wrong?

Note, before adding the telemetry plugin to DevWorkspace, it starts successfully.

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to test the changes in a bit different way.
I prepared a test repo https://github.com/azatsarynnyy/che-code/tree/telemetry-3, where I declared the custom editor (based on this PR) and added the telemetry plugin definition directly to the Devfile: https://github.com/dkwon17/che-code/compare/main...azatsarynnyy:che-code:telemetry-3?expand=1

After starting a DevWorkspace, I checked the logs in the telemetry plugin's container. There are expected messages:

2022-10-07 11:34:45,947 DEBUG [com.red.dev.ser.tel.woo.AnalyticsManager] (executor-thread-1) sending Refresh Workspace in Che (ip= - userAgent=) with properties: {creation time=1665140898000, devworkspace id=workspaceabe1e31c995344a6, devworkspace name=che-code, start time=1665140900999, age=
...
2022-10-07 11:35:47,083 DEBUG [com.red.dev.ser.tel.woo.AnalyticsManager] (executor-thread-1) sending Edit Workspace File in Che (ip= - userAgent=) with properties: {creation time=1665140898000, devworkspace id=workspaceabe1e31c995344a6, devworkspace name=che-code, start time=1665140900999, age=2, programming language=markdown}

@dkwon17
Copy link
Contributor Author

dkwon17 commented Oct 7, 2022

@dkwon17 there are still a couple of redundant files:

Sorry, fixed

I tried to test it following the provided steps. I added the telemetry plugin to DevWorkspace.

I was able to get your sample working by first converting it from v1alpha1 to a v1alpha2 DevWorkspace by running:

oc get devworkspace.v1alpha2.workspace.devfile.io che-code-test-4 -o yaml > output.yaml

and then in output.yaml's dev container's endpoints' attributes, I set:

cookiesAuthEnabled: true     (if exists on endpoint)
discoverable: false
urlRewriteSupported: true

since I noticed they were empty strings in the v1alpha1 DevWorkspace. I'm not sure why they were empty in the first place, maybe there is a bug? I haven't seen this issue when working on this PR

After starting a DevWorkspace, I checked the logs in the telemetry plugin's container. There are expected messages:

Looks good, thank you for checking

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good and it works as expected.
Thanks, @dkwon17!

@azatsarynnyy azatsarynnyy merged commit b0fde7b into che-incubator:main Oct 7, 2022
@che-bot che-bot added this to the 7.55 milestone Oct 7, 2022
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.

3 participants