Last active
July 29, 2020 00:18
-
-
Save daoshengmu/4ac9029ae7d1b04f51adac345b296bdd to your computer and use it in GitHub Desktop.
My first glean c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize Glean SDK. `uploadEnabled` can be configured according to | |
// user telemetry enable|disable setting. | |
GleanInstance.Initialize( | |
applicationId: "org.test.glean.sample", | |
applicationVersion: "1.0", | |
uploadEnabled: true, | |
configuration: new Configuration(), | |
dataDir: gleanDataDir | |
); | |
// Making a custom ping | |
var customPing = new PingType<NoReasonCodes>( | |
name: "sample", | |
includeClientId: true, | |
sendIfEmpty: false, | |
reasonCodes: null | |
); | |
// Making a string metric, it will be sent in | |
// `sample` ping. | |
var testMetric = new StringMetricType( | |
category: "test", | |
disabled: false, | |
lifetime: Lifetime.Application, | |
name: "hellow_world", | |
sendInPings: new string[] { "sample" }); | |
// Set a value to this test metric. | |
testMetric.Set("my first metric."); | |
// Submit this custom ping that include the metrics | |
// that has `sample` in sendInPings. | |
customPing.Submit(); | |
// We need to block the main process a couple of | |
// seconds to avoid it quits in order to give enought | |
// time for letting Glean ping uploader thread finishes | |
// its tasks. | |
Thread.Sleep(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment