public void EnsureInvalidLabelsOnLabeledStringGoToOther()
        {
            StringMetricType stringMetric = new StringMetricType(
                disabled: false,
                category: "telemetry",
                lifetime: Lifetime.Application,
                name: "labeled_string_metric",
                sendInPings: new string[] { "metrics" }
                );

            var labeledStringMetric = new LabeledMetricType <StringMetricType>(
                disabled: false,
                category: "telemetry",
                lifetime: Lifetime.Application,
                name: "labeled_string_metric",
                sendInPings: new string[] { "metrics" },
                submetric: stringMetric
                );

            labeledStringMetric["notSnakeCase"].Set("foo");
            labeledStringMetric[""].Set("foo");
            labeledStringMetric["with/slash"].Set("foo");
            labeledStringMetric["this_string_has_more_than_thirty_characters"].Set("foo");

            Assert.Equal(
                4,
                labeledStringMetric.TestGetNumRecordedErrors(
                    ErrorType.InvalidLabel
                    )
                );
            Assert.Equal(
                "foo",
                labeledStringMetric["__other__"].TestGetValue()
                );
        }
        public void TestLabeledStringMetricType()
        {
            StringMetricType stringMetric = new StringMetricType(
                disabled: false,
                category: "telemetry",
                lifetime: Lifetime.Application,
                name: "labeled_string_metric",
                sendInPings: new string[] { "metrics" }
                );

            var labeledStringMetric = new LabeledMetricType <StringMetricType>(
                disabled: false,
                category: "telemetry",
                lifetime: Lifetime.Application,
                name: "labeled_string_metric",
                sendInPings: new string[] { "metrics" },
                submetric: stringMetric
                );

            labeledStringMetric["label1"].Set("foo");
            labeledStringMetric["label2"].Set("bar");

            Assert.Equal("foo", labeledStringMetric["label1"].TestGetValue());
            Assert.Equal("bar", labeledStringMetric["label2"].TestGetValue());
        }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        // Redirect third party library logs to Unity panel.
        SystemConsoleRedirector.Redirect();

        Console.WriteLine("Begin Glean test.");

        GleanInstance.Initialize(
            applicationId: "org.mycompany.glean.tests",
            applicationVersion: "0.1",
            uploadEnabled: true,
            configuration: new Configuration(channel: "debug", maxEvents: 500),
            dataDir: "data"
            );

        // Create a custom ping.
        var ping = new PingType <NoReasonCodes>(
            name: "custom",
            includeClientId: true,
            sendIfEmpty: false,
            reasonCodes: null
            );

        // Init launch ping.
        var metric = new StringMetricType(
            category: "hello_world",
            disabled: false,
            lifetime: Lifetime.Application,
            name: "test",
            sendInPings: new string[] { "custom" }
            );

        metric.Set("my_data");
        ping.Submit();

        Console.WriteLine("End of Glean test.");
    }