Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

I've implemented a cutom ping to collect search data, but the ping is unkwon when glean attemping to send #13872

Closed
fpichlou opened this issue Aug 17, 2020 · 1 comment
Labels
🐞 bug Crashes, Something isn't working, .. needs:triage Issue needs triage

Comments

@fpichlou
Copy link

fpichlou commented Aug 17, 2020

I've added a custom metric in the metrics.yaml as below :

search_metric:
  query:
    type: string
    send_in_pings:
      - search-ping
    description: |
      The query string of search.
    bugs:
      - https://github.com/mozilla-mobile/android-components/issues/7865
    data_reviews:
      - https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979
    notification_emails:
      - [email protected]
    expires: "2020-10-01"

Also I've added a custom ping in the pings.yaml as below:

search-ping:
  description: |
    A ping to record search data.
  include_client_id: false
  bugs:
    - https://github.com/mozilla-mobile/fenix/issues/12345678
  data_reviews:
    - https://github.com/mozilla-mobile/fenix/pull/12345678
  notification_emails:
    - [email protected]

I've added a file for searchPing as below:

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.fenix.components.metrics

import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.*
import org.mozilla.fenix.GleanMetrics.SearchMetric
import org.mozilla.fenix.GleanMetrics.Pings

class SearchPing {
    /**
     * Fills the metrics and triggers the 'search' ping.
     */
    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    internal fun triggerPing(url: String) {
        CoroutineScope(Dispatchers.IO).launch {
            SearchMetric.query.set(url)
            Pings.searchPing.submit()
            }
    }

    /**
     * Trigger sending the `search` ping.
     */
    fun checkAndSend(url: String) {
        triggerPing(url)
    }
}


And I'm submitting the ping in the openSearchOrUrl method of SearchController class as follow:

private fun openSearchOrUrl(url: String) {
        val searchPing = SearchPing()
        searchPing.checkAndSend(url)
... 
}

What is wrong with me?

I have the following results in the logcat first when performing a search and second when closing and opening app:

2020-08-17 13:23:43.172 19752-19799/org.mozilla I/libglean_ffi: glean_core::ping: Collecting search-ping
2020-08-17 13:23:43.189 19752-19799/org.mozilla D/libglean_ffi: glean_core::ping: Storing ping 'e7bd582c-28aa-4a59-bc7e-062b56fa5522' at '/data/user/0/org.mozilla/glean_data/pending_pings/e7bd582c-28aa-4a59-bc7e-062b56fa5522'
2020-08-17 13:23:43.191 19752-19799/org.mozilla I/libglean_ffi: glean_core: The ping 'search-ping' was submitted and will be sent as soon as possible
2020-08-17 13:12:03.923 19752-19799/org.mozilla E/libglean_ffi: glean_core: Attempted to submit unknown ping 'search-ping'

┆Issue is synchronized with this Jira Task

@fpichlou fpichlou added the 🐞 bug Crashes, Something isn't working, .. label Aug 17, 2020
@github-actions github-actions bot added the needs:triage Issue needs triage label Aug 17, 2020
@liuche
Copy link
Contributor

liuche commented Aug 18, 2020

I don't think this is the right place to file this, the telemetry will go to Mozilla telemetry servers, and collecting search queries isn't an open bug in this repo.

If you would like to learn more about Glean, here is their documentation (on custom pings): https://mozilla.github.io/glean/book/user/pings/custom.html

@liuche liuche closed this as completed Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Crashes, Something isn't working, .. needs:triage Issue needs triage
Projects
None yet
Development

No branches or pull requests

2 participants