Skip to content

Commit c20653f

Browse files
committed
integrated dynatrace to the sdk
1 parent 34bea88 commit c20653f

31 files changed

+751
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
**/*.log
2+
**/*.md
3+
**/*.php~
4+
**/*.dist.php
5+
**/*.dist
6+
**/*.cache
7+
**/._*
8+
**/.dockerignore
9+
**/.DS_Store
10+
**/.git/
11+
**/.gitattributes
12+
**/.gitignore
13+
**/.gitmodules
14+
**/docker-compose.*.yaml
15+
**/docker-compose.*.yml
16+
**/docker-compose.yaml
17+
**/docker-compose.yml
18+
**/Dockerfile
19+
**/Thumbs.db
20+
.github/
21+
docs/
22+
public/bundles/
23+
tests/
24+
var/
25+
vendor/
26+
.editorconfig
27+
.env.*.local
28+
docker/php/.env.sample
29+
.env.local.php
30+
.env.test
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
# Change these settings to your own preference
9+
indent_style = space
10+
indent_size = 4
11+
12+
# We recommend you to keep these unchanged
13+
end_of_line = lf
14+
charset = utf-8
15+
trim_trailing_whitespace = true
16+
insert_final_newline = true
17+
18+
[*.{js,html,ts,tsx}]
19+
indent_style = space
20+
indent_size = 2
21+
22+
[*.json]
23+
indent_style = space
24+
indent_size = 2
25+
26+
[*.md]
27+
trim_trailing_whitespace = false
28+
29+
[*.php]
30+
indent_style = space
31+
indent_size = 4
32+
33+
[*.sh]
34+
indent_style = tab
35+
indent_size = 4
36+
37+
[*.xml{,.dist}]
38+
indent_style = space
39+
indent_size = 4
40+
41+
[*.{yaml,yml}]
42+
indent_style = space
43+
indent_size = 4
44+
trim_trailing_whitespace = false
45+
46+
[.github/workflows/*.yml]
47+
indent_style = space
48+
indent_size = 2
49+
50+
[.gitmodules]
51+
indent_style = tab
52+
indent_size = 4
53+
54+
[.php_cs{,.dist}]
55+
indent_style = space
56+
indent_size = 4
57+
58+
[.travis.yml]
59+
indent_style = space
60+
indent_size = 2
61+
62+
[composer.json]
63+
indent_style = space
64+
indent_size = 4
65+
66+
[docker-compose{,.*}.{yaml,yml}]
67+
indent_style = space
68+
indent_size = 2
69+
70+
[Dockerfile]
71+
indent_style = tab
72+
indent_size = 4
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
* text=auto eol=lf
2+
3+
*.conf text eol=lf
4+
*.html text eol=lf
5+
*.ini text eol=lf
6+
*.js text eol=lf
7+
*.json text eol=lf
8+
*.md text eol=lf
9+
*.php text eol=lf
10+
*.sh text eol=lf
11+
*.yaml text eol=lf
12+
*.yml text eol=lf
13+
bin/console text eol=lf
14+
15+
*.ico binary
16+
*.png binary
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
###> symfony/framework-bundle ###
3+
/docker/php/.env.local
4+
/.env.local.php
5+
/.env.*.local
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/
9+
/vendor/
10+
###< symfony/framework-bundle ###
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Symfony demo app for Dynatrace
2+
3+
This Demo is to show how PHP SDK can be used in a Symfony application for a Docker environment with monitoring tools enabled.
4+
5+
For now, we configured the docker environment for Datadog.
6+
7+
## Requirements
8+
9+
- PHP at least 8.1
10+
- Symfony 6
11+
- Docker
12+
- Registration in Dynatrace
13+
14+
## Installation
15+
16+
1. Clone/Download the example folder.
17+
2. Navigate to the path `symfony-app-dynatrace/`.
18+
19+
### Token creation
20+
1. Create the token in Dynatrace at least with PAAS scopes, "Ingest metrics" and "Read configuration" scopes.
21+
2. The token is necessary to paste it in the .env file later.
22+
23+
24+
## Using the Symfony Demo app in a Docker Environment
25+
26+
### Configuring the Demo App
27+
28+
1. Open the Terminal
29+
2. Run `composer install` or `composer update`
30+
3. Copy the [.env.sample](docker/php/.env.sample) file to the root folder renaming it to `.env`. So in the root folder run `cp docker/php/.env.sample .env`.
31+
4. Fill the `.env` file with the missing data.
32+
5. Run `composer dump-env prod`
33+
34+
### Preparing the Docker environment
35+
36+
1. Always in the Root of the project
37+
2. Run `docker compose up`
38+
3. Wait until the environment is running
39+
40+
### Navigate the application
41+
42+
1. Navigate to [http://localhost:8080/products](http://localhost:8080/products) or [http://localhost:8080/categories](http://localhost:8080/categories)
43+
2. The result would be an array objects containing products or categories.
44+
3. If it's not make sure that in Merchant Center in the project key selected (see the environment variable for the client credentials in the point 3 of the Installation section), there would be some data for products and categories.
45+
4. Go in the Dynatrace UI to see the monitoring of the API calls.
46+
47+
The docker configuration files will be found in the `docker/php` folder and the `docker-compose.yml` in the `symfony-app-dynatrace/` folder so they can be used in your application.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
9+
}
10+
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
12+
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
15+
16+
return new Application($kernel);
17+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"minimum-stability": "stable",
5+
"prefer-stable": true,
6+
"require": {
7+
"php": ">=8.1",
8+
"ext-ctype": "*",
9+
"ext-iconv": "*",
10+
"commercetools/commercetools-sdk": "^9.1",
11+
"symfony/console": "6.2.*",
12+
"symfony/dotenv": "6.2.*",
13+
"symfony/flex": "^2",
14+
"symfony/framework-bundle": "6.2.*",
15+
"symfony/runtime": "6.2.*",
16+
"symfony/yaml": "6.2.*"
17+
},
18+
"config": {
19+
"allow-plugins": {
20+
"php-http/discovery": true,
21+
"symfony/flex": true,
22+
"symfony/runtime": true
23+
},
24+
"sort-packages": true
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"App\\": "src/"
29+
}
30+
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"App\\Tests\\": "tests/"
34+
}
35+
},
36+
"replace": {
37+
"symfony/polyfill-ctype": "*",
38+
"symfony/polyfill-iconv": "*",
39+
"symfony/polyfill-php72": "*",
40+
"symfony/polyfill-php73": "*",
41+
"symfony/polyfill-php74": "*",
42+
"symfony/polyfill-php80": "*",
43+
"symfony/polyfill-php81": "*"
44+
},
45+
"scripts": {
46+
"auto-scripts": {
47+
"cache:clear": "symfony-cmd",
48+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
49+
},
50+
"post-install-cmd": [
51+
"@auto-scripts"
52+
],
53+
"post-update-cmd": [
54+
"@auto-scripts"
55+
]
56+
},
57+
"conflict": {
58+
"symfony/symfony": "*"
59+
},
60+
"extra": {
61+
"symfony": {
62+
"allow-contrib": false,
63+
"require": "6.2.*",
64+
"docker": true
65+
}
66+
}
67+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5+
];
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
framework:
2+
cache:
3+
# Unique name of your app: used to compute stable namespaces for cache keys.
4+
#prefix_seed: your_vendor_name/app_name
5+
6+
# The "app" cache stores to the filesystem by default.
7+
# The data in this cache should persist between deploys.
8+
# Other options include:
9+
10+
# Redis
11+
#app: cache.adapter.redis
12+
#default_redis_provider: redis://localhost
13+
14+
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
15+
#app: cache.adapter.apcu
16+
17+
# Namespaced pools use the above "app" backend by default
18+
#pools:
19+
#my.dedicated.cache: null
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# see https://symfony.com/doc/current/reference/configuration/framework.html
2+
framework:
3+
secret: '%env(APP_SECRET)%'
4+
#csrf_protection: true
5+
http_method_override: false
6+
handle_all_throwables: true
7+
8+
# Enables session support. Note that the session will ONLY be started if you read or write from it.
9+
# Remove or comment this section to explicitly disable session support.
10+
session:
11+
handler_id: null
12+
cookie_secure: auto
13+
cookie_samesite: lax
14+
storage_factory_id: session.storage.factory.native
15+
16+
#esi: true
17+
#fragments: true
18+
php_errors:
19+
log: true
20+
21+
when@test:
22+
framework:
23+
test: true
24+
session:
25+
storage_factory_id: session.storage.factory.mock_file

0 commit comments

Comments
 (0)