Skip to content
Snippets Groups Projects
Commit 714c7604 authored by Andy Schoenen's avatar Andy Schoenen :two:
Browse files

Reverts the datadog fields DSL refactor

The refactor lead to a problem where the archive_trace_events
flag not stored in the database column but only in properties.

This way the integration would not be executed on
archive trace events

Changelog: fixed
parent 6bab48a5
No related branches found
No related tags found
1 merge request!93734Revert the Datadog fields DSL refactor
......@@ -15,75 +15,7 @@ class Datadog < Integration
TAG_KEY_VALUE_RE = %r{\A [\w-]+ : .*\S.* \z}x.freeze
field :datadog_site,
placeholder: DEFAULT_DOMAIN,
help: -> do
ERB::Util.html_escape(
s_('DatadogIntegration|The Datadog site to send data to. To send data to the EU site, use %{codeOpen}datadoghq.eu%{codeClose}.')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe
}
end
field :api_url,
title: -> { s_('DatadogIntegration|API URL') },
help: -> { s_('DatadogIntegration|(Advanced) The full URL for your Datadog site.') }
field :api_key,
type: 'password',
title: -> { _('API key') },
non_empty_password_title: -> { s_('ProjectService|Enter new API key') },
non_empty_password_help: -> { s_('ProjectService|Leave blank to use your current API key') },
help: -> do
ERB::Util.html_escape(
s_('DatadogIntegration|%{linkOpen}API key%{linkClose} used for authentication with Datadog.')
) % {
linkOpen: %Q{<a href="#{URL_API_KEYS_DOCS}" target="_blank" rel="noopener noreferrer">}.html_safe,
linkClose: '</a>'.html_safe
}
end,
required: true
field :archive_trace_events,
type: 'checkbox',
title: -> { s_('Logs') },
checkbox_label: -> { s_('Enable logs collection') },
help: -> { s_('When enabled, job logs are collected by Datadog and displayed along with pipeline execution traces.') }
field :datadog_service,
title: -> { s_('DatadogIntegration|Service') },
placeholder: 'gitlab-ci',
help: -> { s_('DatadogIntegration|Tag all data from this GitLab instance in Datadog. Useful when managing several self-managed deployments.') }
field :datadog_env,
title: -> { s_('DatadogIntegration|Environment') },
placeholder: 'ci',
help: -> do
ERB::Util.html_escape(
s_('DatadogIntegration|For self-managed deployments, set the %{codeOpen}env%{codeClose} tag for all the data sent to Datadog. %{linkOpen}How do I use tags?%{linkClose}')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe,
linkOpen: '<a href="https://docs.datadoghq.com/getting_started/tagging/#using-tags" target="_blank" rel="noopener noreferrer">'.html_safe,
linkClose: '</a>'.html_safe
}
end
field :datadog_tags,
type: 'textarea',
title: -> { s_('DatadogIntegration|Tags') },
placeholder: "tag:value\nanother_tag:value",
help: -> do
ERB::Util.html_escape(
s_('DatadogIntegration|Custom tags in Datadog. Enter one tag per line in the %{codeOpen}key:value%{codeClose} format. %{linkOpen}How do I use tags?%{linkClose}')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe,
linkOpen: '<a href="https://docs.datadoghq.com/getting_started/tagging/#using-tags" target="_blank" rel="noopener noreferrer">'.html_safe,
linkClose: '</a>'.html_safe
}
end
prop_accessor :datadog_site, :api_url, :api_key, :datadog_service, :datadog_env, :datadog_tags
before_validation :strip_properties
......@@ -145,11 +77,92 @@ def self.to_param
end
def fields
f = [
{
type: 'text',
name: 'datadog_site',
placeholder: DEFAULT_DOMAIN,
help: ERB::Util.html_escape(
s_('DatadogIntegration|The Datadog site to send data to. To send data to the EU site, use %{codeOpen}datadoghq.eu%{codeClose}.')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe
},
required: false
},
{
type: 'text',
name: 'api_url',
title: s_('DatadogIntegration|API URL'),
help: s_('DatadogIntegration|(Advanced) The full URL for your Datadog site.'),
required: false
},
{
type: 'password',
name: 'api_key',
title: _('API key'),
non_empty_password_title: s_('ProjectService|Enter new API key'),
non_empty_password_help: s_('ProjectService|Leave blank to use your current API key'),
help: ERB::Util.html_escape(
s_('DatadogIntegration|%{linkOpen}API key%{linkClose} used for authentication with Datadog.')
) % {
linkOpen: %Q{<a href="#{URL_API_KEYS_DOCS}" target="_blank" rel="noopener noreferrer">}.html_safe,
linkClose: '</a>'.html_safe
},
required: true
}
]
if Feature.enabled?(:datadog_integration_logs_collection, parent)
super
else
super.reject { _1.name == 'archive_trace_events' }
f.append({
type: 'checkbox',
name: 'archive_trace_events',
title: s_('Logs'),
checkbox_label: s_('Enable logs collection'),
help: s_('When enabled, job logs are collected by Datadog and displayed along with pipeline execution traces.'),
required: false
})
end
f += [
{
type: 'text',
name: 'datadog_service',
title: s_('DatadogIntegration|Service'),
placeholder: 'gitlab-ci',
help: s_('DatadogIntegration|Tag all data from this GitLab instance in Datadog. Useful when managing several self-managed deployments.')
},
{
type: 'text',
name: 'datadog_env',
title: s_('DatadogIntegration|Environment'),
placeholder: 'ci',
help: ERB::Util.html_escape(
s_('DatadogIntegration|For self-managed deployments, set the %{codeOpen}env%{codeClose} tag for all the data sent to Datadog. %{linkOpen}How do I use tags?%{linkClose}')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe,
linkOpen: '<a href="https://docs.datadoghq.com/getting_started/tagging/#using-tags" target="_blank" rel="noopener noreferrer">'.html_safe,
linkClose: '</a>'.html_safe
}
},
{
type: 'textarea',
name: 'datadog_tags',
title: s_('DatadogIntegration|Tags'),
placeholder: "tag:value\nanother_tag:value",
help: ERB::Util.html_escape(
s_('DatadogIntegration|Custom tags in Datadog. Enter one tag per line in the %{codeOpen}key:value%{codeClose} format. %{linkOpen}How do I use tags?%{linkClose}')
) % {
codeOpen: '<code>'.html_safe,
codeClose: '</code>'.html_safe,
linkOpen: '<a href="https://docs.datadoghq.com/getting_started/tagging/#using-tags" target="_blank" rel="noopener noreferrer">'.html_safe,
linkClose: '</a>'.html_safe
}
}
]
f
end
override :hook_url
......
......@@ -240,20 +240,4 @@
end
end
end
describe '#fields' do
it 'includes the archive_trace_events field' do
expect(instance.fields).to include(have_attributes(name: 'archive_trace_events'))
end
context 'when the FF :datadog_integration_logs_collection is disabled' do
before do
stub_feature_flags(datadog_integration_logs_collection: false)
end
it 'does not include the archive_trace_events field' do
expect(instance.fields).not_to include(have_attributes(name: 'archive_trace_events'))
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment