Class: Integrations::Datadog
Constant Summary
collapse
- DEFAULT_DOMAIN =
'datadoghq.com'
- URL_TEMPLATE =
'https://webhook-intake.%{datadog_domain}/api/v2/webhook'
- URL_API_KEYS_DOCS =
"https://docs.#{DEFAULT_DOMAIN}/account_management/api-app-keys/"
- SUPPORTED_EVENTS =
%w[
pipeline build archive_trace
].freeze
- TAG_KEY_VALUE_RE =
%r{\A [\w-]+ : .*\S.* \z}x
Constants inherited
from Integration
Integration::BASE_CLASSES, Integration::DEV_INTEGRATION_NAMES, Integration::INTEGRATION_NAMES, Integration::PROJECT_SPECIFIC_INTEGRATION_NAMES, Integration::SECTION_TYPE_CONFIGURATION, Integration::SECTION_TYPE_CONNECTION, Integration::SECTION_TYPE_TRIGGER, Integration::SNOWPLOW_EVENT_ACTION, Integration::SNOWPLOW_EVENT_LABEL, Integration::UnknownType
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from Importable
#imported, #importing
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HasWebHook
#execute_web_hook!, #hook_ssl_verification, #update_web_hook!
Methods inherited from Integration
#activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, available_integration_names, available_integration_types, boolean_accessor, build_from_integration, #category, #chat?, #ci?, create_from_active_default_integrations, default_integration, #default_test_event, dev_integration_names, #dup, #editable?, #event_channel_names, event_description, event_names, #event_names, field, #fields, fields, find_or_initialize_all_non_project_specific, find_or_initialize_non_project_specific_integration, #form_fields, #group_level?, #inheritable?, inherited_descendants_from_self_or_ancestors_from, instance_exists_for?, #instance_level?, integration_name_to_model, integration_name_to_type, integration_names, #json_fields, #operating?, #parent, #project_level?, project_specific_integration_names, prop_accessor, #properties=, #reencrypt_properties, #reset_updated_properties, #secret_fields, #sections, #show_active_box?, #supported_events, #supports_data_fields?, #testable?, #to_database_hash, #to_param, #updated_properties
#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!
#exposing_secrets_fields
Methods included from Loggable
#build_message, #log_error, #log_exception, #log_info, #logger
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Class Method Details
.default_test_event ⇒ Object
111
112
113
|
# File 'app/models/integrations/datadog.rb', line 111
def self.default_test_event
'pipeline'
end
|
.supported_events ⇒ Object
107
108
109
|
# File 'app/models/integrations/datadog.rb', line 107
def self.supported_events
SUPPORTED_EVENTS
end
|
.to_param ⇒ Object
137
138
139
|
# File 'app/models/integrations/datadog.rb', line 137
def self.to_param
'datadog'
end
|
Instance Method Details
#configurable_events ⇒ Object
115
116
117
118
|
# File 'app/models/integrations/datadog.rb', line 115
def configurable_events
[] end
|
#description ⇒ Object
124
125
126
|
# File 'app/models/integrations/datadog.rb', line 124
def description
s_('DatadogIntegration|Trace your GitLab pipelines with Datadog.')
end
|
#execute(data) ⇒ Object
159
160
161
162
163
164
165
166
|
# File 'app/models/integrations/datadog.rb', line 159
def execute(data)
return unless supported_events.include?(data[:object_kind])
object_kind = data[:object_kind]
object_kind = 'job' if object_kind == 'build'
data = hook_data(data, object_kind)
execute_web_hook!(data, "#{object_kind} hook")
end
|
#help ⇒ Object
128
129
130
131
132
133
134
135
|
# File 'app/models/integrations/datadog.rb', line 128
def help
docs_link = ActionController::Base.helpers.link_to(
s_('DatadogIntegration|How do I set up this integration?'),
Rails.application.routes.url_helpers.help_page_url('integration/datadog'),
target: '_blank', rel: 'noopener noreferrer'
)
s_('DatadogIntegration|Send CI/CD pipeline information to Datadog to monitor for job failures and troubleshoot performance issues. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
end
|
#hook_url ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'app/models/integrations/datadog.rb', line 142
def hook_url
url = api_url.presence || sprintf(URL_TEMPLATE, datadog_domain: datadog_domain)
url = URI.parse(url)
query = {
"dd-api-key" => 'THIS_VALUE_WILL_BE_REPLACED',
service: datadog_service.presence,
env: datadog_env.presence,
tags: datadog_tags_query_param.presence
}.compact
url.query = query.to_query
url.to_s.gsub('THIS_VALUE_WILL_BE_REPLACED', '{api_key}')
end
|
#initialize_properties ⇒ Object
101
102
103
104
105
|
# File 'app/models/integrations/datadog.rb', line 101
def initialize_properties
super
self.datadog_site ||= DEFAULT_DOMAIN
end
|
#test(data) ⇒ Object
168
169
170
171
172
173
174
175
|
# File 'app/models/integrations/datadog.rb', line 168
def test(data)
result = execute(data)
{
success: (200..299).cover?(result.payload[:http_status]),
result: result.message
}
end
|
#title ⇒ Object
120
121
122
|
# File 'app/models/integrations/datadog.rb', line 120
def title
'Datadog'
end
|
#url_variables ⇒ Object
155
156
157
|
# File 'app/models/integrations/datadog.rb', line 155
def url_variables
{ 'api_key' => api_key }
end
|