Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add datadog APM support #115

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/richie/templates/app/bc.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ spec:
source:
dockerfile: |-
FROM {{ richie_image_name }}:{{ richie_image_tag }}
# Add new statements here
USER 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why creating a BC who do nothing if we have no apm ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To take advantage of the cluster's docker repository and speed up image pulling. We only create a IS/BC for our public images that will:

  1. will be updated frequently
  2. requires further customization given a customer and an env_type

{% if is_apm_enabled -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment line because this Dockerfile extract will receive several separate augmentations?

RUN pip install ddtrace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is only for datadog so why the variable is named is_apm_enabled ?
If we use an other APM we need a new name.
I propose is_apm_datadog_enabled, if we add newrelic whe can use is_apm_newrelic_enabled.

Or we can specify the APM name on the variable, so s_apm_enabled can ave the value (false, datadog, newrelic, etc.)

CMD ddtrace-run gunicorn -c /usr/local/etc/gunicorn/richie.py richie.wsgi:application
{% endif -%}
USER 10000
triggers:
- type: "ConfigChange"
output:
Expand Down
14 changes: 14 additions & 0 deletions apps/richie/templates/app/dc.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ spec:
value: "{{ richie_host }}"
- name: ES_CLIENT
value: "richie-{{ richie_elasticsearch_host }}-{{ deployment_stamp }}"

{% if is_apm_enabled -%}
- name: DATADOG_TRACE_AGENT_HOSTNAME
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: DD_AGENT_SERVICE_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: DD_AGENT_SERVICE_PORT
value: "{{ apm_agent_port }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a default value ?

{%- endif %}

envFrom:
- secretRef:
name: richie-{{ secret_id }}
Expand Down
6 changes: 6 additions & 0 deletions group_vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ secret_id: "1.0.0"
# OpenShift's internal docker registry server
internal_docker_registry: "docker-registry.default.svc:5000"

# Set is_apm_enabled to "true" to enable APM in all apps where defined templates
# include this feature (default: "false")
is_apm_enabled: false
# APM agent port defaults to Datadog agent service port
apm_agent_port: 8126
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could omit the port when it is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default (main) value. When it's disabled, you don't need to declare this variable at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other message, you can add a default value on the BC template


# TODO: move the following settings to the redirect app
# Ports
aliases_port: 8999
Expand Down
3 changes: 3 additions & 0 deletions group_vars/env_type/preproduction.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Variables specific to the pre-production environment
richie_django_configuration: PreProduction

# Enable APM in all apps where defined templates include this feature
is_apm_enabled: true
3 changes: 3 additions & 0 deletions group_vars/env_type/production.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Variables specific to the production environment
richie_django_configuration: Production
acme_env: live

# Enable APM in all apps where defined templates include this feature
is_apm_enabled: true
3 changes: 3 additions & 0 deletions group_vars/env_type/staging.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Variables specific to the staging environment
richie_django_configuration: Staging

# Enable APM in all apps where defined templates include this feature
is_apm_enabled: true
1 change: 1 addition & 0 deletions tasks/delete_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
obj: "{{ lookup('openshift', api_version='v1', namespace=project_name, kind=item, label_selector='app=' + app.name + ',deployment_stamp=' + targeted_deployment_stamp) | zip_longest([{'kind': item}], fillvalue={'kind': item}) | list }}"
register: raw_selected_objects
loop:
- BuildConfig
- ConfigMap
- DeploymentConfig
- Job
Expand Down