fune/toolkit/components/glean/pytest/metrics_test_output_cpp
Jan-Erik Rediger 8321cd2247 Bug 1693486 - Implement new event extra API. r=chutten
This drops the _old_ API fully and implements support only for the new object-focused API,
regardless of `type` defintions in metrics.yaml.

The new API will look like the following examples:

Rust

    let extra = AnEventKeys {
        extra1: Some("a-value".into()),
        ..Default::default()
    };
    category::an_event.record(extra);

(Note: not optimal yet, but we can extend this with a builder-like
pattern later)

C++

    AnEventExtra extra = { .extra1 = Some("value"_ns) };
    category::an_event.Record(Some(extra));

JavaScript (actually unchanged!)

    let extra = { extra1: "value" };
    Glean.category.anEvent.record(extra);

(Note: The JavaScript API accepts strings, booleans and integers for any
extra value and will stringify them regardless of their specified type.)

Differential Revision: https://phabricator.services.mozilla.com/D114498
2021-06-02 16:07:56 +00:00

208 lines
4.6 KiB
C++

// -*- mode: C++ -*-
// AUTOGENERATED BY glean_parser. DO NOT EDIT.
/* 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/. */
#ifndef mozilla_Metrics_h
#define mozilla_Metrics_h
#include "mozilla/glean/bindings/MetricTypes.h"
#include "mozilla/Tuple.h"
#include "mozilla/Maybe.h"
#include "nsTArray.h"
#include "nsPrintfCString.h"
namespace mozilla::glean {
struct NoExtraKeys;
namespace test {
/**
* generated from test.boolean_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::BooleanMetric boolean_metric(1);
/**
* generated from test.labeled_boolean_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::BooleanMetric> labeled_boolean_metric(2);
/**
* generated from test.labeled_boolean_metric_labels
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::BooleanMetric> labeled_boolean_metric_labels(3);
/**
* generated from test.counter_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::CounterMetric counter_metric(4);
/**
* generated from test.labeled_counter_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::CounterMetric> labeled_counter_metric(5);
/**
* generated from test.labeled_counter_metric_labels
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::CounterMetric> labeled_counter_metric_labels(6);
/**
* generated from test.string_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::StringMetric string_metric(7);
/**
* generated from test.labeled_string_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::StringMetric> labeled_string_metric(8);
/**
* generated from test.labeled_string_metric_labels
*/
/**
* A multi-line
* description
*/
constexpr impl::Labeled<impl::StringMetric> labeled_string_metric_labels(9);
/**
* generated from test.string_list_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::StringListMetric string_list_metric(10);
/**
* generated from test.timespan_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::TimespanMetric timespan_metric(11);
/**
* generated from test.timing_distribution_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::TimingDistributionMetric timing_distribution_metric(12);
/**
* generated from test.memory_distribution_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::MemoryDistributionMetric memory_distribution_metric(13);
}
namespace test_nested {
/**
* generated from test.nested.uuid_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::UuidMetric uuid_metric(14);
/**
* generated from test.nested.datetime_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::DatetimeMetric datetime_metric(15);
/**
* generated from test.nested.event_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::EventMetric<NoExtraKeys> event_metric(16);
/**
* generated from test.nested.event_metric_with_extra
*/
struct EventMetricWithExtraExtra {
mozilla::Maybe<nsCString> anExtraKey;
mozilla::Maybe<nsCString> anotherExtraKey;
Tuple<nsTArray<uint32_t>, nsTArray<nsCString>> ToFfiExtra() const {
nsTArray<uint32_t> extraKeys;
nsTArray<nsCString> extraValues;
if (anExtraKey) {
extraKeys.AppendElement(0);
extraValues.EmplaceBack(anExtraKey.value());
}
if (anotherExtraKey) {
extraKeys.AppendElement(1);
extraValues.EmplaceBack(anotherExtraKey.value());
}
return MakeTuple(std::move(extraKeys), std::move(extraValues));
}
};
/**
* A multi-line
* description
*/
constexpr impl::EventMetric<EventMetricWithExtraExtra> event_metric_with_extra(17);
/**
* generated from test.nested.quantity_metric
*/
/**
* A multi-line
* description
*/
constexpr impl::QuantityMetric quantity_metric(18);
}
} // namespace mozilla::glean
#endif // mozilla_Metrics_h