Skip to content

Commit

Permalink
Add PhpMetrics (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
tidal authored Jan 23, 2022
1 parent 0f17e55 commit 61c8465
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ tests/coverage
.php-cs-fixer.cache
.phpbench
!tests/coverage/html/.gitkeep
var/metrics/
!var/metrics/.gitkeep
junit.xml
.env

# IntelliJ IDEA
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ update:
$(DC_RUN_PHP) env XDEBUG_MODE=off composer update
test: test-unit test-integration
test-unit:
$(DC_RUN_PHP) env XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite unit --colors=always --coverage-text --testdox --coverage-clover coverage.clover --coverage-html=tests/coverage/html
$(DC_RUN_PHP) env XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite unit --colors=always --coverage-text --testdox --coverage-clover coverage.clover --coverage-html=tests/coverage/html --log-junit=junit.xml
test-integration:
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpunit --testsuite integration --colors=always
test-coverage:
Expand All @@ -23,6 +23,8 @@ phpstan:
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpstan analyse
benchmark:
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpbench run --report=default
phpmetrics:
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpmetrics --config=./phpmetrics.json --junit=junit.xml
trace examples: FORCE
docker-compose up -d --remove-orphans
$(DC_RUN_PHP) php ./examples/AlwaysOnZipkinExample.php
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ make test
from your bash compatible shell. This will output the test output as well
as a test coverage analysis (text + html - see `tests/coverage/html`). Code that doesn't pass our currently defined tests will emit a failure in CI

## PhpMetrics
To generate a report showing a variety of metrics for the library and its classes, you can run:
```bash
make phpmetrics
```
This will generate a HTML PhpMetrics report in the `var/metrics` directory. Make sure to run `make test` before to create the test log-file, used by the metrics report.

## Examples

### Trace
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"phan/phan": "^5.0",
"php-http/mock-client": "^1.5",
"phpbench/phpbench": "^1.2",
"phpmetrics/phpmetrics": "^2.7",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-mockery": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand Down
47 changes: 47 additions & 0 deletions phpmetrics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"includes": [
"src"
],
"exclude": [
"tests",
"proto",
"thrift"
],
"report": {
"html": "var/metrics",
"csv": "var/metrics/metrics.csv",
"json": "var/metrics/metrics.json",
"violations": "var/metrics/violations.xml"
},
"groups": [
{
"name": "API",
"match": "!^OpenTelemetry\\\\API\\\\!i"
},
{
"name": "Context",
"match": "!^OpenTelemetry\\\\Context\\\\!i"
},
{
"name": "SDK",
"match": "!^OpenTelemetry\\\\SDK\\\\!i"
},
{
"name": "SemConv",
"match": "!^OpenTelemetry\\\\SemConv\\\\!i"
},
{
"name": "Contrib",
"match": "!^OpenTelemetry\\\\Contrib\\\\!i"
}
],
"plugins": {
"git": {
"binary": "git"
},
"junit": {
"file": "junit.xml"
}
},
"extensions": [ "php" ]
}
Empty file added var/metrics/.gitkeep
Empty file.

0 comments on commit 61c8465

Please sign in to comment.