Class: DeploymentMetrics
- Inherits:
-
Object
- Object
- DeploymentMetrics
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/models/deployment_metrics.rb
Instance Attribute Summary collapse
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #additional_metrics ⇒ Object
- #has_metrics? ⇒ Boolean
-
#initialize(project, deployment) ⇒ DeploymentMetrics
constructor
A new instance of DeploymentMetrics.
- #metrics ⇒ Object
Constructor Details
#initialize(project, deployment) ⇒ DeploymentMetrics
Returns a new instance of DeploymentMetrics.
10 11 12 13 |
# File 'app/models/deployment_metrics.rb', line 10 def initialize(project, deployment) @project = project @deployment = deployment end |
Instance Attribute Details
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
6 7 8 |
# File 'app/models/deployment_metrics.rb', line 6 def deployment @deployment end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
6 7 8 |
# File 'app/models/deployment_metrics.rb', line 6 def project @project end |
Instance Method Details
#additional_metrics ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/deployment_metrics.rb', line 26 def additional_metrics return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:additional_metrics_deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} end |
#has_metrics? ⇒ Boolean
15 16 17 |
# File 'app/models/deployment_metrics.rb', line 15 def has_metrics? deployment.success? && prometheus_adapter&.configured? end |
#metrics ⇒ Object
19 20 21 22 23 24 |
# File 'app/models/deployment_metrics.rb', line 19 def metrics return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} end |