Skip to content

Commit

Permalink
Merge pull request #128 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sorobon authored Jul 4, 2024
2 parents d2d32dd + 8886cee commit 461722c
Show file tree
Hide file tree
Showing 14 changed files with 924 additions and 362 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.yml linguist-detectable=true
*.yaml linguist-detectable=true
*.html linguist-detectable=false
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---

dist: focal
language: python
python: "3.7"
python: "3.9"
os: linux
services:
- docker
before_install:
- echo '{"default-cgroupns-mode":"host"}' | sudo tee /etc/docker/daemon.json
- sudo systemctl restart docker
install:
- pip install pipenv
- pipenv sync
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## Added
- *[#125](https://github.com/idealista/tomcat_role/pull/125) (2024-01-17)- Add ".gitattributes" file for linguist detection.* @ygomezsaiz


## [Unreleased](https://github.com/idealista/tomcat_role/tree/develop)


## [1.11.0](https://github.com/idealista/tomcat_role/tree/1.11.0)
[Full Changelog](https://github.com/idealista/tomcat_role/compare/1.10.4...1.11.0)
### Added
- *[#126](https://github.com/idealista/tomcat_role/issues/126) Agent extensions support* @sorobon

## [1.10.4](https://github.com/idealista/tomcat_role/tree/1.10.4)
[Full Changelog](https://github.com/idealista/tomcat_role/compare/1.10.3...1.10.4)
### Fixed
Expand Down
19 changes: 11 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
verify_ssl = false
name = "pip_conf_index_global"

[packages]
ansible = "==2.9.14"
molecule = "==3.0.4"
docker = "==4.2.2"
ansible = "==2.9.27"
molecule = "==3.0.8"
docker = "==7.0.0"
jmespath = "==0.9.4"
lxml = "==4.6.2"
pyyaml = "==5.3.1"
requests = "<2.32.0"
ansible-lint = "==4.2.0"

[dev-packages]

[requires]
python_version = "3"
python_version = "3.9"
python_full_version = "3.9.18"
973 changes: 649 additions & 324 deletions Pipfile.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ tomcat_agents_force_reinstall: false
# - '-javaagent:{{ tomcat_install_path }}/agent_name/agent_file'
# configuration_files:
# - "configuration_file.yml"
# extensions:
# path: "{{ spring_boot_application_path }}/agent_name/extensions"
# files:
# - "ur1"
# - "url2"
# templates:
# - "deploy/agents/agent_name/extensions/extension-example.xml"
# params: {
# application_name: "application_name",
# license_key: "license_key"
Expand Down
4 changes: 2 additions & 2 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Molecule managed

{% if item.registry is defined %}
FROM --platform=linux/amd64 {{ item.registry.url }}/{{ item.image }}
FROM --platform={{ item.platform | default('amd64') }} {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM --platform=linux/amd64 {{ item.image }}
FROM --platform={{ item.platform | default('amd64') }} {{ item.image }}
{% endif %}

{% if 'stretch' in item.image %}
Expand Down
13 changes: 10 additions & 3 deletions molecule/default/group_vars/tomcat/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ tomcat_agents_required_libs:
tomcat_agents_config:
- name: "newrelic"
download_url: "http://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip"
version: "6.4.1"
version: "8.12.0"
catalina_opts:
- '-javaagent:{{ tomcat_install_path }}/newrelic/newrelic.jar'
configuration_files:
- "newrelic.yml"
extensions:
path: "{{ tomcat_install_path }}/newrelic/extensions"
files:
- "https://download.newrelic.com/newrelic/java-agent/extensions/hikaricp-2.4.0.jar"
- "https://download.newrelic.com/newrelic/java-agent/extensions/c3p0-0.9.jar"
templates:
- "tomcat/agents/newrelic/extensions/extension-example.xml"
params: {
application_name: "application_sample_name",
license_key: "sddsasd"
Expand All @@ -23,8 +30,8 @@ tomcat_agents_config:
- '-javaagent:{{ tomcat_install_path }}/datadog/dd-java-agent-0.73.0.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.service=sample -Ddd.env=molecule'
configuration_files: []
- name: "otel"
version: "1.30.0"
download_url: "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.30.0/opentelemetry-javaagent.jar"
version: "2.5.0"
download_url: "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.5.0/opentelemetry-javaagent.jar"
catalina_opts:
- '-javaagent:{{ tomcat_install_path }}/otel/opentelemetry-javaagent.jar -Dotel.javaagent.configuration-file={{ tomcat_install_path }}/otel/otel.properties'
configuration_files:
Expand Down
15 changes: 8 additions & 7 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ lint: |
platforms:
- name: tomcat
platform: amd64
groups:
- tomcat
image: ${DOCKER_IMAGE_BASE:-idealista/jdk:8u382-bullseye-temurin-jdk}
privileged: false
privileged: true
command: '/lib/systemd/systemd'
capabilities:
- SYS_ADMIN
volumes:
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
tmpfs:
- '/run'
- '/run/lock'
- '/tmp'
# volumes:
# - '/sys/fs/cgroup:/sys/fs/cgroup:ro'
# tmpfs:
# - '/run'
# - '/run/lock'
# - '/tmp'

provisioner:
name: ansible
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- This is an example of a custom instrumentation extension XML file. -->

<extension xmlns="https://newrelic.com/docs/java/xsd/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="newrelic-extension extension.xsd " name="extension-example"
version="1.0" enabled="true">
<instrumentation>

<!-- This point cut instruments some of the methods in the class com.sample.SampleArrayList. -->
<pointcut transactionStartPoint="true"
excludeFromTransactionTrace="false" ignoreTransaction="false">
<className>com.sample.SampleArrayList</className>
<!-- Instruments the method clear() -->
<method>
<name>clear</name>
<parameters />
<!-- The parameters node should be specified if there are no input parameters
and you only want to match clear(). Not specifying the parameters node will
match all methods named clear on the class regardless of the input parameters.
In other words it would match clear(int) clear(long) clear(int, long). -->
</method>
<!-- Instruments the method Object get(int index) -->
<method>
<name>get</name>
<parameters>
<!-- Primitives should written using their name: byte, short, int, long,
float, double, boolean, char -->
<type>int</type>
</parameters>
</method>
<!-- Instruments the method boolean addAll(int index, Collection c) -->
<method>
<name>addAll</name>
<parameters>
<!-- Make sure your parameters are listed in order. -->
<type>int</type>
<type>java.util.Collection</type>
</parameters>
</method>
</pointcut>

<!-- This point cut instruments some of the methods in the class com.sample.SampleString. -->
<pointcut transactionStartPoint="true">
<className>com.sample.SampleString</className>
<!-- Instruments the method boolean startsWith(String prefix) -->
<method>
<name>startsWith</name>
<parameters>
<type>java.lang.String</type>
</parameters>
</method>
<!-- Instruments the method String valueOf(char[] data, int offset, int
count) -->
<method>
<name>valueOf</name>
<parameters>
<!-- Be sure to use brackets for arrays. -->
<type>char[]</type>
<type>int</type>
<type>int</type>
</parameters>
</method>
</pointcut>


<!-- This point cut instruments all of the methods in the class com.sample.SampleString
that are named startsWith, ignoring the input parameters and return type. -->
<pointcut transactionStartPoint="true">
<className>com.sample.SampleString</className>
<method>
<name>startsWith</name>
</method>
</pointcut>


<!-- This point cut instruments the method startsWith in the class com.sample.SampleString.
By adding the <nameTransaction/> element, the class and method specified
in this pointcut will be used to name transactions which hit this pointcut.
Without this, the default convention is to name transctions with the class
and method from the transaction start point. -->
<pointcut transactionStartPoint="false">
<nameTransaction />
<className>com.sample.SampleString</className>
<!-- Instruments the method boolean startsWith(String prefix) -->
<method>
<name>startsWith</name>
<parameters>
<type>java.lang.String</type>
</parameters>
</method>
</pointcut>

<!-- This point cut instruments the method startsWith(String prefix) for
all implementations of the interface com.sample.SampleStringInterface. -->
<pointcut transactionStartPoint="true">
<interfaceName>com.sample.SampleStringInterface</interfaceName>
<!-- Instruments the method boolean startsWith(String prefix) -->
<method>
<name>startsWith</name>
<parameters>
<type>java.lang.String</type>
</parameters>
</method>
</pointcut>

<!-- This point cut instruments some of the methods in the class com.sample.SampleString
based on return type. -->
<pointcut transactionStartPoint="true">
<className>com.sample.SampleString</className>
<!-- Instruments all methods in the class whose return type is ResultSet -->
<method>
<returnType>com.example.ResultSet</returnType>
</method>
</pointcut>

<!-- This point cut instruments all of the methods which have the annotation
com.example.myAnnotation. -->
<pointcut transactionStartPoint="true">
<methodAnnotation>com.example.myAnnotation</methodAnnotation>
</pointcut>

<pointcut transactionStartPoint="true">
<className>com.sample.SampleString</className>
<traceLambda>true</traceLambda>
</pointcut>

<pointcut transactionStartPoint="true">
<className>com.sample.SampleString</className>
<traceByReturnType>Lcom/sample/SampleString;</traceByReturnType>
</pointcut>
</instrumentation>
</extension>
25 changes: 18 additions & 7 deletions molecule/default/tests/test_tomcat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ group:
tomcat:
exists: true


port:
tcp:8080:
tcp6:8080:
listening: true
tcp:8005:
tcp6:8005:
listening: true
tcp:8009:
tcp6:8009:
listening: true

file:
Expand All @@ -35,12 +36,10 @@ file:
exists: true
contains:
- '-javaagent:/opt/tomcat/newrelic/newrelic.jar'
- '-javaagent:/opt/tomcat/datadog/dd-java-agent-0.73.0.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.service=sample -Ddd.env=molecule'
- '-javaagent:/opt/tomcat/otel/opentelemetry-javaagent.jar -Dotel.javaagent.configuration-file=/opt/tomcat/otel/otel.properties'
/opt/tomcat/datadog/dd-java-agent-0.73.0.jar:
exists: true
/opt/tomcat/bin/setagentenv.sh:
exists: true
contains:
- '-javaagent:/opt/tomcat/datadog/dd-java-agent-0.73.0.jar -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.service=sample -Ddd.env=molecule'
/opt/tomcat/bin/setenv.sh:
exists: true
contains:
Expand Down Expand Up @@ -72,6 +71,18 @@ file:
exists: true
/opt/tomcat/webapps/hello-servlet.war:
exists: true
/opt/tomcat/newrelic/extensions/c3p0-0.9.jar:
exists: true
owner: tomcat
group: tomcat
/opt/tomcat/newrelic/extensions/hikaricp-2.4.0.jar:
exists: true
owner: tomcat
group: tomcat
/opt/tomcat/newrelic/extensions/extension-example.xml:
exists: true
owner: tomcat
group: tomcat

command:
java -cp /opt/tomcat/lib/catalina.jar org.apache.catalina.util.ServerInfo | grep 'Server version':
Expand Down
15 changes: 9 additions & 6 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
hosts: all
become: true
vars:
goss_version: v0.3.11
goss_arch: amd64
goss_version: v0.4.4
goss_arch: "{{ 'arm64' if ansible_facts.architecture == 'aarch64' else 'amd64'}}"
goss_dst: /usr/local/bin/goss
goss_sha256sum: 7a751c102abac61fd8dff45f87f36c3732cb5158e1414ab78e6877864fc2f7a4
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_sha256sum: "{{ 'fd76103dd6f373d48317b19542e4556cd27a06d415638561d410dfc139af19c8' if ansible_facts.architecture == 'aarch64' else '1c4f54b22fde9d4d5687939abc2606b0660a5d14a98afcd09b04b793d69acdc5'}}"
goss_url: "https://github.com/goss-org/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation
tomcat_version: "{{ molecule_yml.provisioner.inventory.group_vars.tomcat.tomcat_version }}"
goss_sleep: 1s
goss_retry_timeout: 0
tasks:
- name: Download and install Goss
get_url:
Expand All @@ -35,9 +37,10 @@
register: test_files

- name: Execute Goss tests
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }}"
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }} -s {{ goss_sleep }} -r {{ goss_retry_timeout }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true

- name: Display details about the Goss results
debug:
Expand All @@ -48,4 +51,4 @@
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
with_items: "{{ test_results.results }}"
Loading

0 comments on commit 461722c

Please sign in to comment.