Class: Gitlab::Usage::Metrics::Instrumentations::GenericMetric
- Inherits:
-
BaseMetric
- Object
- BaseMetric
- Gitlab::Usage::Metrics::Instrumentations::GenericMetric
- Defined in:
- lib/gitlab/usage/metrics/instrumentations/generic_metric.rb
Direct Known Subclasses
AkismetEnabledMetric, CertBasedClustersFfMetric, ClickHouseConfiguredMetric, CollectedDataCategoriesMetric, ContainerRegistryDbEnabledMetric, DatabaseMode, DormantUserPeriodSettingMetric, DormantUserSettingEnabledMetric, EditionMetric, GitlabConfigMetric, GitlabDedicatedMetric, GitlabEnvironmentToolkitMetric, GitlabSettingsMetric, GroupRunnerTokenExpirationEnabledMetric, HostnameMetric, IncomingEmailEncryptedSecretsEnabledMetric, IndexInconsistenciesMetric, InstallationCreationDateApproximationMetric, InstallationTypeMetric, InstanceFeatureFlagsMetric, InstanceRunnerTokenExpirationEnabledMetric, LdapEncryptedSecretsMetric, ObservabilityFeaturesFfMetric, OmniauthEnabledMetric, OperatingSystemMetric, OrphanedNamespacesMetric, PatchedFilesMetric, ProjectRunnerTokenExpirationEnabledMetric, PrometheusEnabledMetric, PrometheusMetric, PrometheusMetricsEnabledMetric, RelativeUrlInstallMetric, ReplyByEmailEnabledMetric, SchemaInconsistenciesMetric, ServiceDeskEmailEncryptedSecretsEnabledMetric, ServicePingFeaturesMetric, SmtpEncryptedSecretsMetric, SnowplowConfiguredToGitlabCollectorMetric, SnowplowEnabledMetric, SpamcheckEnabledMetric, SumNumberOfInternalEventInvocationsMetric, TestGitlabNetConnectivityMetric, UniqueInstanceIdMetric, UuidMetric, VersionMetric
Constant Summary collapse
- FALLBACK =
Usage example
class UuidMetric < GenericMetric value do Gitlab::CurrentSettings.uuid end end
-1
Constants included from TimeFrame
TimeFrame::ALL_TIME_TIME_FRAME_NAME, TimeFrame::DEFAULT_TIMESTAMP_COLUMN, TimeFrame::SEVEN_DAYS_TIME_FRAME_NAME, TimeFrame::TWENTY_EIGHT_DAYS_TIME_FRAME_NAME
Constants included from Gitlab::Utils::UsageData
Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE
Class Attribute Summary collapse
-
.metric_value ⇒ Object
readonly
Returns the value of attribute metric_value.
Attributes inherited from BaseMetric
#events, #metric_definition, #options, #time_frame
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(metric_definition) ⇒ GenericMetric
constructor
A new instance of GenericMetric.
- #value ⇒ Object
Methods inherited from BaseMetric
available?, #available?, #instrumentation
Methods included from TimeFrame
#monthly_time_range, #monthly_time_range_db_params, #weekly_time_range, #weekly_time_range_db_params
Methods included from Gitlab::Utils::UsageData
#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #metrics_collection_metadata, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Constructor Details
#initialize(metric_definition) ⇒ GenericMetric
Returns a new instance of GenericMetric.
31 32 33 |
# File 'lib/gitlab/usage/metrics/instrumentations/generic_metric.rb', line 31 def initialize(metric_definition) super(metric_definition.reverse_merge(time_frame: 'none')) end |
Class Attribute Details
.metric_value ⇒ Object (readonly)
Returns the value of attribute metric_value.
18 19 20 |
# File 'lib/gitlab/usage/metrics/instrumentations/generic_metric.rb', line 18 def metric_value @metric_value end |
Class Method Details
.fallback(custom_fallback = FALLBACK) ⇒ Object
20 21 22 23 24 |
# File 'lib/gitlab/usage/metrics/instrumentations/generic_metric.rb', line 20 def fallback(custom_fallback = FALLBACK) return @metric_fallback if defined?(@metric_fallback) @metric_fallback = custom_fallback end |
.value(&block) ⇒ Object
26 27 28 |
# File 'lib/gitlab/usage/metrics/instrumentations/generic_metric.rb', line 26 def value(&block) @metric_value = block end |
Instance Method Details
#value ⇒ Object
35 36 37 38 39 |
# File 'lib/gitlab/usage/metrics/instrumentations/generic_metric.rb', line 35 def value alt_usage_data(fallback: self.class.fallback) do instance_eval(&self.class.metric_value) end end |