Initial package-split setup (#531)
* Rename protobuf make target to "make protobuf" * Move otel protobuf files to 'otel' subdirectory * Add composer/package-versions-deprecated as allowed plugin * Report uncovered files in dependency check * Move PrometheusExporter to contrib package * Add missing dependency checks * Fix API dependency * Add package specific composer files * Fix wording * Add use-statement for PrometheusExporter class
This commit is contained in:
parent
4ace6c1b66
commit
2d365e6443
4
Makefile
4
Makefile
|
@ -41,14 +41,14 @@ metrics-prometheus-example:
|
||||||
@docker-compose -f docker-compose.prometheus.yaml -p opentelemetry-php_metrics-prometheus-example run --rm php php examples/prometheus/PrometheusMetricsExample.php
|
@docker-compose -f docker-compose.prometheus.yaml -p opentelemetry-php_metrics-prometheus-example run --rm php php examples/prometheus/PrometheusMetricsExample.php
|
||||||
stop-prometheus:
|
stop-prometheus:
|
||||||
@docker-compose -f docker-compose.prometheus.yaml -p opentelemetry-php_metrics-prometheus-example stop
|
@docker-compose -f docker-compose.prometheus.yaml -p opentelemetry-php_metrics-prometheus-example stop
|
||||||
proto:
|
protobuf:
|
||||||
@docker-compose -f docker-compose.proto.yaml up proto
|
@docker-compose -f docker-compose.proto.yaml up proto
|
||||||
bash:
|
bash:
|
||||||
$(DC_RUN_PHP) bash
|
$(DC_RUN_PHP) bash
|
||||||
style:
|
style:
|
||||||
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no -vvv
|
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no -vvv
|
||||||
deptrac:
|
deptrac:
|
||||||
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/deptrac --formatter=table
|
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/deptrac --formatter=table --report-uncovered
|
||||||
w3c-test-service:
|
w3c-test-service:
|
||||||
@docker-compose -f docker-compose.w3cTraceContext.yaml run --rm php ./tests/TraceContext/W3CTestService/symfony-setup
|
@docker-compose -f docker-compose.w3cTraceContext.yaml run --rm php ./tests/TraceContext/W3CTestService/symfony-setup
|
||||||
semconv:
|
semconv:
|
||||||
|
|
|
@ -160,14 +160,14 @@ PHP_VERSION=8.1 make all
|
||||||
```
|
```
|
||||||
|
|
||||||
## Proto Generation
|
## Proto Generation
|
||||||
Our proto files are committed to the repository into the `/proto` folder. These are used in gRPC connections to the
|
Our protobuf files are committed to the repository into the `/proto` folder. These are used in gRPC connections to the
|
||||||
upstream. These get updated when the [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto)
|
upstream. These get updated when the [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto)
|
||||||
repo has a meaningful update. The maintainer SIG is discussing a way to make this more automatic in the future.
|
repo has a meaningful update. The maintainer SIG is discussing a way to make this more automatic in the future.
|
||||||
|
|
||||||
If you'd like to generate proto files for use with this repository, one can run the following command:
|
If you'd like to generate protobuf files for use with this repository, one can run the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make proto
|
make protobuf
|
||||||
```
|
```
|
||||||
|
|
||||||
From your bash compatible shell in the root of this directory. This wil create a `/proto` folder in the root
|
From your bash compatible shell in the root of this directory. This wil create a `/proto` folder in the root
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
"symfony/polyfill-mbstring": "^1.23"
|
"symfony/polyfill-mbstring": "^1.23"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true
|
"sort-packages": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"composer/package-versions-deprecated": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -35,11 +38,19 @@
|
||||||
"email": "levim@php.net"
|
"email": "levim@php.net"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"replace": {
|
||||||
|
"open-telemetry/api": "self.version",
|
||||||
|
"open-telemetry/context": "self.version",
|
||||||
|
"open-telemetry/proto-otel": "self.version",
|
||||||
|
"open-telemetry/sdk": "self.version",
|
||||||
|
"open-telemetry/sdk-contrib": "self.version",
|
||||||
|
"open-telemetry/sem-conv": "self.version"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"OpenTelemetry\\": "src/",
|
"OpenTelemetry\\": "src/",
|
||||||
"Opentelemetry\\Proto\\": "proto/Opentelemetry/Proto/",
|
"Opentelemetry\\Proto\\": "proto/otel/Opentelemetry/Proto/",
|
||||||
"GPBMetadata\\Opentelemetry\\Proto\\": "proto/GPBMetadata/Opentelemetry/Proto/"
|
"GPBMetadata\\Opentelemetry\\": "proto/otel/GPBMetadata/Opentelemetry/"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/Context/fiber/initialize_fiber_handler.php"
|
"src/Context/fiber/initialize_fiber_handler.php"
|
||||||
|
|
115
depfile.yaml
115
depfile.yaml
|
@ -1,57 +1,96 @@
|
||||||
#baseline: depfile.baseline.yml
|
#baseline: depfile.baseline.yml
|
||||||
paths:
|
paths:
|
||||||
- ./src
|
- ./src
|
||||||
|
- ./proto
|
||||||
exclude_files:
|
exclude_files:
|
||||||
- '#.*test.*#'
|
- '#.*test.*#'
|
||||||
layers:
|
layers:
|
||||||
-
|
- name: API
|
||||||
name: API
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\API\\*
|
||||||
regex: OpenTelemetry\\API\\*
|
- name: SDK
|
||||||
-
|
|
||||||
name: SDK
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\SDK\\*
|
||||||
regex: OpenTelemetry\\SDK\\*
|
- name: Context
|
||||||
-
|
|
||||||
name: Context
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\Context\\*
|
||||||
regex: OpenTelemetry\\Context\\*
|
- name: SemConv
|
||||||
-
|
|
||||||
name: SemConv
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\SemConv\\*
|
||||||
regex: OpenTelemetry\\SemConv\\*
|
- name: Contrib
|
||||||
-
|
|
||||||
name: Contrib
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\Contrib\\*
|
||||||
regex: OpenTelemetry\\Contrib\\*
|
- name: OtelProto
|
||||||
-
|
|
||||||
name: Proto
|
|
||||||
collectors:
|
collectors:
|
||||||
-
|
- type: className
|
||||||
type: className
|
regex: ^OpenTelemetry\\Proto\\*
|
||||||
regex: OpenTelemetry\\Proto\\*
|
- type: className
|
||||||
|
regex: ^GPBMetadata\\Opentelemetry\\*
|
||||||
|
- name: GoogleProtobuf
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Google\\Protobuf\\*
|
||||||
|
- name: Grpc
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Grpc\\
|
||||||
|
- name: PsrLog
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Psr\\Log\\
|
||||||
|
- name: PsrHttp
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Psr\\Http\\
|
||||||
|
- name: Http
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Http\\
|
||||||
|
- name: NyholmDsn
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Nyholm\\Dsn\\
|
||||||
|
- name: Prometheus
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^Prometheus\\
|
||||||
|
- name: FFI
|
||||||
|
collectors:
|
||||||
|
- type: className
|
||||||
|
regex: ^FFI\\
|
||||||
|
|
||||||
ruleset:
|
ruleset:
|
||||||
Contrib:
|
Context:
|
||||||
- API
|
- FFI
|
||||||
- SDK
|
|
||||||
- Context
|
|
||||||
- Proto
|
|
||||||
- SemConv
|
|
||||||
Context: ~
|
|
||||||
SemConv: ~
|
SemConv: ~
|
||||||
|
API:
|
||||||
|
- Context
|
||||||
|
- SemConv
|
||||||
SDK:
|
SDK:
|
||||||
- API
|
- API
|
||||||
- Context
|
- Context
|
||||||
- SemConv
|
- SemConv
|
||||||
API:
|
- PsrLog
|
||||||
|
- PsrHttp
|
||||||
|
- Http
|
||||||
|
- NyholmDsn
|
||||||
|
OtelProto:
|
||||||
|
- GoogleProtobuf
|
||||||
|
- Grpc
|
||||||
|
Contrib:
|
||||||
|
- API
|
||||||
|
- SDK
|
||||||
- Context
|
- Context
|
||||||
|
- SemConv
|
||||||
|
- OtelProto
|
||||||
|
- Grpc
|
||||||
|
- PsrLog
|
||||||
|
- PsrHttp
|
||||||
|
- Http
|
||||||
|
- NyholmDsn
|
||||||
|
- Prometheus
|
||||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
require __DIR__ . '/../../vendor/autoload.php';
|
require __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use OpenTelemetry\Contrib\Prometheus\PrometheusExporter;
|
||||||
use OpenTelemetry\SDK\Metrics\Counter;
|
use OpenTelemetry\SDK\Metrics\Counter;
|
||||||
use OpenTelemetry\SDK\Metrics\Exporters\PrometheusExporter;
|
|
||||||
use Prometheus\CollectorRegistry;
|
use Prometheus\CollectorRegistry;
|
||||||
use Prometheus\Storage\Redis;
|
use Prometheus\Storage\Redis;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
v0.11.0
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/proto-otel",
|
||||||
|
"description": "PHP protobuf files for communication with OpenTelemetry OTLP collectors/servers.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "gRPC", "protobuf", "otlp"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0",
|
||||||
|
"google/protobuf": "^v3.3.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Opentelemetry\\Proto\\": "Opentelemetry/Proto/",
|
||||||
|
"GPBMetadata\\Opentelemetry\\": "GPBMetadata/Opentelemetry/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-protobuf": "For better performance, when dealing with the protobuf format",
|
||||||
|
"ext-grpc": "To use the gRPC based exporters"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,31 @@
|
||||||
apk update && apk add git
|
apk update && apk add git
|
||||||
|
|
||||||
mkdir /mnt/proto
|
DESTINATION_DIR=/mnt/proto/otel
|
||||||
git clone https://github.com/open-telemetry/opentelemetry-proto
|
REPO_DIR=opentelemetry-proto
|
||||||
|
|
||||||
protoc --proto_path=opentelemetry-proto/ --php_out=/mnt/proto --grpc_out=/mnt/proto --plugin=protoc-gen-grpc=usr/local/bin/grpc_php_plugin $(find opentelemetry-proto/opentelemetry -iname "*.proto")
|
mkdir -p $DESTINATION_DIR
|
||||||
|
rm -R ./$REPO_DIR
|
||||||
|
git clone https://github.com/open-telemetry/$REPO_DIR
|
||||||
|
|
||||||
|
TAG=$(
|
||||||
|
# shellcheck disable=SC2164
|
||||||
|
cd ./$REPO_DIR
|
||||||
|
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
# shellcheck disable=SC2006
|
||||||
|
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||||
|
|
||||||
|
git checkout "${TAG}"
|
||||||
|
|
||||||
|
echo "$TAG"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Generating protobuf files for version $TAG ..."
|
||||||
|
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
protoc --proto_path=$REPO_DIR/ --php_out=$DESTINATION_DIR --grpc_out=$DESTINATION_DIR \
|
||||||
|
--plugin=protoc-gen-grpc=usr/local/bin/grpc_php_plugin $(find $REPO_DIR/opentelemetry/proto -iname "*.proto")
|
||||||
|
|
||||||
|
echo "$TAG" > $DESTINATION_DIR/VERSION
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/api",
|
||||||
|
"description": "API for OpenTelemetry PHP.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "api"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0",
|
||||||
|
"open-telemetry/context": "self.version",
|
||||||
|
"open-telemetry/sem-conv": "self.version"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"OpenTelemetry\\API\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/context",
|
||||||
|
"description": "Context implementation for OpenTelemetry PHP.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "context"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"OpenTelemetry\\Context\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-ffi": "To allow context switching in Fibers"
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace OpenTelemetry\SDK\Metrics\Exporters;
|
namespace OpenTelemetry\Contrib\Prometheus;
|
||||||
|
|
||||||
use OpenTelemetry\API\Metrics as API;
|
use OpenTelemetry\API\Metrics as API;
|
||||||
use OpenTelemetry\SDK\Metrics\Counter;
|
use OpenTelemetry\SDK\Metrics\Counter;
|
||||||
use OpenTelemetry\SDK\Metrics\Exceptions\CantBeExported;
|
use OpenTelemetry\SDK\Metrics\Exceptions\CantBeExported;
|
||||||
|
use OpenTelemetry\SDK\Metrics\Exporters\AbstractExporter;
|
||||||
use Prometheus\CollectorRegistry;
|
use Prometheus\CollectorRegistry;
|
||||||
|
|
||||||
class PrometheusExporter extends AbstractExporter
|
class PrometheusExporter extends AbstractExporter
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/sdk-contrib",
|
||||||
|
"description": "Vendor specific implementations for OpenTelemetry PHP API/SDK.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "otlp", "jaeger", "zipkin", "prometheus", "newrelic"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0",
|
||||||
|
"ext-json": "*",
|
||||||
|
"nyholm/dsn": "^2.0.0",
|
||||||
|
"open-telemetry/api": "self.version",
|
||||||
|
"open-telemetry/context": "self.version",
|
||||||
|
"open-telemetry/proto-otel": "self.version",
|
||||||
|
"open-telemetry/sdk": "self.version",
|
||||||
|
"open-telemetry/sem-conv": "self.version",
|
||||||
|
"php-http/async-client-implementation": "^1.0",
|
||||||
|
"php-http/discovery": "^1.14",
|
||||||
|
"promphp/prometheus_client_php": "^2.2.1",
|
||||||
|
"psr/http-factory-implementation": "^1.0",
|
||||||
|
"psr/log": "^1.1",
|
||||||
|
"symfony/polyfill-mbstring": "^1.23"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"OpenTelemetry\\Contrib\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/sdk",
|
||||||
|
"description": "SDK for OpenTelemetry PHP.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "sdk"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0",
|
||||||
|
"ext-json": "*",
|
||||||
|
"nyholm/dsn": "^2.0.0",
|
||||||
|
"open-telemetry/api": "self.version",
|
||||||
|
"open-telemetry/context": "self.version",
|
||||||
|
"open-telemetry/sem-conv": "self.version",
|
||||||
|
"php-http/async-client-implementation": "^1.0",
|
||||||
|
"php-http/discovery": "^1.14",
|
||||||
|
"psr/http-factory-implementation": "^1.0",
|
||||||
|
"psr/log": "^1.1",
|
||||||
|
"symfony/polyfill-mbstring": "^1.23"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"OpenTelemetry\\SDK\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "To increase performance of string operations"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "open-telemetry/sem-conv",
|
||||||
|
"description": "Semantic conventions for OpenTelemetry PHP.",
|
||||||
|
"keywords": ["opentelemetry", "otel", "metrics", "tracing", "logging", "apm", "semconv", "semantic conventions"],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "opentelemetry-php contributors",
|
||||||
|
"homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.4 || ^8.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"OpenTelemetry\\SemConv\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue