diff --git a/.phan/config.php b/.phan/config.php index 5285ca791..72986eefc 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -359,10 +359,12 @@ // your application should be included in this list. 'directory_list' => [ 'src', - 'proto', + 'proto/otel/GPBMetadata', + 'proto/otel/Opentelemetry', 'thrift', 'vendor/packaged/thrift', 'vendor/composer', + 'vendor/grpc/grpc/src/lib', 'vendor/guzzlehttp', 'vendor/psr', 'vendor/php-http', diff --git a/Makefile b/Makefile index b315ae670..22157b841 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ psalm: psalm-info: $(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/psalm --show-info=true --threads=1 phpstan: - $(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpstan analyse + $(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpstan analyse --memory-limit=256M benchmark: $(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/phpbench run --report=default phpmetrics: @@ -39,9 +39,9 @@ trace examples: FORCE docker-compose run -e NEW_RELIC_ENDPOINT -e NEW_RELIC_INSERT_KEY --rm php php ./examples/AlwaysOnZipkinToNewrelicExample.php docker-compose stop collector: - docker-compose -f docker-compose-collector.yaml up -d --remove-orphans - docker-compose -f docker-compose-collector.yaml run -e OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4317 --rm php php ./examples/AlwaysOnOTLPGrpcExample2.php - docker-compose -f docker-compose-collector.yaml stop + docker-compose -f docker-compose.collector.yaml up -d --remove-orphans + docker-compose -f docker-compose.collector.yaml run -e OTEL_EXPORTER_OTLP_ENDPOINT=collector:4317 --rm php php ./examples/AlwaysOnOTLPGrpcExample.php + docker-compose -f docker-compose.collector.yaml stop fiber-ffi-example: @docker-compose -f docker-compose.fiber-ffi.yaml -p opentelemetry-php_fiber-ffi-example up -d web @@ -51,7 +51,7 @@ metrics-prometheus-example: stop-prometheus: @docker-compose -f docker-compose.prometheus.yaml -p opentelemetry-php_metrics-prometheus-example stop protobuf: - @docker-compose -f docker-compose.proto.yaml up proto + ./script/proto_gen.sh thrift: ./script/thrift_gen.sh bash: diff --git a/README.md b/README.md index c41b594b7..38cf9fb28 100644 --- a/README.md +++ b/README.md @@ -205,9 +205,8 @@ To generate protobuf files for use with this repository, you can run the followi make protobuf ``` -Change into the root of this directory. This will create a `/proto` folder in the root -directory of the -repository. +This will replace `proto/otel/Opentelemetry` and `proto/otel/GPBMetadata` with freshly generated code based on the latest +tag from `opentelemetry-proto`, which can then be committed. ## Semantic Conventions Generation diff --git a/docker-compose-collector.yaml b/docker-compose.collector.yaml similarity index 93% rename from docker-compose-collector.yaml rename to docker-compose.collector.yaml index a7aba1633..dde69085d 100644 --- a/docker-compose-collector.yaml +++ b/docker-compose.collector.yaml @@ -7,7 +7,7 @@ services: volumes: - ./:/usr/src/myapp depends_on: - - otel-collector + - collector zipkin: image: openzipkin/zipkin-slim ports: @@ -19,8 +19,7 @@ services: ports: - 9412:9412 - 16686:16686 - otel-collector: - platform: linux/amd64 + collector: image: otel/opentelemetry-collector-contrib command: ["--config=/etc/otel-collector-config.yml"] volumes: diff --git a/docker-compose.proto.yaml b/docker-compose.proto.yaml deleted file mode 100644 index 803de76d9..000000000 --- a/docker-compose.proto.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: '3.7' -services: - proto: - image: socialpoint/protobuf-tools - volumes: - - ./:/mnt - command: sh -c "/mnt/script/proto_gen.sh" diff --git a/proto/otel/.gitignore b/proto/otel/.gitignore new file mode 100644 index 000000000..b02a72bf6 --- /dev/null +++ b/proto/otel/.gitignore @@ -0,0 +1 @@ +opentelemetry-proto diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Logs/V1/LogsService.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Logs/V1/LogsService.php index 267c550d8..ac9bbb1ac 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Logs/V1/LogsService.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Logs/V1/LogsService.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Metrics/V1/MetricsService.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Metrics/V1/MetricsService.php index e641622aa..6c1abcc08 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Metrics/V1/MetricsService.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Metrics/V1/MetricsService.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Trace/V1/TraceService.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Trace/V1/TraceService.php index aa6bf4e1e..89428d535 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Trace/V1/TraceService.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Collector/Trace/V1/TraceService.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Common/V1/Common.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Common/V1/Common.php index b8a8802a6..6b973ada6 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Common/V1/Common.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Common/V1/Common.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Logs/V1/Logs.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Logs/V1/Logs.php index 1af543378..a7e879307 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Logs/V1/Logs.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Logs/V1/Logs.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/Experimental/MetricsConfigService.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/Experimental/MetricsConfigService.php index 20949ab85..398396939 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/Experimental/MetricsConfigService.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/Experimental/MetricsConfigService.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/V1/Metrics.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/V1/Metrics.php index 21cec1de5..38c0f7905 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/V1/Metrics.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Metrics/V1/Metrics.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Resource/V1/Resource.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Resource/V1/Resource.php index 5fa599f67..7e7658f5d 100644 --- a/proto/otel/GPBMetadata/Opentelemetry/Proto/Resource/V1/Resource.php +++ b/proto/otel/GPBMetadata/Opentelemetry/Proto/Resource/V1/Resource.php @@ -15,19 +15,16 @@ public static function initOnce() { return; } \GPBMetadata\Opentelemetry\Proto\Common\V1\Common::initOnce(); - $pool->internalAddGeneratedFile(hex2bin( - "0abd020a2e6f70656e74656c656d657472792f70726f746f2f7265736f75" . - "7263652f76312f7265736f757263652e70726f746f121f6f70656e74656c" . - "656d657472792e70726f746f2e7265736f757263652e763122690a085265" . - "736f75726365123b0a0a6174747269627574657318012003280b32272e6f" . - "70656e74656c656d657472792e70726f746f2e636f6d6d6f6e2e76312e4b" . - "657956616c756512200a1864726f707065645f617474726962757465735f" . - "636f756e7418022001280d42770a22696f2e6f70656e74656c656d657472" . - "792e70726f746f2e7265736f757263652e7631420d5265736f7572636550" . - "726f746f50015a406769746875622e636f6d2f6f70656e2d74656c656d65" . - "7472792f6f70656e74656c656d657472792d70726f746f2f67656e2f676f" . - "2f7265736f757263652f7631620670726f746f33" - )); + $pool->internalAddGeneratedFile( + ' +§ +.opentelemetry/proto/resource/v1/resource.protoopentelemetry.proto.resource.v1"i +Resource; + +attributes ( 2\'.opentelemetry.proto.common.v1.KeyValue +dropped_attributes_count ( Ba +"io.opentelemetry.proto.resource.v1B ResourceProtoPZ*go.opentelemetry.io/proto/otlp/resource/v1bproto3' + , true); static::$is_initialized = true; } diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/Trace.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/Trace.php index 100f24de8..b492fad4d 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/Trace.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/Trace.php differ diff --git a/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/TraceConfig.php b/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/TraceConfig.php index 81d9b675a..cf25a1656 100644 Binary files a/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/TraceConfig.php and b/proto/otel/GPBMetadata/Opentelemetry/Proto/Trace/V1/TraceConfig.php differ diff --git a/proto/otel/Opentelemetry/Proto/Collector/Logs/V1/LogsServiceClient.php b/proto/otel/Opentelemetry/Proto/Collector/Logs/V1/LogsServiceClient.php index 49211c1d2..e3249d73e 100644 --- a/proto/otel/Opentelemetry/Proto/Collector/Logs/V1/LogsServiceClient.php +++ b/proto/otel/Opentelemetry/Proto/Collector/Logs/V1/LogsServiceClient.php @@ -40,6 +40,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Opentelemetry\Proto\Collector\Logs\V1\ExportLogsServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function Export(\Opentelemetry\Proto\Collector\Logs\V1\ExportLogsServiceRequest $argument, $metadata = [], $options = []) { diff --git a/proto/otel/Opentelemetry/Proto/Collector/Metrics/V1/MetricsServiceClient.php b/proto/otel/Opentelemetry/Proto/Collector/Metrics/V1/MetricsServiceClient.php index aad4bb030..b5cddb55a 100644 --- a/proto/otel/Opentelemetry/Proto/Collector/Metrics/V1/MetricsServiceClient.php +++ b/proto/otel/Opentelemetry/Proto/Collector/Metrics/V1/MetricsServiceClient.php @@ -40,6 +40,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Opentelemetry\Proto\Collector\Metrics\V1\ExportMetricsServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function Export(\Opentelemetry\Proto\Collector\Metrics\V1\ExportMetricsServiceRequest $argument, $metadata = [], $options = []) { diff --git a/proto/otel/Opentelemetry/Proto/Collector/Trace/V1/TraceServiceClient.php b/proto/otel/Opentelemetry/Proto/Collector/Trace/V1/TraceServiceClient.php index d4d13f976..7a676b3e1 100644 --- a/proto/otel/Opentelemetry/Proto/Collector/Trace/V1/TraceServiceClient.php +++ b/proto/otel/Opentelemetry/Proto/Collector/Trace/V1/TraceServiceClient.php @@ -40,6 +40,7 @@ public function __construct($hostname, $opts, $channel = null) { * @param \Opentelemetry\Proto\Collector\Trace\V1\ExportTraceServiceRequest $argument input argument * @param array $metadata metadata * @param array $options call options + * @return \Grpc\UnaryCall */ public function Export(\Opentelemetry\Proto\Collector\Trace\V1\ExportTraceServiceRequest $argument, $metadata = [], $options = []) { diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/AnyValue.php b/proto/otel/Opentelemetry/Proto/Common/V1/AnyValue.php index 25cb4f6f0..89079de89 100644 --- a/proto/otel/Opentelemetry/Proto/Common/V1/AnyValue.php +++ b/proto/otel/Opentelemetry/Proto/Common/V1/AnyValue.php @@ -48,6 +48,11 @@ public function getStringValue() return $this->readOneof(1); } + public function hasStringValue() + { + return $this->hasOneof(1); + } + /** * Generated from protobuf field string string_value = 1; * @param string $var @@ -70,6 +75,11 @@ public function getBoolValue() return $this->readOneof(2); } + public function hasBoolValue() + { + return $this->hasOneof(2); + } + /** * Generated from protobuf field bool bool_value = 2; * @param bool $var @@ -92,6 +102,11 @@ public function getIntValue() return $this->readOneof(3); } + public function hasIntValue() + { + return $this->hasOneof(3); + } + /** * Generated from protobuf field int64 int_value = 3; * @param int|string $var @@ -114,6 +129,11 @@ public function getDoubleValue() return $this->readOneof(4); } + public function hasDoubleValue() + { + return $this->hasOneof(4); + } + /** * Generated from protobuf field double double_value = 4; * @param float $var @@ -129,13 +149,18 @@ public function setDoubleValue($var) /** * Generated from protobuf field .opentelemetry.proto.common.v1.ArrayValue array_value = 5; - * @return \Opentelemetry\Proto\Common\V1\ArrayValue + * @return \Opentelemetry\Proto\Common\V1\ArrayValue|null */ public function getArrayValue() { return $this->readOneof(5); } + public function hasArrayValue() + { + return $this->hasOneof(5); + } + /** * Generated from protobuf field .opentelemetry.proto.common.v1.ArrayValue array_value = 5; * @param \Opentelemetry\Proto\Common\V1\ArrayValue $var @@ -151,13 +176,18 @@ public function setArrayValue($var) /** * Generated from protobuf field .opentelemetry.proto.common.v1.KeyValueList kvlist_value = 6; - * @return \Opentelemetry\Proto\Common\V1\KeyValueList + * @return \Opentelemetry\Proto\Common\V1\KeyValueList|null */ public function getKvlistValue() { return $this->readOneof(6); } + public function hasKvlistValue() + { + return $this->hasOneof(6); + } + /** * Generated from protobuf field .opentelemetry.proto.common.v1.KeyValueList kvlist_value = 6; * @param \Opentelemetry\Proto\Common\V1\KeyValueList $var @@ -180,6 +210,11 @@ public function getBytesValue() return $this->readOneof(7); } + public function hasBytesValue() + { + return $this->hasOneof(7); + } + /** * Generated from protobuf field bytes bytes_value = 7; * @param string $var diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationLibrary.php b/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationLibrary.php index 1a977a8e6..7d012ad19 100644 --- a/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationLibrary.php +++ b/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationLibrary.php @@ -10,22 +10,25 @@ /** * InstrumentationLibrary is a message representing the instrumentation library information - * such as the fully qualified name and version. + * such as the fully qualified name and version. + * InstrumentationLibrary is wire-compatible with InstrumentationScope for binary + * Protobuf format. + * This message is deprecated and will be removed on June 15, 2022. * * Generated from protobuf message opentelemetry.proto.common.v1.InstrumentationLibrary */ class InstrumentationLibrary extends \Google\Protobuf\Internal\Message { /** - * An empty instrumentation library name means the name is unknown. + * An empty instrumentation library name means the name is unknown. * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Generated from protobuf field string version = 2; */ - private $version = ''; + protected $version = ''; /** * Constructor. @@ -34,7 +37,7 @@ class InstrumentationLibrary extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $name - * An empty instrumentation library name means the name is unknown. + * An empty instrumentation library name means the name is unknown. * @type string $version * } */ @@ -44,7 +47,7 @@ public function __construct($data = NULL) { } /** - * An empty instrumentation library name means the name is unknown. + * An empty instrumentation library name means the name is unknown. * * Generated from protobuf field string name = 1; * @return string @@ -55,7 +58,7 @@ public function getName() } /** - * An empty instrumentation library name means the name is unknown. + * An empty instrumentation library name means the name is unknown. * * Generated from protobuf field string name = 1; * @param string $var diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationScope.php b/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationScope.php new file mode 100644 index 000000000..ee6cc1ed7 --- /dev/null +++ b/proto/otel/Opentelemetry/Proto/Common/V1/InstrumentationScope.php @@ -0,0 +1,95 @@ +opentelemetry.proto.common.v1.InstrumentationScope + */ +class InstrumentationScope extends \Google\Protobuf\Internal\Message +{ + /** + * An empty instrumentation scope name means the name is unknown. + * + * Generated from protobuf field string name = 1; + */ + protected $name = ''; + /** + * Generated from protobuf field string version = 2; + */ + protected $version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * An empty instrumentation scope name means the name is unknown. + * @type string $version + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Opentelemetry\Proto\Common\V1\Common::initOnce(); + parent::__construct($data); + } + + /** + * An empty instrumentation scope name means the name is unknown. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * An empty instrumentation scope name means the name is unknown. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Generated from protobuf field string version = 2; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Generated from protobuf field string version = 2; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + +} + diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/KeyValue.php b/proto/otel/Opentelemetry/Proto/Common/V1/KeyValue.php index 6ca4567f2..6dfbdeb40 100644 --- a/proto/otel/Opentelemetry/Proto/Common/V1/KeyValue.php +++ b/proto/otel/Opentelemetry/Proto/Common/V1/KeyValue.php @@ -19,11 +19,11 @@ class KeyValue extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field string key = 1; */ - private $key = ''; + protected $key = ''; /** * Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue value = 2; */ - private $value = null; + protected $value = null; /** * Constructor. @@ -64,13 +64,23 @@ public function setKey($var) /** * Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue value = 2; - * @return \Opentelemetry\Proto\Common\V1\AnyValue + * @return \Opentelemetry\Proto\Common\V1\AnyValue|null */ public function getValue() { return $this->value; } + public function hasValue() + { + return isset($this->value); + } + + public function clearValue() + { + unset($this->value); + } + /** * Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue value = 2; * @param \Opentelemetry\Proto\Common\V1\AnyValue $var diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/KeyValueList.php b/proto/otel/Opentelemetry/Proto/Common/V1/KeyValueList.php index e581f862a..51fb628ae 100644 --- a/proto/otel/Opentelemetry/Proto/Common/V1/KeyValueList.php +++ b/proto/otel/Opentelemetry/Proto/Common/V1/KeyValueList.php @@ -22,6 +22,8 @@ class KeyValueList extends \Google\Protobuf\Internal\Message /** * A collection of key/value pairs of key-value pairs. The list may be empty (may * contain 0 elements). + * The keys MUST be unique (it is not allowed to have more than one + * value with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue values = 1; */ @@ -36,6 +38,8 @@ class KeyValueList extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $values * A collection of key/value pairs of key-value pairs. The list may be empty (may * contain 0 elements). + * The keys MUST be unique (it is not allowed to have more than one + * value with the same key). * } */ public function __construct($data = NULL) { @@ -46,6 +50,8 @@ public function __construct($data = NULL) { /** * A collection of key/value pairs of key-value pairs. The list may be empty (may * contain 0 elements). + * The keys MUST be unique (it is not allowed to have more than one + * value with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue values = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -58,6 +64,8 @@ public function getValues() /** * A collection of key/value pairs of key-value pairs. The list may be empty (may * contain 0 elements). + * The keys MUST be unique (it is not allowed to have more than one + * value with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue values = 1; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/proto/otel/Opentelemetry/Proto/Common/V1/StringKeyValue.php b/proto/otel/Opentelemetry/Proto/Common/V1/StringKeyValue.php index 37acf4b08..c508dd1aa 100644 --- a/proto/otel/Opentelemetry/Proto/Common/V1/StringKeyValue.php +++ b/proto/otel/Opentelemetry/Proto/Common/V1/StringKeyValue.php @@ -19,11 +19,11 @@ class StringKeyValue extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field string key = 1; */ - private $key = ''; + protected $key = ''; /** * Generated from protobuf field string value = 2; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/InstrumentationLibraryLogs.php b/proto/otel/Opentelemetry/Proto/Logs/V1/InstrumentationLibraryLogs.php index 1bd7516fb..e43654641 100644 --- a/proto/otel/Opentelemetry/Proto/Logs/V1/InstrumentationLibraryLogs.php +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/InstrumentationLibraryLogs.php @@ -10,6 +10,9 @@ /** * A collection of Logs produced by an InstrumentationLibrary. + * InstrumentationLibraryLogs is wire-compatible with ScopeLogs for binary + * Protobuf format. + * This message is deprecated and will be removed on June 15, 2022. * * Generated from protobuf message opentelemetry.proto.logs.v1.InstrumentationLibraryLogs */ @@ -22,19 +25,19 @@ class InstrumentationLibraryLogs extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; */ - private $instrumentation_library = null; + protected $instrumentation_library = null; /** - * A list of log records. + * A list of logs that originate from an instrumentation library. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; */ - private $logs; + private $log_records; /** * This schema_url applies to all logs in the "logs" field. * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -46,8 +49,8 @@ class InstrumentationLibraryLogs extends \Google\Protobuf\Internal\Message * The instrumentation library information for the logs in this message. * Semantically when InstrumentationLibrary isn't set, it is equivalent with * an empty instrumentation library name (unknown). - * @type \Opentelemetry\Proto\Logs\V1\LogRecord[]|\Google\Protobuf\Internal\RepeatedField $logs - * A list of log records. + * @type \Opentelemetry\Proto\Logs\V1\LogRecord[]|\Google\Protobuf\Internal\RepeatedField $log_records + * A list of logs that originate from an instrumentation library. * @type string $schema_url * This schema_url applies to all logs in the "logs" field. * } @@ -63,13 +66,23 @@ public function __construct($data = NULL) { * an empty instrumentation library name (unknown). * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; - * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary + * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary|null */ public function getInstrumentationLibrary() { return $this->instrumentation_library; } + public function hasInstrumentationLibrary() + { + return isset($this->instrumentation_library); + } + + public function clearInstrumentationLibrary() + { + unset($this->instrumentation_library); + } + /** * The instrumentation library information for the logs in this message. * Semantically when InstrumentationLibrary isn't set, it is equivalent with @@ -88,27 +101,27 @@ public function setInstrumentationLibrary($var) } /** - * A list of log records. + * A list of logs that originate from an instrumentation library. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; * @return \Google\Protobuf\Internal\RepeatedField */ - public function getLogs() + public function getLogRecords() { - return $this->logs; + return $this->log_records; } /** - * A list of log records. + * A list of logs that originate from an instrumentation library. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; * @param \Opentelemetry\Proto\Logs\V1\LogRecord[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setLogs($var) + public function setLogRecords($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Logs\V1\LogRecord::class); - $this->logs = $arr; + $this->log_records = $arr; return $this; } diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecord.php b/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecord.php index 5cb639338..e05c1060c 100644 --- a/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecord.php +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecord.php @@ -23,29 +23,39 @@ class LogRecord extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 1; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; + /** + * Time when the event was observed by the collection system. + * For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) + * this timestamp is typically set at the generation time and is equal to Timestamp. + * For events originating externally and collected by OpenTelemetry (e.g. using + * Collector) this is the time when OpenTelemetry's code observed the event measured + * by the clock of the OpenTelemetry code. This field MUST be set once the event is + * observed by OpenTelemetry. + * For converting OpenTelemetry log data to formats that support only one timestamp or + * when receiving OpenTelemetry log data by recipients that support only one timestamp + * internally the following logic is recommended: + * - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * Value of 0 indicates unknown or missing timestamp. + * + * Generated from protobuf field fixed64 observed_time_unix_nano = 11; + */ + protected $observed_time_unix_nano = 0; /** * Numerical value of the severity, normalized to values described in Log Data Model. * [Optional]. * * Generated from protobuf field .opentelemetry.proto.logs.v1.SeverityNumber severity_number = 2; */ - private $severity_number = 0; + protected $severity_number = 0; /** * The severity text (also known as log level). The original string representation as * it is known at the source. [Optional]. * * Generated from protobuf field string severity_text = 3; */ - private $severity_text = ''; - /** - * Short event identifier that does not contain varying parts. Name describes - * what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - * characters. Not guaranteed to be unique in any way. [Optional]. - * - * Generated from protobuf field string name = 4; - */ - private $name = ''; + protected $severity_text = ''; /** * A value containing the body of the log record. Can be for example a human-readable * string message (including multi-line) describing the event in a free form or it can @@ -53,9 +63,11 @@ class LogRecord extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue body = 5; */ - private $body = null; + protected $body = null; /** * Additional attributes that describe the specific event occurrence. [Optional]. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6; */ @@ -63,7 +75,7 @@ class LogRecord extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field uint32 dropped_attributes_count = 7; */ - private $dropped_attributes_count = 0; + protected $dropped_attributes_count = 0; /** * Flags, a bit field. 8 least significant bits are the trace flags as * defined in W3C Trace Context specification. 24 most significant bits are reserved @@ -73,7 +85,7 @@ class LogRecord extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed32 flags = 8; */ - private $flags = 0; + protected $flags = 0; /** * A unique identifier for a trace. All logs from the same trace share * the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes @@ -82,7 +94,7 @@ class LogRecord extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes trace_id = 9; */ - private $trace_id = ''; + protected $trace_id = ''; /** * A unique identifier for a span within a trace, assigned when the span * is created. The ID is an 8-byte array. An ID with all zeroes is considered @@ -91,7 +103,7 @@ class LogRecord extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes span_id = 10; */ - private $span_id = ''; + protected $span_id = ''; /** * Constructor. @@ -103,22 +115,34 @@ class LogRecord extends \Google\Protobuf\Internal\Message * time_unix_nano is the time when the event occurred. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. * Value of 0 indicates unknown or missing timestamp. + * @type int|string $observed_time_unix_nano + * Time when the event was observed by the collection system. + * For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) + * this timestamp is typically set at the generation time and is equal to Timestamp. + * For events originating externally and collected by OpenTelemetry (e.g. using + * Collector) this is the time when OpenTelemetry's code observed the event measured + * by the clock of the OpenTelemetry code. This field MUST be set once the event is + * observed by OpenTelemetry. + * For converting OpenTelemetry log data to formats that support only one timestamp or + * when receiving OpenTelemetry log data by recipients that support only one timestamp + * internally the following logic is recommended: + * - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * Value of 0 indicates unknown or missing timestamp. * @type int $severity_number * Numerical value of the severity, normalized to values described in Log Data Model. * [Optional]. * @type string $severity_text * The severity text (also known as log level). The original string representation as * it is known at the source. [Optional]. - * @type string $name - * Short event identifier that does not contain varying parts. Name describes - * what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - * characters. Not guaranteed to be unique in any way. [Optional]. * @type \Opentelemetry\Proto\Common\V1\AnyValue $body * A value containing the body of the log record. Can be for example a human-readable * string message (including multi-line) describing the event in a free form or it can * be a structured data composed of arrays and maps of other values. [Optional]. * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * Additional attributes that describe the specific event occurrence. [Optional]. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int $dropped_attributes_count * @type int $flags * Flags, a bit field. 8 least significant bits are the trace flags as @@ -173,6 +197,56 @@ public function setTimeUnixNano($var) return $this; } + /** + * Time when the event was observed by the collection system. + * For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) + * this timestamp is typically set at the generation time and is equal to Timestamp. + * For events originating externally and collected by OpenTelemetry (e.g. using + * Collector) this is the time when OpenTelemetry's code observed the event measured + * by the clock of the OpenTelemetry code. This field MUST be set once the event is + * observed by OpenTelemetry. + * For converting OpenTelemetry log data to formats that support only one timestamp or + * when receiving OpenTelemetry log data by recipients that support only one timestamp + * internally the following logic is recommended: + * - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * Value of 0 indicates unknown or missing timestamp. + * + * Generated from protobuf field fixed64 observed_time_unix_nano = 11; + * @return int|string + */ + public function getObservedTimeUnixNano() + { + return $this->observed_time_unix_nano; + } + + /** + * Time when the event was observed by the collection system. + * For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) + * this timestamp is typically set at the generation time and is equal to Timestamp. + * For events originating externally and collected by OpenTelemetry (e.g. using + * Collector) this is the time when OpenTelemetry's code observed the event measured + * by the clock of the OpenTelemetry code. This field MUST be set once the event is + * observed by OpenTelemetry. + * For converting OpenTelemetry log data to formats that support only one timestamp or + * when receiving OpenTelemetry log data by recipients that support only one timestamp + * internally the following logic is recommended: + * - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. + * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + * Value of 0 indicates unknown or missing timestamp. + * + * Generated from protobuf field fixed64 observed_time_unix_nano = 11; + * @param int|string $var + * @return $this + */ + public function setObservedTimeUnixNano($var) + { + GPBUtil::checkUint64($var); + $this->observed_time_unix_nano = $var; + + return $this; + } + /** * Numerical value of the severity, normalized to values described in Log Data Model. * [Optional]. @@ -229,49 +303,29 @@ public function setSeverityText($var) return $this; } - /** - * Short event identifier that does not contain varying parts. Name describes - * what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - * characters. Not guaranteed to be unique in any way. [Optional]. - * - * Generated from protobuf field string name = 4; - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Short event identifier that does not contain varying parts. Name describes - * what happened (e.g. "ProcessStarted"). Recommended to be no longer than 50 - * characters. Not guaranteed to be unique in any way. [Optional]. - * - * Generated from protobuf field string name = 4; - * @param string $var - * @return $this - */ - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - - return $this; - } - /** * A value containing the body of the log record. Can be for example a human-readable * string message (including multi-line) describing the event in a free form or it can * be a structured data composed of arrays and maps of other values. [Optional]. * * Generated from protobuf field .opentelemetry.proto.common.v1.AnyValue body = 5; - * @return \Opentelemetry\Proto\Common\V1\AnyValue + * @return \Opentelemetry\Proto\Common\V1\AnyValue|null */ public function getBody() { return $this->body; } + public function hasBody() + { + return isset($this->body); + } + + public function clearBody() + { + unset($this->body); + } + /** * A value containing the body of the log record. Can be for example a human-readable * string message (including multi-line) describing the event in a free form or it can @@ -291,6 +345,8 @@ public function setBody($var) /** * Additional attributes that describe the specific event occurrence. [Optional]. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6; * @return \Google\Protobuf\Internal\RepeatedField @@ -302,6 +358,8 @@ public function getAttributes() /** * Additional attributes that describe the specific event occurrence. [Optional]. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 6; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecordFlags.php b/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecordFlags.php index 8f4664868..992740091 100644 --- a/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecordFlags.php +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/LogRecordFlags.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Logs\V1; +use UnexpectedValueException; + /** * Masks for LogRecord.flags field. * @@ -19,5 +21,30 @@ class LogRecordFlags * Generated from protobuf enum LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 255; */ const LOG_RECORD_FLAG_TRACE_FLAGS_MASK = 255; + + private static $valueToName = [ + self::LOG_RECORD_FLAG_UNSPECIFIED => 'LOG_RECORD_FLAG_UNSPECIFIED', + self::LOG_RECORD_FLAG_TRACE_FLAGS_MASK => 'LOG_RECORD_FLAG_TRACE_FLAGS_MASK', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/ResourceLogs.php b/proto/otel/Opentelemetry/Proto/Logs/V1/ResourceLogs.php index 724b98afb..70b399b61 100644 --- a/proto/otel/Opentelemetry/Proto/Logs/V1/ResourceLogs.php +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/ResourceLogs.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A collection of InstrumentationLibraryLogs from a Resource. + * A collection of ScopeLogs from a Resource. * * Generated from protobuf message opentelemetry.proto.logs.v1.ResourceLogs */ @@ -21,21 +21,48 @@ class ResourceLogs extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; */ - private $resource = null; + protected $resource = null; + /** + * A list of ScopeLogs that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.ScopeLogs scope_logs = 2; + */ + private $scope_logs; /** * A list of InstrumentationLibraryLogs that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_logs. Instead + * scope_logs SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_logs is set + * and scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_logs field MAY also set + * scope_logs to carry the same logs, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_logs and + * SHOULD NOT set instrumentation_library_logs. + * JSON receivers SHOULD check if instrumentation_library_logs is set and + * scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 1000 [deprecated = true]; + * @deprecated */ private $instrumentation_library_logs; /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_logs" field which have their own - * schema_url field. + * to the data in the "scope_logs" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -46,12 +73,34 @@ class ResourceLogs extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Resource\V1\Resource $resource * The resource for the logs in this message. * If this field is not set then resource info is unknown. + * @type \Opentelemetry\Proto\Logs\V1\ScopeLogs[]|\Google\Protobuf\Internal\RepeatedField $scope_logs + * A list of ScopeLogs that originate from a resource. * @type \Opentelemetry\Proto\Logs\V1\InstrumentationLibraryLogs[]|\Google\Protobuf\Internal\RepeatedField $instrumentation_library_logs * A list of InstrumentationLibraryLogs that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_logs. Instead + * scope_logs SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_logs is set + * and scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_logs field MAY also set + * scope_logs to carry the same logs, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_logs and + * SHOULD NOT set instrumentation_library_logs. + * JSON receivers SHOULD check if instrumentation_library_logs is set and + * scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs field SHOULD be ignored. * @type string $schema_url * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_logs" field which have their own - * schema_url field. + * to the data in the "scope_logs" field which have their own schema_url field. * } */ public function __construct($data = NULL) { @@ -64,13 +113,23 @@ public function __construct($data = NULL) { * If this field is not set then resource info is unknown. * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; - * @return \Opentelemetry\Proto\Resource\V1\Resource + * @return \Opentelemetry\Proto\Resource\V1\Resource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); + } + /** * The resource for the logs in this message. * If this field is not set then resource info is unknown. @@ -87,26 +146,98 @@ public function setResource($var) return $this; } + /** + * A list of ScopeLogs that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.ScopeLogs scope_logs = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getScopeLogs() + { + return $this->scope_logs; + } + + /** + * A list of ScopeLogs that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.ScopeLogs scope_logs = 2; + * @param \Opentelemetry\Proto\Logs\V1\ScopeLogs[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setScopeLogs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Logs\V1\ScopeLogs::class); + $this->scope_logs = $arr; + + return $this; + } + /** * A list of InstrumentationLibraryLogs that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_logs. Instead + * scope_logs SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_logs is set + * and scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_logs field MAY also set + * scope_logs to carry the same logs, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_logs and + * SHOULD NOT set instrumentation_library_logs. + * JSON receivers SHOULD check if instrumentation_library_logs is set and + * scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 1000 [deprecated = true]; * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated */ public function getInstrumentationLibraryLogs() { + @trigger_error('instrumentation_library_logs is deprecated.', E_USER_DEPRECATED); return $this->instrumentation_library_logs; } /** * A list of InstrumentationLibraryLogs that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_logs. Instead + * scope_logs SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_logs is set + * and scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_logs field MAY also set + * scope_logs to carry the same logs, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_logs and + * SHOULD NOT set instrumentation_library_logs. + * JSON receivers SHOULD check if instrumentation_library_logs is set and + * scope_logs is not set then the value in instrumentation_library_logs + * SHOULD be used instead by converting InstrumentationLibraryLogs into ScopeLogs. + * If scope_logs is set then instrumentation_library_logs field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 2; + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.InstrumentationLibraryLogs instrumentation_library_logs = 1000 [deprecated = true]; * @param \Opentelemetry\Proto\Logs\V1\InstrumentationLibraryLogs[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this + * @deprecated */ public function setInstrumentationLibraryLogs($var) { + @trigger_error('instrumentation_library_logs is deprecated.', E_USER_DEPRECATED); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Logs\V1\InstrumentationLibraryLogs::class); $this->instrumentation_library_logs = $arr; @@ -115,8 +246,7 @@ public function setInstrumentationLibraryLogs($var) /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_logs" field which have their own - * schema_url field. + * to the data in the "scope_logs" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @return string @@ -128,8 +258,7 @@ public function getSchemaUrl() /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_logs" field which have their own - * schema_url field. + * to the data in the "scope_logs" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @param string $var diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/ScopeLogs.php b/proto/otel/Opentelemetry/Proto/Logs/V1/ScopeLogs.php new file mode 100644 index 000000000..8c5a94821 --- /dev/null +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/ScopeLogs.php @@ -0,0 +1,153 @@ +opentelemetry.proto.logs.v1.ScopeLogs + */ +class ScopeLogs extends \Google\Protobuf\Internal\Message +{ + /** + * The instrumentation scope information for the logs in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + */ + protected $scope = null; + /** + * A list of log records. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; + */ + private $log_records; + /** + * This schema_url applies to all logs in the "logs" field. + * + * Generated from protobuf field string schema_url = 3; + */ + protected $schema_url = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Opentelemetry\Proto\Common\V1\InstrumentationScope $scope + * The instrumentation scope information for the logs in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * @type \Opentelemetry\Proto\Logs\V1\LogRecord[]|\Google\Protobuf\Internal\RepeatedField $log_records + * A list of log records. + * @type string $schema_url + * This schema_url applies to all logs in the "logs" field. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Opentelemetry\Proto\Logs\V1\Logs::initOnce(); + parent::__construct($data); + } + + /** + * The instrumentation scope information for the logs in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @return \Opentelemetry\Proto\Common\V1\InstrumentationScope|null + */ + public function getScope() + { + return $this->scope; + } + + public function hasScope() + { + return isset($this->scope); + } + + public function clearScope() + { + unset($this->scope); + } + + /** + * The instrumentation scope information for the logs in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @param \Opentelemetry\Proto\Common\V1\InstrumentationScope $var + * @return $this + */ + public function setScope($var) + { + GPBUtil::checkMessage($var, \Opentelemetry\Proto\Common\V1\InstrumentationScope::class); + $this->scope = $var; + + return $this; + } + + /** + * A list of log records. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getLogRecords() + { + return $this->log_records; + } + + /** + * A list of log records. + * + * Generated from protobuf field repeated .opentelemetry.proto.logs.v1.LogRecord log_records = 2; + * @param \Opentelemetry\Proto\Logs\V1\LogRecord[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setLogRecords($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Logs\V1\LogRecord::class); + $this->log_records = $arr; + + return $this; + } + + /** + * This schema_url applies to all logs in the "logs" field. + * + * Generated from protobuf field string schema_url = 3; + * @return string + */ + public function getSchemaUrl() + { + return $this->schema_url; + } + + /** + * This schema_url applies to all logs in the "logs" field. + * + * Generated from protobuf field string schema_url = 3; + * @param string $var + * @return $this + */ + public function setSchemaUrl($var) + { + GPBUtil::checkString($var, True); + $this->schema_url = $var; + + return $this; + } + +} + diff --git a/proto/otel/Opentelemetry/Proto/Logs/V1/SeverityNumber.php b/proto/otel/Opentelemetry/Proto/Logs/V1/SeverityNumber.php index 4d22d9b5b..ad89442b0 100644 --- a/proto/otel/Opentelemetry/Proto/Logs/V1/SeverityNumber.php +++ b/proto/otel/Opentelemetry/Proto/Logs/V1/SeverityNumber.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Logs\V1; +use UnexpectedValueException; + /** * Possible values for LogRecord.SeverityNumber. * @@ -113,5 +115,53 @@ class SeverityNumber * Generated from protobuf enum SEVERITY_NUMBER_FATAL4 = 24; */ const SEVERITY_NUMBER_FATAL4 = 24; + + private static $valueToName = [ + self::SEVERITY_NUMBER_UNSPECIFIED => 'SEVERITY_NUMBER_UNSPECIFIED', + self::SEVERITY_NUMBER_TRACE => 'SEVERITY_NUMBER_TRACE', + self::SEVERITY_NUMBER_TRACE2 => 'SEVERITY_NUMBER_TRACE2', + self::SEVERITY_NUMBER_TRACE3 => 'SEVERITY_NUMBER_TRACE3', + self::SEVERITY_NUMBER_TRACE4 => 'SEVERITY_NUMBER_TRACE4', + self::SEVERITY_NUMBER_DEBUG => 'SEVERITY_NUMBER_DEBUG', + self::SEVERITY_NUMBER_DEBUG2 => 'SEVERITY_NUMBER_DEBUG2', + self::SEVERITY_NUMBER_DEBUG3 => 'SEVERITY_NUMBER_DEBUG3', + self::SEVERITY_NUMBER_DEBUG4 => 'SEVERITY_NUMBER_DEBUG4', + self::SEVERITY_NUMBER_INFO => 'SEVERITY_NUMBER_INFO', + self::SEVERITY_NUMBER_INFO2 => 'SEVERITY_NUMBER_INFO2', + self::SEVERITY_NUMBER_INFO3 => 'SEVERITY_NUMBER_INFO3', + self::SEVERITY_NUMBER_INFO4 => 'SEVERITY_NUMBER_INFO4', + self::SEVERITY_NUMBER_WARN => 'SEVERITY_NUMBER_WARN', + self::SEVERITY_NUMBER_WARN2 => 'SEVERITY_NUMBER_WARN2', + self::SEVERITY_NUMBER_WARN3 => 'SEVERITY_NUMBER_WARN3', + self::SEVERITY_NUMBER_WARN4 => 'SEVERITY_NUMBER_WARN4', + self::SEVERITY_NUMBER_ERROR => 'SEVERITY_NUMBER_ERROR', + self::SEVERITY_NUMBER_ERROR2 => 'SEVERITY_NUMBER_ERROR2', + self::SEVERITY_NUMBER_ERROR3 => 'SEVERITY_NUMBER_ERROR3', + self::SEVERITY_NUMBER_ERROR4 => 'SEVERITY_NUMBER_ERROR4', + self::SEVERITY_NUMBER_FATAL => 'SEVERITY_NUMBER_FATAL', + self::SEVERITY_NUMBER_FATAL2 => 'SEVERITY_NUMBER_FATAL2', + self::SEVERITY_NUMBER_FATAL3 => 'SEVERITY_NUMBER_FATAL3', + self::SEVERITY_NUMBER_FATAL4 => 'SEVERITY_NUMBER_FATAL4', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } diff --git a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigClient.php b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigClient.php deleted file mode 100644 index b2dca8b6d..000000000 --- a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigClient.php +++ /dev/null @@ -1,53 +0,0 @@ -_simpleRequest('/opentelemetry.proto.metrics.experimental.MetricConfig/GetMetricConfig', - $argument, - ['\Opentelemetry\Proto\Metrics\Experimental\MetricConfigResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigRequest.php b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigRequest.php index d1288f05b..bdf9ea2fa 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigRequest.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigRequest.php @@ -18,14 +18,14 @@ class MetricConfigRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; */ - private $resource = null; + protected $resource = null; /** * Optional. The value of MetricConfigResponse.fingerprint for the last * configuration that the caller received and successfully applied. * * Generated from protobuf field bytes last_known_fingerprint = 2; */ - private $last_known_fingerprint = ''; + protected $last_known_fingerprint = ''; /** * Constructor. @@ -53,7 +53,17 @@ public function __construct($data = NULL) { */ public function getResource() { - return $this->resource; + return isset($this->resource) ? $this->resource : null; + } + + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); } /** diff --git a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse.php b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse.php index ba5f7216f..0993a59ea 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse.php @@ -29,7 +29,7 @@ class MetricConfigResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes fingerprint = 1; */ - private $fingerprint = ''; + protected $fingerprint = ''; /** * A single metric may match multiple schedules. In such cases, the schedule * that specifies the smallest period is applied. @@ -47,7 +47,7 @@ class MetricConfigResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 suggested_wait_time_sec = 3; */ - private $suggested_wait_time_sec = 0; + protected $suggested_wait_time_sec = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule.php b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule.php index 4e825dc2a..07091928d 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule.php @@ -36,7 +36,7 @@ class Schedule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 period_sec = 3; */ - private $period_sec = 0; + protected $period_sec = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule/Pattern.php b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule/Pattern.php index 131a0a839..839c097fb 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule/Pattern.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/Experimental/MetricConfigResponse/Schedule/Pattern.php @@ -47,6 +47,11 @@ public function getEquals() return $this->readOneof(1); } + public function hasEquals() + { + return $this->hasOneof(1); + } + /** * matches the metric name exactly * @@ -73,6 +78,11 @@ public function getStartsWith() return $this->readOneof(2); } + public function hasStartsWith() + { + return $this->hasOneof(2); + } + /** * prefix-matches the metric name * diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/AggregationTemporality.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/AggregationTemporality.php index fb791cc71..93fb0ea97 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/AggregationTemporality.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/AggregationTemporality.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Metrics\V1; +use UnexpectedValueException; + /** * AggregationTemporality defines how a metric aggregator reports aggregated * values. It describes how those values relate to the time interval over @@ -82,5 +84,31 @@ class AggregationTemporality * Generated from protobuf enum AGGREGATION_TEMPORALITY_CUMULATIVE = 2; */ const AGGREGATION_TEMPORALITY_CUMULATIVE = 2; + + private static $valueToName = [ + self::AGGREGATION_TEMPORALITY_UNSPECIFIED => 'AGGREGATION_TEMPORALITY_UNSPECIFIED', + self::AGGREGATION_TEMPORALITY_DELTA => 'AGGREGATION_TEMPORALITY_DELTA', + self::AGGREGATION_TEMPORALITY_CUMULATIVE => 'AGGREGATION_TEMPORALITY_CUMULATIVE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/DataPointFlags.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/DataPointFlags.php index 3009c2483..f0f082b46 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/DataPointFlags.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/DataPointFlags.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Metrics\V1; +use UnexpectedValueException; + /** * DataPointFlags is defined as a protobuf 'uint32' type and is to be used as a * bit-field representing 32 distinct boolean flags. Each flag defined in this @@ -27,5 +29,30 @@ class DataPointFlags * Generated from protobuf enum FLAG_NO_RECORDED_VALUE = 1; */ const FLAG_NO_RECORDED_VALUE = 1; + + private static $valueToName = [ + self::FLAG_NONE => 'FLAG_NONE', + self::FLAG_NO_RECORDED_VALUE => 'FLAG_NO_RECORDED_VALUE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/Exemplar.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/Exemplar.php index 32263d7bd..a0387ede1 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/Exemplar.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/Exemplar.php @@ -26,19 +26,6 @@ class Exemplar extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue filtered_attributes = 7; */ private $filtered_attributes; - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `filtered_labels` field. - * 2. New senders, which are aware of this change MUST send only - * `filtered_attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `filtered_labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue filtered_labels = 1 [deprecated = true]; - */ - private $filtered_labels; /** * time_unix_nano is the exact time when this exemplar was recorded * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -46,7 +33,7 @@ class Exemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 2; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * (Optional) Span ID of the exemplar trace. * span_id may be missing if the measurement is not recorded inside a trace @@ -54,7 +41,7 @@ class Exemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes span_id = 4; */ - private $span_id = ''; + protected $span_id = ''; /** * (Optional) Trace ID of the exemplar trace. * trace_id may be missing if the measurement is not recorded inside a trace @@ -62,7 +49,7 @@ class Exemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes trace_id = 5; */ - private $trace_id = ''; + protected $trace_id = ''; protected $value; /** @@ -75,15 +62,6 @@ class Exemplar extends \Google\Protobuf\Internal\Message * The set of key/value pairs that were filtered out by the aggregator, but * recorded alongside the original measurement. Only key/value pairs that were * filtered out by the aggregator should be included - * @type \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $filtered_labels - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `filtered_labels` field. - * 2. New senders, which are aware of this change MUST send only - * `filtered_attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `filtered_labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. * @type int|string $time_unix_nano * time_unix_nano is the exact time when this exemplar was recorded * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -135,46 +113,6 @@ public function setFilteredAttributes($var) return $this; } - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `filtered_labels` field. - * 2. New senders, which are aware of this change MUST send only - * `filtered_attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `filtered_labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue filtered_labels = 1 [deprecated = true]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getFilteredLabels() - { - return $this->filtered_labels; - } - - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `filtered_labels` field. - * 2. New senders, which are aware of this change MUST send only - * `filtered_attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `filtered_labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue filtered_labels = 1 [deprecated = true]; - * @param \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setFilteredLabels($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Common\V1\StringKeyValue::class); - $this->filtered_labels = $arr; - - return $this; - } - /** * time_unix_nano is the exact time when this exemplar was recorded * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -214,6 +152,11 @@ public function getAsDouble() return $this->readOneof(3); } + public function hasAsDouble() + { + return $this->hasOneof(3); + } + /** * Generated from protobuf field double as_double = 3; * @param float $var @@ -236,6 +179,11 @@ public function getAsInt() return $this->readOneof(6); } + public function hasAsInt() + { + return $this->hasOneof(6); + } + /** * Generated from protobuf field sfixed64 as_int = 6; * @param int|string $var diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogram.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogram.php index d8bd7a60e..2a5c4cc90 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogram.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogram.php @@ -26,7 +26,7 @@ class ExponentialHistogram extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.metrics.v1.AggregationTemporality aggregation_temporality = 2; */ - private $aggregation_temporality = 0; + protected $aggregation_temporality = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint.php index a3738bb67..2ad3ee655 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint.php @@ -21,6 +21,8 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; */ @@ -33,7 +35,7 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -41,7 +43,7 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * count is the number of values in the population. Must be * non-negative. This value must be equal to the sum of the "bucket_counts" @@ -49,7 +51,7 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 count = 4; */ - private $count = 0; + protected $count = 0; /** * sum of the values in the population. If count is zero then this field * must be zero. @@ -61,7 +63,7 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double sum = 5; */ - private $sum = 0.0; + protected $sum = 0.0; /** * scale describes the resolution of the histogram. Boundaries are * located at powers of the base, where: @@ -77,7 +79,7 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field sint32 scale = 6; */ - private $scale = 0; + protected $scale = 0; /** * zero_count is the count of values that are either exactly zero or * within the region considered zero by the instrumentation at the @@ -89,26 +91,26 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 zero_count = 7; */ - private $zero_count = 0; + protected $zero_count = 0; /** * positive carries the positive range of exponential bucket counts. * * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets positive = 8; */ - private $positive = null; + protected $positive = null; /** * negative carries the negative range of exponential bucket counts. * * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets negative = 9; */ - private $negative = null; + protected $negative = null; /** * Flags that apply to this specific data point. See DataPointFlags * for the available flags and their meaning. * * Generated from protobuf field uint32 flags = 10; */ - private $flags = 0; + protected $flags = 0; /** * (Optional) List of exemplars collected from * measurements that were used to form the data point @@ -126,6 +128,8 @@ class ExponentialHistogramDataPoint extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int|string $start_time_unix_nano * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -187,6 +191,8 @@ public function __construct($data = NULL) { /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -199,6 +205,8 @@ public function getAttributes() /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var @@ -430,13 +438,23 @@ public function setZeroCount($var) * positive carries the positive range of exponential bucket counts. * * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets positive = 8; - * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets + * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets|null */ public function getPositive() { return $this->positive; } + public function hasPositive() + { + return isset($this->positive); + } + + public function clearPositive() + { + unset($this->positive); + } + /** * positive carries the positive range of exponential bucket counts. * @@ -446,7 +464,7 @@ public function getPositive() */ public function setPositive($var) { - GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint_Buckets::class); + GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets::class); $this->positive = $var; return $this; @@ -456,13 +474,23 @@ public function setPositive($var) * negative carries the negative range of exponential bucket counts. * * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets negative = 9; - * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets + * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets|null */ public function getNegative() { return $this->negative; } + public function hasNegative() + { + return isset($this->negative); + } + + public function clearNegative() + { + unset($this->negative); + } + /** * negative carries the negative range of exponential bucket counts. * @@ -472,7 +500,7 @@ public function getNegative() */ public function setNegative($var) { - GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint_Buckets::class); + GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\ExponentialHistogramDataPoint\Buckets::class); $this->negative = $var; return $this; diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint/Buckets.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint/Buckets.php index ff70f73a9..b9e7f0199 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint/Buckets.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/ExponentialHistogramDataPoint/Buckets.php @@ -23,7 +23,7 @@ class Buckets extends \Google\Protobuf\Internal\Message * * Generated from protobuf field sint32 offset = 1; */ - private $offset = 0; + protected $offset = 0; /** * Count is an array of counts, where count[i] carries the count * of the bucket at index (offset+i). count[i] is the count of diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/Histogram.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/Histogram.php index f62a10340..e6643b89e 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/Histogram.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/Histogram.php @@ -26,7 +26,7 @@ class Histogram extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.metrics.v1.AggregationTemporality aggregation_temporality = 2; */ - private $aggregation_temporality = 0; + protected $aggregation_temporality = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/HistogramDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/HistogramDataPoint.php index fb5f40be5..2d2933c4a 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/HistogramDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/HistogramDataPoint.php @@ -26,22 +26,12 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; */ private $attributes; - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - */ - private $labels; /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -50,7 +40,7 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -58,7 +48,7 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * count is the number of values in the population. Must be non-negative. This * value must be equal to the sum of the "count" fields in buckets if a @@ -66,7 +56,7 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 count = 4; */ - private $count = 0; + protected $count = 0; /** * sum of the values in the population. If count is zero then this field * must be zero. @@ -76,9 +66,9 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * doing so. This is specifically to enforce compatibility w/ OpenMetrics, * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram * - * Generated from protobuf field double sum = 5; + * Generated from protobuf field optional double sum = 5; */ - private $sum = 0.0; + protected $sum = null; /** * bucket_counts is an optional field contains the count values of histogram * for each bucket. @@ -116,7 +106,7 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 flags = 10; */ - private $flags = 0; + protected $flags = 0; /** * Constructor. @@ -127,14 +117,8 @@ class HistogramDataPoint extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). - * @type \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $labels - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int|string $start_time_unix_nano * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -188,6 +172,8 @@ public function __construct($data = NULL) { /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; * @return \Google\Protobuf\Internal\RepeatedField @@ -200,6 +186,8 @@ public function getAttributes() /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var @@ -213,44 +201,6 @@ public function setAttributes($var) return $this; } - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @param \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Common\V1\StringKeyValue::class); - $this->labels = $arr; - - return $this; - } - /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -352,12 +302,22 @@ public function setCount($var) * doing so. This is specifically to enforce compatibility w/ OpenMetrics, * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram * - * Generated from protobuf field double sum = 5; + * Generated from protobuf field optional double sum = 5; * @return float */ public function getSum() { - return $this->sum; + return isset($this->sum) ? $this->sum : 0.0; + } + + public function hasSum() + { + return isset($this->sum); + } + + public function clearSum() + { + unset($this->sum); } /** @@ -369,7 +329,7 @@ public function getSum() * doing so. This is specifically to enforce compatibility w/ OpenMetrics, * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram * - * Generated from protobuf field double sum = 5; + * Generated from protobuf field optional double sum = 5; * @param float $var * @return $this */ diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/InstrumentationLibraryMetrics.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/InstrumentationLibraryMetrics.php index 02103fd87..807aa1054 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/InstrumentationLibraryMetrics.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/InstrumentationLibraryMetrics.php @@ -10,6 +10,9 @@ /** * A collection of Metrics produced by an InstrumentationLibrary. + * InstrumentationLibraryMetrics is wire-compatible with ScopeMetrics for binary + * Protobuf format. + * This message is deprecated and will be removed on June 15, 2022. * * Generated from protobuf message opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics */ @@ -22,7 +25,7 @@ class InstrumentationLibraryMetrics extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; */ - private $instrumentation_library = null; + protected $instrumentation_library = null; /** * A list of metrics that originate from an instrumentation library. * @@ -34,7 +37,7 @@ class InstrumentationLibraryMetrics extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -63,13 +66,23 @@ public function __construct($data = NULL) { * an empty instrumentation library name (unknown). * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; - * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary + * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary|null */ public function getInstrumentationLibrary() { return $this->instrumentation_library; } + public function hasInstrumentationLibrary() + { + return isset($this->instrumentation_library); + } + + public function clearInstrumentationLibrary() + { + unset($this->instrumentation_library); + } + /** * The instrumentation library information for the metrics in this message. * Semantically when InstrumentationLibrary isn't set, it is equivalent with diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntDataPoint.php index e1f9e87a5..2eac03fcb 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntDataPoint.php @@ -29,7 +29,7 @@ class IntDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -37,13 +37,13 @@ class IntDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * value itself. * * Generated from protobuf field sfixed64 value = 4; */ - private $value = 0; + protected $value = 0; /** * (Optional) List of exemplars collected from * measurements that were used to form the data point diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntExemplar.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntExemplar.php index 1a54076af..319c0ff27 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntExemplar.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntExemplar.php @@ -30,13 +30,13 @@ class IntExemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 2; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * Numerical int value of the measurement that was recorded. * * Generated from protobuf field sfixed64 value = 3; */ - private $value = 0; + protected $value = 0; /** * (Optional) Span ID of the exemplar trace. * span_id may be missing if the measurement is not recorded inside a trace @@ -44,7 +44,7 @@ class IntExemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes span_id = 4; */ - private $span_id = ''; + protected $span_id = ''; /** * (Optional) Trace ID of the exemplar trace. * trace_id may be missing if the measurement is not recorded inside a trace @@ -52,7 +52,7 @@ class IntExemplar extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes trace_id = 5; */ - private $trace_id = ''; + protected $trace_id = ''; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogram.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogram.php index e0ab5e54a..934649310 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogram.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogram.php @@ -26,7 +26,7 @@ class IntHistogram extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.metrics.v1.AggregationTemporality aggregation_temporality = 2; */ - private $aggregation_temporality = 0; + protected $aggregation_temporality = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogramDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogramDataPoint.php index 301b26447..cf0e4898b 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogramDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntHistogramDataPoint.php @@ -29,7 +29,7 @@ class IntHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -37,7 +37,7 @@ class IntHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * count is the number of values in the population. Must be non-negative. This * value must be equal to the sum of the "count" fields in buckets if a @@ -45,7 +45,7 @@ class IntHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 count = 4; */ - private $count = 0; + protected $count = 0; /** * sum of the values in the population. If count is zero then this field * must be zero. This value must be equal to the sum of the "sum" fields in @@ -53,7 +53,7 @@ class IntHistogramDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field sfixed64 sum = 5; */ - private $sum = 0; + protected $sum = 0; /** * bucket_counts is an optional field contains the count values of histogram * for each bucket. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntSum.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntSum.php index d72d2bfd6..aaa313d7d 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/IntSum.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/IntSum.php @@ -25,13 +25,13 @@ class IntSum extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.metrics.v1.AggregationTemporality aggregation_temporality = 2; */ - private $aggregation_temporality = 0; + protected $aggregation_temporality = 0; /** * If "true" means that the sum is monotonic. * * Generated from protobuf field bool is_monotonic = 3; */ - private $is_monotonic = false; + protected $is_monotonic = false; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/Metric.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/Metric.php index af68291b0..fc1cf5dbd 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/Metric.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/Metric.php @@ -90,20 +90,20 @@ class Metric extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * description of the metric, which can be used in documentation. * * Generated from protobuf field string description = 2; */ - private $description = ''; + protected $description = ''; /** * unit in which the metric value is reported. Follows the format * described by http://unitsofmeasure.org/ucum.html. * * Generated from protobuf field string unit = 3; */ - private $unit = ''; + protected $unit = ''; protected $data; /** @@ -119,27 +119,8 @@ class Metric extends \Google\Protobuf\Internal\Message * @type string $unit * unit in which the metric value is reported. Follows the format * described by http://unitsofmeasure.org/ucum.html. - * @type \Opentelemetry\Proto\Metrics\V1\IntGauge $int_gauge - * IntGauge and IntSum are deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_gauge` and `int_sum` fields. - * 2. New senders, which are aware of this change MUST send only `gauge` - * and `sum` fields. - * 3. New receivers, which are aware of this change MUST convert these into - * `gauge` and `sum` by using the provided as_int field in the oneof values. - * This field will be removed in ~3 months, on July 1, 2021. * @type \Opentelemetry\Proto\Metrics\V1\Gauge $gauge - * @type \Opentelemetry\Proto\Metrics\V1\IntSum $int_sum - * This field will be removed in ~3 months, on July 1, 2021. * @type \Opentelemetry\Proto\Metrics\V1\Sum $sum - * @type \Opentelemetry\Proto\Metrics\V1\IntHistogram $int_histogram - * IntHistogram is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_histogram` field. - * 2. New senders, which are aware of this change MUST send only `histogram`. - * 3. New receivers, which are aware of this change MUST convert this into - * `histogram` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. * @type \Opentelemetry\Proto\Metrics\V1\Histogram $histogram * @type \Opentelemetry\Proto\Metrics\V1\ExponentialHistogram $exponential_histogram * @type \Opentelemetry\Proto\Metrics\V1\Summary $summary @@ -230,55 +211,20 @@ public function setUnit($var) return $this; } - /** - * IntGauge and IntSum are deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_gauge` and `int_sum` fields. - * 2. New senders, which are aware of this change MUST send only `gauge` - * and `sum` fields. - * 3. New receivers, which are aware of this change MUST convert these into - * `gauge` and `sum` by using the provided as_int field in the oneof values. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntGauge int_gauge = 4 [deprecated = true]; - * @return \Opentelemetry\Proto\Metrics\V1\IntGauge - */ - public function getIntGauge() - { - return $this->readOneof(4); - } - - /** - * IntGauge and IntSum are deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_gauge` and `int_sum` fields. - * 2. New senders, which are aware of this change MUST send only `gauge` - * and `sum` fields. - * 3. New receivers, which are aware of this change MUST convert these into - * `gauge` and `sum` by using the provided as_int field in the oneof values. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntGauge int_gauge = 4 [deprecated = true]; - * @param \Opentelemetry\Proto\Metrics\V1\IntGauge $var - * @return $this - */ - public function setIntGauge($var) - { - GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\IntGauge::class); - $this->writeOneof(4, $var); - - return $this; - } - /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Gauge gauge = 5; - * @return \Opentelemetry\Proto\Metrics\V1\Gauge + * @return \Opentelemetry\Proto\Metrics\V1\Gauge|null */ public function getGauge() { return $this->readOneof(5); } + public function hasGauge() + { + return $this->hasOneof(5); + } + /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Gauge gauge = 5; * @param \Opentelemetry\Proto\Metrics\V1\Gauge $var @@ -292,41 +238,20 @@ public function setGauge($var) return $this; } - /** - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntSum int_sum = 6 [deprecated = true]; - * @return \Opentelemetry\Proto\Metrics\V1\IntSum - */ - public function getIntSum() - { - return $this->readOneof(6); - } - - /** - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntSum int_sum = 6 [deprecated = true]; - * @param \Opentelemetry\Proto\Metrics\V1\IntSum $var - * @return $this - */ - public function setIntSum($var) - { - GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\IntSum::class); - $this->writeOneof(6, $var); - - return $this; - } - /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Sum sum = 7; - * @return \Opentelemetry\Proto\Metrics\V1\Sum + * @return \Opentelemetry\Proto\Metrics\V1\Sum|null */ public function getSum() { return $this->readOneof(7); } + public function hasSum() + { + return $this->hasOneof(7); + } + /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Sum sum = 7; * @param \Opentelemetry\Proto\Metrics\V1\Sum $var @@ -340,53 +265,20 @@ public function setSum($var) return $this; } - /** - * IntHistogram is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_histogram` field. - * 2. New senders, which are aware of this change MUST send only `histogram`. - * 3. New receivers, which are aware of this change MUST convert this into - * `histogram` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntHistogram int_histogram = 8 [deprecated = true]; - * @return \Opentelemetry\Proto\Metrics\V1\IntHistogram - */ - public function getIntHistogram() - { - return $this->readOneof(8); - } - - /** - * IntHistogram is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `int_histogram` field. - * 2. New senders, which are aware of this change MUST send only `histogram`. - * 3. New receivers, which are aware of this change MUST convert this into - * `histogram` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field .opentelemetry.proto.metrics.v1.IntHistogram int_histogram = 8 [deprecated = true]; - * @param \Opentelemetry\Proto\Metrics\V1\IntHistogram $var - * @return $this - */ - public function setIntHistogram($var) - { - GPBUtil::checkMessage($var, \Opentelemetry\Proto\Metrics\V1\IntHistogram::class); - $this->writeOneof(8, $var); - - return $this; - } - /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Histogram histogram = 9; - * @return \Opentelemetry\Proto\Metrics\V1\Histogram + * @return \Opentelemetry\Proto\Metrics\V1\Histogram|null */ public function getHistogram() { return $this->readOneof(9); } + public function hasHistogram() + { + return $this->hasOneof(9); + } + /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Histogram histogram = 9; * @param \Opentelemetry\Proto\Metrics\V1\Histogram $var @@ -402,13 +294,18 @@ public function setHistogram($var) /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogram exponential_histogram = 10; - * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogram + * @return \Opentelemetry\Proto\Metrics\V1\ExponentialHistogram|null */ public function getExponentialHistogram() { return $this->readOneof(10); } + public function hasExponentialHistogram() + { + return $this->hasOneof(10); + } + /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.ExponentialHistogram exponential_histogram = 10; * @param \Opentelemetry\Proto\Metrics\V1\ExponentialHistogram $var @@ -424,13 +321,18 @@ public function setExponentialHistogram($var) /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Summary summary = 11; - * @return \Opentelemetry\Proto\Metrics\V1\Summary + * @return \Opentelemetry\Proto\Metrics\V1\Summary|null */ public function getSummary() { return $this->readOneof(11); } + public function hasSummary() + { + return $this->hasOneof(11); + } + /** * Generated from protobuf field .opentelemetry.proto.metrics.v1.Summary summary = 11; * @param \Opentelemetry\Proto\Metrics\V1\Summary $var diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/NumberDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/NumberDataPoint.php index 52d62b4bc..d9fa829e0 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/NumberDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/NumberDataPoint.php @@ -19,22 +19,12 @@ class NumberDataPoint extends \Google\Protobuf\Internal\Message /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; */ private $attributes; - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - */ - private $labels; /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -43,7 +33,7 @@ class NumberDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -51,7 +41,7 @@ class NumberDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * (Optional) List of exemplars collected from * measurements that were used to form the data point @@ -65,7 +55,7 @@ class NumberDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 flags = 8; */ - private $flags = 0; + protected $flags = 0; protected $value; /** @@ -77,14 +67,8 @@ class NumberDataPoint extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). - * @type \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $labels - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int|string $start_time_unix_nano * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -112,6 +96,8 @@ public function __construct($data = NULL) { /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; * @return \Google\Protobuf\Internal\RepeatedField @@ -124,6 +110,8 @@ public function getAttributes() /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var @@ -137,44 +125,6 @@ public function setAttributes($var) return $this; } - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @param \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Common\V1\StringKeyValue::class); - $this->labels = $arr; - - return $this; - } - /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -246,6 +196,11 @@ public function getAsDouble() return $this->readOneof(4); } + public function hasAsDouble() + { + return $this->hasOneof(4); + } + /** * Generated from protobuf field double as_double = 4; * @param float $var @@ -268,6 +223,11 @@ public function getAsInt() return $this->readOneof(6); } + public function hasAsInt() + { + return $this->hasOneof(6); + } + /** * Generated from protobuf field sfixed64 as_int = 6; * @param int|string $var diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/ResourceMetrics.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/ResourceMetrics.php index f8d8ca878..30bb5ef4e 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/ResourceMetrics.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/ResourceMetrics.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A collection of InstrumentationLibraryMetrics from a Resource. + * A collection of ScopeMetrics from a Resource. * * Generated from protobuf message opentelemetry.proto.metrics.v1.ResourceMetrics */ @@ -21,21 +21,48 @@ class ResourceMetrics extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; */ - private $resource = null; + protected $resource = null; /** * A list of metrics that originate from a resource. * - * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 2; + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.ScopeMetrics scope_metrics = 2; + */ + private $scope_metrics; + /** + * A list of InstrumentationLibraryMetrics that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_metrics. Instead + * scope_metrics SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_metrics is set + * and scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_metrics field MAY also set + * scope_metrics to carry the same metrics, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_metrics and + * SHOULD NOT set instrumentation_library_metrics. + * JSON receivers SHOULD check if instrumentation_library_metrics is set and + * scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics field SHOULD be ignored. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 1000 [deprecated = true]; + * @deprecated */ private $instrumentation_library_metrics; /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_metrics" field which have their own - * schema_url field. + * to the data in the "scope_metrics" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -46,12 +73,34 @@ class ResourceMetrics extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Resource\V1\Resource $resource * The resource for the metrics in this message. * If this field is not set then no resource info is known. - * @type \Opentelemetry\Proto\Metrics\V1\InstrumentationLibraryMetrics[]|\Google\Protobuf\Internal\RepeatedField $instrumentation_library_metrics + * @type \Opentelemetry\Proto\Metrics\V1\ScopeMetrics[]|\Google\Protobuf\Internal\RepeatedField $scope_metrics * A list of metrics that originate from a resource. + * @type \Opentelemetry\Proto\Metrics\V1\InstrumentationLibraryMetrics[]|\Google\Protobuf\Internal\RepeatedField $instrumentation_library_metrics + * A list of InstrumentationLibraryMetrics that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_metrics. Instead + * scope_metrics SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_metrics is set + * and scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_metrics field MAY also set + * scope_metrics to carry the same metrics, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_metrics and + * SHOULD NOT set instrumentation_library_metrics. + * JSON receivers SHOULD check if instrumentation_library_metrics is set and + * scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics field SHOULD be ignored. * @type string $schema_url * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_metrics" field which have their own - * schema_url field. + * to the data in the "scope_metrics" field which have their own schema_url field. * } */ public function __construct($data = NULL) { @@ -64,13 +113,23 @@ public function __construct($data = NULL) { * If this field is not set then no resource info is known. * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; - * @return \Opentelemetry\Proto\Resource\V1\Resource + * @return \Opentelemetry\Proto\Resource\V1\Resource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); + } + /** * The resource for the metrics in this message. * If this field is not set then no resource info is known. @@ -90,23 +149,95 @@ public function setResource($var) /** * A list of metrics that originate from a resource. * - * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 2; + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.ScopeMetrics scope_metrics = 2; * @return \Google\Protobuf\Internal\RepeatedField */ + public function getScopeMetrics() + { + return $this->scope_metrics; + } + + /** + * A list of metrics that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.ScopeMetrics scope_metrics = 2; + * @param \Opentelemetry\Proto\Metrics\V1\ScopeMetrics[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setScopeMetrics($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Metrics\V1\ScopeMetrics::class); + $this->scope_metrics = $arr; + + return $this; + } + + /** + * A list of InstrumentationLibraryMetrics that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_metrics. Instead + * scope_metrics SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_metrics is set + * and scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_metrics field MAY also set + * scope_metrics to carry the same metrics, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_metrics and + * SHOULD NOT set instrumentation_library_metrics. + * JSON receivers SHOULD check if instrumentation_library_metrics is set and + * scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics field SHOULD be ignored. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 1000 [deprecated = true]; + * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated + */ public function getInstrumentationLibraryMetrics() { + @trigger_error('instrumentation_library_metrics is deprecated.', E_USER_DEPRECATED); return $this->instrumentation_library_metrics; } /** - * A list of metrics that originate from a resource. + * A list of InstrumentationLibraryMetrics that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_metrics. Instead + * scope_metrics SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_metrics is set + * and scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_metrics field MAY also set + * scope_metrics to carry the same metrics, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_metrics and + * SHOULD NOT set instrumentation_library_metrics. + * JSON receivers SHOULD check if instrumentation_library_metrics is set and + * scope_metrics is not set then the value in instrumentation_library_metrics + * SHOULD be used instead by converting InstrumentationLibraryMetrics into ScopeMetrics. + * If scope_metrics is set then instrumentation_library_metrics field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 2; + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics instrumentation_library_metrics = 1000 [deprecated = true]; * @param \Opentelemetry\Proto\Metrics\V1\InstrumentationLibraryMetrics[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this + * @deprecated */ public function setInstrumentationLibraryMetrics($var) { + @trigger_error('instrumentation_library_metrics is deprecated.', E_USER_DEPRECATED); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Metrics\V1\InstrumentationLibraryMetrics::class); $this->instrumentation_library_metrics = $arr; @@ -115,8 +246,7 @@ public function setInstrumentationLibraryMetrics($var) /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_metrics" field which have their own - * schema_url field. + * to the data in the "scope_metrics" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @return string @@ -128,8 +258,7 @@ public function getSchemaUrl() /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_metrics" field which have their own - * schema_url field. + * to the data in the "scope_metrics" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @param string $var diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/ScopeMetrics.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/ScopeMetrics.php new file mode 100644 index 000000000..71f5cdb86 --- /dev/null +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/ScopeMetrics.php @@ -0,0 +1,153 @@ +opentelemetry.proto.metrics.v1.ScopeMetrics + */ +class ScopeMetrics extends \Google\Protobuf\Internal\Message +{ + /** + * The instrumentation scope information for the metrics in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + */ + protected $scope = null; + /** + * A list of metrics that originate from an instrumentation library. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.Metric metrics = 2; + */ + private $metrics; + /** + * This schema_url applies to all metrics in the "metrics" field. + * + * Generated from protobuf field string schema_url = 3; + */ + protected $schema_url = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Opentelemetry\Proto\Common\V1\InstrumentationScope $scope + * The instrumentation scope information for the metrics in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * @type \Opentelemetry\Proto\Metrics\V1\Metric[]|\Google\Protobuf\Internal\RepeatedField $metrics + * A list of metrics that originate from an instrumentation library. + * @type string $schema_url + * This schema_url applies to all metrics in the "metrics" field. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Opentelemetry\Proto\Metrics\V1\Metrics::initOnce(); + parent::__construct($data); + } + + /** + * The instrumentation scope information for the metrics in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @return \Opentelemetry\Proto\Common\V1\InstrumentationScope|null + */ + public function getScope() + { + return $this->scope; + } + + public function hasScope() + { + return isset($this->scope); + } + + public function clearScope() + { + unset($this->scope); + } + + /** + * The instrumentation scope information for the metrics in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @param \Opentelemetry\Proto\Common\V1\InstrumentationScope $var + * @return $this + */ + public function setScope($var) + { + GPBUtil::checkMessage($var, \Opentelemetry\Proto\Common\V1\InstrumentationScope::class); + $this->scope = $var; + + return $this; + } + + /** + * A list of metrics that originate from an instrumentation library. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.Metric metrics = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMetrics() + { + return $this->metrics; + } + + /** + * A list of metrics that originate from an instrumentation library. + * + * Generated from protobuf field repeated .opentelemetry.proto.metrics.v1.Metric metrics = 2; + * @param \Opentelemetry\Proto\Metrics\V1\Metric[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMetrics($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Metrics\V1\Metric::class); + $this->metrics = $arr; + + return $this; + } + + /** + * This schema_url applies to all metrics in the "metrics" field. + * + * Generated from protobuf field string schema_url = 3; + * @return string + */ + public function getSchemaUrl() + { + return $this->schema_url; + } + + /** + * This schema_url applies to all metrics in the "metrics" field. + * + * Generated from protobuf field string schema_url = 3; + * @param string $var + * @return $this + */ + public function setSchemaUrl($var) + { + GPBUtil::checkString($var, True); + $this->schema_url = $var; + + return $this; + } + +} + diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/Sum.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/Sum.php index 80dfe6b6e..0251ecd9f 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/Sum.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/Sum.php @@ -26,13 +26,13 @@ class Sum extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.metrics.v1.AggregationTemporality aggregation_temporality = 2; */ - private $aggregation_temporality = 0; + protected $aggregation_temporality = 0; /** * If "true" means that the sum is monotonic. * * Generated from protobuf field bool is_monotonic = 3; */ - private $is_monotonic = false; + protected $is_monotonic = false; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint.php index 91957656f..30cf4ade4 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint.php @@ -19,22 +19,12 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; */ private $attributes; - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - */ - private $labels; /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -43,7 +33,7 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 2; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * TimeUnixNano is required, see the detailed comments above Metric. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January @@ -51,13 +41,13 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 3; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * count is the number of values in the population. Must be non-negative. * * Generated from protobuf field fixed64 count = 4; */ - private $count = 0; + protected $count = 0; /** * sum of the values in the population. If count is zero then this field * must be zero. @@ -69,7 +59,7 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double sum = 5; */ - private $sum = 0.0; + protected $sum = 0.0; /** * (Optional) list of values at different quantiles of the distribution calculated * from the current snapshot. The quantiles must be strictly increasing. @@ -83,7 +73,7 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 flags = 8; */ - private $flags = 0; + protected $flags = 0; /** * Constructor. @@ -94,14 +84,8 @@ class SummaryDataPoint extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). - * @type \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $labels - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int|string $start_time_unix_nano * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. @@ -137,6 +121,8 @@ public function __construct($data = NULL) { /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; * @return \Google\Protobuf\Internal\RepeatedField @@ -149,6 +135,8 @@ public function getAttributes() /** * The set of key/value pairs that uniquely identify the timeseries from * where this point belongs. The list may be empty (may contain 0 elements). + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 7; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var @@ -162,44 +150,6 @@ public function setAttributes($var) return $this; } - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @return \Google\Protobuf\Internal\RepeatedField - */ - public function getLabels() - { - return $this->labels; - } - - /** - * Labels is deprecated and will be removed soon. - * 1. Old senders and receivers that are not aware of this change will - * continue using the `labels` field. - * 2. New senders, which are aware of this change MUST send only `attributes`. - * 3. New receivers, which are aware of this change MUST convert this into - * `labels` by simply converting all int64 values into float. - * This field will be removed in ~3 months, on July 1, 2021. - * - * Generated from protobuf field repeated .opentelemetry.proto.common.v1.StringKeyValue labels = 1 [deprecated = true]; - * @param \Opentelemetry\Proto\Common\V1\StringKeyValue[]|\Google\Protobuf\Internal\RepeatedField $var - * @return $this - */ - public function setLabels($var) - { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Common\V1\StringKeyValue::class); - $this->labels = $arr; - - return $this; - } - /** * StartTimeUnixNano is optional but strongly encouraged, see the * the detailed comments above Metric. diff --git a/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint/ValueAtQuantile.php b/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint/ValueAtQuantile.php index e08e46d97..8200b6d26 100644 --- a/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint/ValueAtQuantile.php +++ b/proto/otel/Opentelemetry/Proto/Metrics/V1/SummaryDataPoint/ValueAtQuantile.php @@ -26,14 +26,14 @@ class ValueAtQuantile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double quantile = 1; */ - private $quantile = 0.0; + protected $quantile = 0.0; /** * The value at the given quantile of a distribution. * Quantile values must NOT be negative. * * Generated from protobuf field double value = 2; */ - private $value = 0.0; + protected $value = 0.0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Resource/V1/Resource.php b/proto/otel/Opentelemetry/Proto/Resource/V1/Resource.php index 485bcdd60..d9062eeb1 100644 --- a/proto/otel/Opentelemetry/Proto/Resource/V1/Resource.php +++ b/proto/otel/Opentelemetry/Proto/Resource/V1/Resource.php @@ -16,7 +16,9 @@ class Resource extends \Google\Protobuf\Internal\Message { /** - * Set of labels that describe the resource. + * Set of attributes that describe the resource. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; */ @@ -27,7 +29,7 @@ class Resource extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_attributes_count = 2; */ - private $dropped_attributes_count = 0; + protected $dropped_attributes_count = 0; /** * Constructor. @@ -36,7 +38,9 @@ class Resource extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes - * Set of labels that describe the resource. + * Set of attributes that describe the resource. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int $dropped_attributes_count * dropped_attributes_count is the number of dropped attributes. If the value is 0, then * no attributes were dropped. @@ -48,7 +52,9 @@ public function __construct($data = NULL) { } /** - * Set of labels that describe the resource. + * Set of attributes that describe the resource. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -59,7 +65,9 @@ public function getAttributes() } /** - * Set of labels that describe the resource. + * Set of attributes that describe the resource. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 1; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler.php b/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler.php index 16fc1969b..c21482623 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler.php @@ -18,7 +18,7 @@ class ConstantSampler extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field .opentelemetry.proto.trace.v1.ConstantSampler.ConstantDecision decision = 1; */ - private $decision = 0; + protected $decision = 0; /** * Constructor. @@ -50,7 +50,7 @@ public function getDecision() */ public function setDecision($var) { - GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\ConstantSampler_ConstantDecision::class); + GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\ConstantSampler\ConstantDecision::class); $this->decision = $var; return $this; diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler/ConstantDecision.php b/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler/ConstantDecision.php index 134ed56c2..04c1950ca 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler/ConstantDecision.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/ConstantSampler/ConstantDecision.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Trace\V1\ConstantSampler; +use UnexpectedValueException; + /** * How spans should be sampled: * - Always off @@ -26,6 +28,32 @@ class ConstantDecision * Generated from protobuf enum ALWAYS_PARENT = 2; */ const ALWAYS_PARENT = 2; + + private static $valueToName = [ + self::ALWAYS_OFF => 'ALWAYS_OFF', + self::ALWAYS_ON => 'ALWAYS_ON', + self::ALWAYS_PARENT => 'ALWAYS_PARENT', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/InstrumentationLibrarySpans.php b/proto/otel/Opentelemetry/Proto/Trace/V1/InstrumentationLibrarySpans.php index 926eb6916..c5cc122e7 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/InstrumentationLibrarySpans.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/InstrumentationLibrarySpans.php @@ -10,6 +10,9 @@ /** * A collection of Spans produced by an InstrumentationLibrary. + * InstrumentationLibrarySpans is wire-compatible with ScopeSpans for binary + * Protobuf format. + * This message is deprecated and will be removed on June 15, 2022. * * Generated from protobuf message opentelemetry.proto.trace.v1.InstrumentationLibrarySpans */ @@ -22,7 +25,7 @@ class InstrumentationLibrarySpans extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; */ - private $instrumentation_library = null; + protected $instrumentation_library = null; /** * A list of Spans that originate from an instrumentation library. * @@ -34,7 +37,7 @@ class InstrumentationLibrarySpans extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -63,13 +66,23 @@ public function __construct($data = NULL) { * an empty instrumentation library name (unknown). * * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1; - * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary + * @return \Opentelemetry\Proto\Common\V1\InstrumentationLibrary|null */ public function getInstrumentationLibrary() { return $this->instrumentation_library; } + public function hasInstrumentationLibrary() + { + return isset($this->instrumentation_library); + } + + public function clearInstrumentationLibrary() + { + unset($this->instrumentation_library); + } + /** * The instrumentation library information for the spans in this message. * Semantically when InstrumentationLibrary isn't set, it is equivalent with diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/RateLimitingSampler.php b/proto/otel/Opentelemetry/Proto/Trace/V1/RateLimitingSampler.php index e55d2fc4c..3fd17fb01 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/RateLimitingSampler.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/RateLimitingSampler.php @@ -20,7 +20,7 @@ class RateLimitingSampler extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 qps = 1; */ - private $qps = 0; + protected $qps = 0; /** * Constructor. diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/ResourceSpans.php b/proto/otel/Opentelemetry/Proto/Trace/V1/ResourceSpans.php index c8635b326..4c9227480 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/ResourceSpans.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/ResourceSpans.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\GPBUtil; /** - * A collection of InstrumentationLibrarySpans from a Resource. + * A collection of ScopeSpans from a Resource. * * Generated from protobuf message opentelemetry.proto.trace.v1.ResourceSpans */ @@ -21,21 +21,48 @@ class ResourceSpans extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; */ - private $resource = null; + protected $resource = null; + /** + * A list of ScopeSpans that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.ScopeSpans scope_spans = 2; + */ + private $scope_spans; /** * A list of InstrumentationLibrarySpans that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_spans. Instead + * scope_spans SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_spans is set + * and scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_spans field MAY also set + * scope_spans to carry the same spans, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_spans and + * SHOULD NOT set instrumentation_library_spans. + * JSON receivers SHOULD check if instrumentation_library_spans is set and + * scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 2; + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 1000 [deprecated = true]; + * @deprecated */ private $instrumentation_library_spans; /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_spans" field which have their own - * schema_url field. + * to the data in the "scope_spans" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; */ - private $schema_url = ''; + protected $schema_url = ''; /** * Constructor. @@ -46,12 +73,34 @@ class ResourceSpans extends \Google\Protobuf\Internal\Message * @type \Opentelemetry\Proto\Resource\V1\Resource $resource * The resource for the spans in this message. * If this field is not set then no resource info is known. + * @type \Opentelemetry\Proto\Trace\V1\ScopeSpans[]|\Google\Protobuf\Internal\RepeatedField $scope_spans + * A list of ScopeSpans that originate from a resource. * @type \Opentelemetry\Proto\Trace\V1\InstrumentationLibrarySpans[]|\Google\Protobuf\Internal\RepeatedField $instrumentation_library_spans * A list of InstrumentationLibrarySpans that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_spans. Instead + * scope_spans SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_spans is set + * and scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_spans field MAY also set + * scope_spans to carry the same spans, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_spans and + * SHOULD NOT set instrumentation_library_spans. + * JSON receivers SHOULD check if instrumentation_library_spans is set and + * scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans field SHOULD be ignored. * @type string $schema_url * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_spans" field which have their own - * schema_url field. + * to the data in the "scope_spans" field which have their own schema_url field. * } */ public function __construct($data = NULL) { @@ -64,13 +113,23 @@ public function __construct($data = NULL) { * If this field is not set then no resource info is known. * * Generated from protobuf field .opentelemetry.proto.resource.v1.Resource resource = 1; - * @return \Opentelemetry\Proto\Resource\V1\Resource + * @return \Opentelemetry\Proto\Resource\V1\Resource|null */ public function getResource() { return $this->resource; } + public function hasResource() + { + return isset($this->resource); + } + + public function clearResource() + { + unset($this->resource); + } + /** * The resource for the spans in this message. * If this field is not set then no resource info is known. @@ -87,26 +146,98 @@ public function setResource($var) return $this; } + /** + * A list of ScopeSpans that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.ScopeSpans scope_spans = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getScopeSpans() + { + return $this->scope_spans; + } + + /** + * A list of ScopeSpans that originate from a resource. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.ScopeSpans scope_spans = 2; + * @param \Opentelemetry\Proto\Trace\V1\ScopeSpans[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setScopeSpans($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Trace\V1\ScopeSpans::class); + $this->scope_spans = $arr; + + return $this; + } + /** * A list of InstrumentationLibrarySpans that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_spans. Instead + * scope_spans SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_spans is set + * and scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_spans field MAY also set + * scope_spans to carry the same spans, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_spans and + * SHOULD NOT set instrumentation_library_spans. + * JSON receivers SHOULD check if instrumentation_library_spans is set and + * scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 2; + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 1000 [deprecated = true]; * @return \Google\Protobuf\Internal\RepeatedField + * @deprecated */ public function getInstrumentationLibrarySpans() { + @trigger_error('instrumentation_library_spans is deprecated.', E_USER_DEPRECATED); return $this->instrumentation_library_spans; } /** * A list of InstrumentationLibrarySpans that originate from a resource. + * This field is deprecated and will be removed after grace period expires on June 15, 2022. + * During the grace period the following rules SHOULD be followed: + * For Binary Protobufs + * ==================== + * Binary Protobuf senders SHOULD NOT set instrumentation_library_spans. Instead + * scope_spans SHOULD be set. + * Binary Protobuf receivers SHOULD check if instrumentation_library_spans is set + * and scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans SHOULD be ignored. + * For JSON + * ======== + * JSON senders that set instrumentation_library_spans field MAY also set + * scope_spans to carry the same spans, essentially double-publishing the same data. + * Such double-publishing MAY be controlled by a user-settable option. + * If double-publishing is not used then the senders SHOULD set scope_spans and + * SHOULD NOT set instrumentation_library_spans. + * JSON receivers SHOULD check if instrumentation_library_spans is set and + * scope_spans is not set then the value in instrumentation_library_spans + * SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans. + * If scope_spans is set then instrumentation_library_spans field SHOULD be ignored. * - * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 2; + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.InstrumentationLibrarySpans instrumentation_library_spans = 1000 [deprecated = true]; * @param \Opentelemetry\Proto\Trace\V1\InstrumentationLibrarySpans[]|\Google\Protobuf\Internal\RepeatedField $var * @return $this + * @deprecated */ public function setInstrumentationLibrarySpans($var) { + @trigger_error('instrumentation_library_spans is deprecated.', E_USER_DEPRECATED); $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Trace\V1\InstrumentationLibrarySpans::class); $this->instrumentation_library_spans = $arr; @@ -115,8 +246,7 @@ public function setInstrumentationLibrarySpans($var) /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_spans" field which have their own - * schema_url field. + * to the data in the "scope_spans" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @return string @@ -128,8 +258,7 @@ public function getSchemaUrl() /** * This schema_url applies to the data in the "resource" field. It does not apply - * to the data in the "instrumentation_library_spans" field which have their own - * schema_url field. + * to the data in the "scope_spans" field which have their own schema_url field. * * Generated from protobuf field string schema_url = 3; * @param string $var diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/ScopeSpans.php b/proto/otel/Opentelemetry/Proto/Trace/V1/ScopeSpans.php new file mode 100644 index 000000000..098376f7d --- /dev/null +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/ScopeSpans.php @@ -0,0 +1,153 @@ +opentelemetry.proto.trace.v1.ScopeSpans + */ +class ScopeSpans extends \Google\Protobuf\Internal\Message +{ + /** + * The instrumentation scope information for the spans in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + */ + protected $scope = null; + /** + * A list of Spans that originate from an instrumentation scope. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.Span spans = 2; + */ + private $spans; + /** + * This schema_url applies to all spans and span events in the "spans" field. + * + * Generated from protobuf field string schema_url = 3; + */ + protected $schema_url = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Opentelemetry\Proto\Common\V1\InstrumentationScope $scope + * The instrumentation scope information for the spans in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * @type \Opentelemetry\Proto\Trace\V1\Span[]|\Google\Protobuf\Internal\RepeatedField $spans + * A list of Spans that originate from an instrumentation scope. + * @type string $schema_url + * This schema_url applies to all spans and span events in the "spans" field. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Opentelemetry\Proto\Trace\V1\Trace::initOnce(); + parent::__construct($data); + } + + /** + * The instrumentation scope information for the spans in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @return \Opentelemetry\Proto\Common\V1\InstrumentationScope|null + */ + public function getScope() + { + return $this->scope; + } + + public function hasScope() + { + return isset($this->scope); + } + + public function clearScope() + { + unset($this->scope); + } + + /** + * The instrumentation scope information for the spans in this message. + * Semantically when InstrumentationScope isn't set, it is equivalent with + * an empty instrumentation scope name (unknown). + * + * Generated from protobuf field .opentelemetry.proto.common.v1.InstrumentationScope scope = 1; + * @param \Opentelemetry\Proto\Common\V1\InstrumentationScope $var + * @return $this + */ + public function setScope($var) + { + GPBUtil::checkMessage($var, \Opentelemetry\Proto\Common\V1\InstrumentationScope::class); + $this->scope = $var; + + return $this; + } + + /** + * A list of Spans that originate from an instrumentation scope. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.Span spans = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSpans() + { + return $this->spans; + } + + /** + * A list of Spans that originate from an instrumentation scope. + * + * Generated from protobuf field repeated .opentelemetry.proto.trace.v1.Span spans = 2; + * @param \Opentelemetry\Proto\Trace\V1\Span[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSpans($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Opentelemetry\Proto\Trace\V1\Span::class); + $this->spans = $arr; + + return $this; + } + + /** + * This schema_url applies to all spans and span events in the "spans" field. + * + * Generated from protobuf field string schema_url = 3; + * @return string + */ + public function getSchemaUrl() + { + return $this->schema_url; + } + + /** + * This schema_url applies to all spans and span events in the "spans" field. + * + * Generated from protobuf field string schema_url = 3; + * @param string $var + * @return $this + */ + public function setSchemaUrl($var) + { + GPBUtil::checkString($var, True); + $this->schema_url = $var; + + return $this; + } + +} + diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Span.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Span.php index f6bd70249..7b823d4d9 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Span.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Span.php @@ -32,7 +32,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes trace_id = 1; */ - private $trace_id = ''; + protected $trace_id = ''; /** * A unique identifier for a span within a trace, assigned when the span * is created. The ID is an 8-byte array. An ID with all zeroes is considered @@ -43,7 +43,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes span_id = 2; */ - private $span_id = ''; + protected $span_id = ''; /** * trace_state conveys information about request position in multiple distributed tracing graphs. * It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header @@ -51,14 +51,14 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string trace_state = 3; */ - private $trace_state = ''; + protected $trace_state = ''; /** * The `span_id` of this span's parent span. If this is a root span, then this * field must be empty. The ID is an 8-byte array. * * Generated from protobuf field bytes parent_span_id = 4; */ - private $parent_span_id = ''; + protected $parent_span_id = ''; /** * A description of the span's operation. * For example, the name can be a qualified method name or a file name @@ -71,7 +71,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 5; */ - private $name = ''; + protected $name = ''; /** * Distinguishes between spans generated in a particular context. For example, * two spans with the same name may be distinguished using `CLIENT` (caller) @@ -79,7 +79,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .opentelemetry.proto.trace.v1.Span.SpanKind kind = 6; */ - private $kind = 0; + protected $kind = 0; /** * start_time_unix_nano is the start time of the span. On the client side, this is the time * kept by the local machine where the span execution starts. On the server side, this @@ -89,7 +89,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 start_time_unix_nano = 7; */ - private $start_time_unix_nano = 0; + protected $start_time_unix_nano = 0; /** * end_time_unix_nano is the end time of the span. On the client side, this is the time * kept by the local machine where the span execution ends. On the server side, this @@ -99,7 +99,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 end_time_unix_nano = 8; */ - private $end_time_unix_nano = 0; + protected $end_time_unix_nano = 0; /** * attributes is a collection of key/value pairs. Note, global attributes * like server name can be set using the resource API. Examples of attributes: @@ -109,6 +109,8 @@ class Span extends \Google\Protobuf\Internal\Message * "abc.com/score": 10.239 * The OpenTelemetry API specification further restricts the allowed value types: * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; */ @@ -120,7 +122,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_attributes_count = 10; */ - private $dropped_attributes_count = 0; + protected $dropped_attributes_count = 0; /** * events is a collection of Event items. * @@ -133,7 +135,7 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_events_count = 12; */ - private $dropped_events_count = 0; + protected $dropped_events_count = 0; /** * links is a collection of Links, which are references from this span to a span * in the same or different trace. @@ -147,14 +149,14 @@ class Span extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_links_count = 14; */ - private $dropped_links_count = 0; + protected $dropped_links_count = 0; /** * An optional final status for this span. Semantically when Status isn't set, it means * span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). * * Generated from protobuf field .opentelemetry.proto.trace.v1.Status status = 15; */ - private $status = null; + protected $status = null; /** * Constructor. @@ -217,6 +219,8 @@ class Span extends \Google\Protobuf\Internal\Message * "abc.com/score": 10.239 * The OpenTelemetry API specification further restricts the allowed value types: * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int $dropped_attributes_count * dropped_attributes_count is the number of attributes that were discarded. Attributes * can be discarded because their keys are too long or because there are too many @@ -436,7 +440,7 @@ public function getKind() */ public function setKind($var) { - GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\Span_SpanKind::class); + GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\Span\SpanKind::class); $this->kind = $var; return $this; @@ -519,6 +523,8 @@ public function setEndTimeUnixNano($var) * "abc.com/score": 10.239 * The OpenTelemetry API specification further restricts the allowed value types: * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; * @return \Google\Protobuf\Internal\RepeatedField @@ -537,6 +543,8 @@ public function getAttributes() * "abc.com/score": 10.239 * The OpenTelemetry API specification further restricts the allowed value types: * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 9; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var @@ -695,13 +703,23 @@ public function setDroppedLinksCount($var) * span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). * * Generated from protobuf field .opentelemetry.proto.trace.v1.Status status = 15; - * @return \Opentelemetry\Proto\Trace\V1\Status + * @return \Opentelemetry\Proto\Trace\V1\Status|null */ public function getStatus() { return $this->status; } + public function hasStatus() + { + return isset($this->status); + } + + public function clearStatus() + { + unset($this->status); + } + /** * An optional final status for this span. Semantically when Status isn't set, it means * span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Event.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Event.php index 8206a8123..c6b7a1807 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Event.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Event.php @@ -21,16 +21,18 @@ class Event extends \Google\Protobuf\Internal\Message * * Generated from protobuf field fixed64 time_unix_nano = 1; */ - private $time_unix_nano = 0; + protected $time_unix_nano = 0; /** * name of the event. * This field is semantically required to be set to non-empty string. * * Generated from protobuf field string name = 2; */ - private $name = ''; + protected $name = ''; /** * attributes is a collection of attribute key/value pairs on the event. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 3; */ @@ -41,7 +43,7 @@ class Event extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_attributes_count = 4; */ - private $dropped_attributes_count = 0; + protected $dropped_attributes_count = 0; /** * Constructor. @@ -56,6 +58,8 @@ class Event extends \Google\Protobuf\Internal\Message * This field is semantically required to be set to non-empty string. * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * attributes is a collection of attribute key/value pairs on the event. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int $dropped_attributes_count * dropped_attributes_count is the number of dropped attributes. If the value is 0, * then no attributes were dropped. @@ -122,6 +126,8 @@ public function setName($var) /** * attributes is a collection of attribute key/value pairs on the event. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 3; * @return \Google\Protobuf\Internal\RepeatedField @@ -133,6 +139,8 @@ public function getAttributes() /** * attributes is a collection of attribute key/value pairs on the event. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 3; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Link.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Link.php index 1b4083d11..3096739de 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Link.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/Link.php @@ -24,21 +24,23 @@ class Link extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes trace_id = 1; */ - private $trace_id = ''; + protected $trace_id = ''; /** * A unique identifier for the linked span. The ID is an 8-byte array. * * Generated from protobuf field bytes span_id = 2; */ - private $span_id = ''; + protected $span_id = ''; /** * The trace_state associated with the link. * * Generated from protobuf field string trace_state = 3; */ - private $trace_state = ''; + protected $trace_state = ''; /** * attributes is a collection of attribute key/value pairs on the link. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 4; */ @@ -49,7 +51,7 @@ class Link extends \Google\Protobuf\Internal\Message * * Generated from protobuf field uint32 dropped_attributes_count = 5; */ - private $dropped_attributes_count = 0; + protected $dropped_attributes_count = 0; /** * Constructor. @@ -66,6 +68,8 @@ class Link extends \Google\Protobuf\Internal\Message * The trace_state associated with the link. * @type \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $attributes * attributes is a collection of attribute key/value pairs on the link. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * @type int $dropped_attributes_count * dropped_attributes_count is the number of dropped attributes. If the value is 0, * then no attributes were dropped. @@ -158,6 +162,8 @@ public function setTraceState($var) /** * attributes is a collection of attribute key/value pairs on the link. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 4; * @return \Google\Protobuf\Internal\RepeatedField @@ -169,6 +175,8 @@ public function getAttributes() /** * attributes is a collection of attribute key/value pairs on the link. + * Attribute keys MUST be unique (it is not allowed to have more than one + * attribute with the same key). * * Generated from protobuf field repeated .opentelemetry.proto.common.v1.KeyValue attributes = 4; * @param \Opentelemetry\Proto\Common\V1\KeyValue[]|\Google\Protobuf\Internal\RepeatedField $var diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/SpanKind.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/SpanKind.php index edb6751b6..9ffa93719 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Span/SpanKind.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Span/SpanKind.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Trace\V1\Span; +use UnexpectedValueException; + /** * SpanKind is the type of span. Can be used to specify additional relationships between spans * in addition to a parent/child relationship. @@ -56,6 +58,35 @@ class SpanKind * Generated from protobuf enum SPAN_KIND_CONSUMER = 5; */ const SPAN_KIND_CONSUMER = 5; + + private static $valueToName = [ + self::SPAN_KIND_UNSPECIFIED => 'SPAN_KIND_UNSPECIFIED', + self::SPAN_KIND_INTERNAL => 'SPAN_KIND_INTERNAL', + self::SPAN_KIND_SERVER => 'SPAN_KIND_SERVER', + self::SPAN_KIND_CLIENT => 'SPAN_KIND_CLIENT', + self::SPAN_KIND_PRODUCER => 'SPAN_KIND_PRODUCER', + self::SPAN_KIND_CONSUMER => 'SPAN_KIND_CONSUMER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Status.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Status.php index 0fbd2ca52..5fee7292e 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Status.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Status.php @@ -16,28 +16,18 @@ */ class Status extends \Google\Protobuf\Internal\Message { - /** - * The deprecated status code. This is an optional field. - * This field is deprecated and is replaced by the `code` field below. See backward - * compatibility notes below. According to our stability guarantees this field - * will be removed in 12 months, on Oct 22, 2021. All usage of old senders and - * receivers that do not understand the `code` field MUST be phased out by then. - * - * Generated from protobuf field .opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode deprecated_code = 1 [deprecated = true]; - */ - private $deprecated_code = 0; /** * A developer-facing human readable error message. * * Generated from protobuf field string message = 2; */ - private $message = ''; + protected $message = ''; /** * The status code. * * Generated from protobuf field .opentelemetry.proto.trace.v1.Status.StatusCode code = 3; */ - private $code = 0; + protected $code = 0; /** * Constructor. @@ -45,12 +35,6 @@ class Status extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type int $deprecated_code - * The deprecated status code. This is an optional field. - * This field is deprecated and is replaced by the `code` field below. See backward - * compatibility notes below. According to our stability guarantees this field - * will be removed in 12 months, on Oct 22, 2021. All usage of old senders and - * receivers that do not understand the `code` field MUST be phased out by then. * @type string $message * A developer-facing human readable error message. * @type int $code @@ -62,40 +46,6 @@ public function __construct($data = NULL) { parent::__construct($data); } - /** - * The deprecated status code. This is an optional field. - * This field is deprecated and is replaced by the `code` field below. See backward - * compatibility notes below. According to our stability guarantees this field - * will be removed in 12 months, on Oct 22, 2021. All usage of old senders and - * receivers that do not understand the `code` field MUST be phased out by then. - * - * Generated from protobuf field .opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode deprecated_code = 1 [deprecated = true]; - * @return int - */ - public function getDeprecatedCode() - { - return $this->deprecated_code; - } - - /** - * The deprecated status code. This is an optional field. - * This field is deprecated and is replaced by the `code` field below. See backward - * compatibility notes below. According to our stability guarantees this field - * will be removed in 12 months, on Oct 22, 2021. All usage of old senders and - * receivers that do not understand the `code` field MUST be phased out by then. - * - * Generated from protobuf field .opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode deprecated_code = 1 [deprecated = true]; - * @param int $var - * @return $this - */ - public function setDeprecatedCode($var) - { - GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\Status_DeprecatedStatusCode::class); - $this->deprecated_code = $var; - - return $this; - } - /** * A developer-facing human readable error message. * @@ -142,7 +92,7 @@ public function getCode() */ public function setCode($var) { - GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\Status_StatusCode::class); + GPBUtil::checkEnum($var, \Opentelemetry\Proto\Trace\V1\Status\StatusCode::class); $this->code = $var; return $this; diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Status/DeprecatedStatusCode.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Status/DeprecatedStatusCode.php index a16570f3e..9a078e2ef 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Status/DeprecatedStatusCode.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Status/DeprecatedStatusCode.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Trace\V1\Status; +use UnexpectedValueException; + /** * Protobuf type opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode */ @@ -77,6 +79,46 @@ class DeprecatedStatusCode * Generated from protobuf enum DEPRECATED_STATUS_CODE_UNAUTHENTICATED = 16; */ const DEPRECATED_STATUS_CODE_UNAUTHENTICATED = 16; + + private static $valueToName = [ + self::DEPRECATED_STATUS_CODE_OK => 'DEPRECATED_STATUS_CODE_OK', + self::DEPRECATED_STATUS_CODE_CANCELLED => 'DEPRECATED_STATUS_CODE_CANCELLED', + self::DEPRECATED_STATUS_CODE_UNKNOWN_ERROR => 'DEPRECATED_STATUS_CODE_UNKNOWN_ERROR', + self::DEPRECATED_STATUS_CODE_INVALID_ARGUMENT => 'DEPRECATED_STATUS_CODE_INVALID_ARGUMENT', + self::DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED => 'DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED', + self::DEPRECATED_STATUS_CODE_NOT_FOUND => 'DEPRECATED_STATUS_CODE_NOT_FOUND', + self::DEPRECATED_STATUS_CODE_ALREADY_EXISTS => 'DEPRECATED_STATUS_CODE_ALREADY_EXISTS', + self::DEPRECATED_STATUS_CODE_PERMISSION_DENIED => 'DEPRECATED_STATUS_CODE_PERMISSION_DENIED', + self::DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED => 'DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED', + self::DEPRECATED_STATUS_CODE_FAILED_PRECONDITION => 'DEPRECATED_STATUS_CODE_FAILED_PRECONDITION', + self::DEPRECATED_STATUS_CODE_ABORTED => 'DEPRECATED_STATUS_CODE_ABORTED', + self::DEPRECATED_STATUS_CODE_OUT_OF_RANGE => 'DEPRECATED_STATUS_CODE_OUT_OF_RANGE', + self::DEPRECATED_STATUS_CODE_UNIMPLEMENTED => 'DEPRECATED_STATUS_CODE_UNIMPLEMENTED', + self::DEPRECATED_STATUS_CODE_INTERNAL_ERROR => 'DEPRECATED_STATUS_CODE_INTERNAL_ERROR', + self::DEPRECATED_STATUS_CODE_UNAVAILABLE => 'DEPRECATED_STATUS_CODE_UNAVAILABLE', + self::DEPRECATED_STATUS_CODE_DATA_LOSS => 'DEPRECATED_STATUS_CODE_DATA_LOSS', + self::DEPRECATED_STATUS_CODE_UNAUTHENTICATED => 'DEPRECATED_STATUS_CODE_UNAUTHENTICATED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/Status/StatusCode.php b/proto/otel/Opentelemetry/Proto/Trace/V1/Status/StatusCode.php index ae6959550..0ce2d1638 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/Status/StatusCode.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/Status/StatusCode.php @@ -4,6 +4,8 @@ namespace Opentelemetry\Proto\Trace\V1\Status; +use UnexpectedValueException; + /** * For the semantics of status codes see * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status @@ -31,6 +33,32 @@ class StatusCode * Generated from protobuf enum STATUS_CODE_ERROR = 2; */ const STATUS_CODE_ERROR = 2; + + private static $valueToName = [ + self::STATUS_CODE_UNSET => 'STATUS_CODE_UNSET', + self::STATUS_CODE_OK => 'STATUS_CODE_OK', + self::STATUS_CODE_ERROR => 'STATUS_CODE_ERROR', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } } // Adding a class alias for backwards compatibility with the previous class name. diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/TraceConfig.php b/proto/otel/Opentelemetry/Proto/Trace/V1/TraceConfig.php index c615da262..9fb54df9b 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/TraceConfig.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/TraceConfig.php @@ -21,31 +21,31 @@ class TraceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 max_number_of_attributes = 4; */ - private $max_number_of_attributes = 0; + protected $max_number_of_attributes = 0; /** * The global default max number of annotation events per span. * * Generated from protobuf field int64 max_number_of_timed_events = 5; */ - private $max_number_of_timed_events = 0; + protected $max_number_of_timed_events = 0; /** * The global default max number of attributes per timed event. * * Generated from protobuf field int64 max_number_of_attributes_per_timed_event = 6; */ - private $max_number_of_attributes_per_timed_event = 0; + protected $max_number_of_attributes_per_timed_event = 0; /** * The global default max number of link entries per span. * * Generated from protobuf field int64 max_number_of_links = 7; */ - private $max_number_of_links = 0; + protected $max_number_of_links = 0; /** * The global default max number of attributes per span. * * Generated from protobuf field int64 max_number_of_attributes_per_link = 8; */ - private $max_number_of_attributes_per_link = 0; + protected $max_number_of_attributes_per_link = 0; protected $sampler; /** @@ -76,13 +76,18 @@ public function __construct($data = NULL) { /** * Generated from protobuf field .opentelemetry.proto.trace.v1.ConstantSampler constant_sampler = 1; - * @return \Opentelemetry\Proto\Trace\V1\ConstantSampler + * @return \Opentelemetry\Proto\Trace\V1\ConstantSampler|null */ public function getConstantSampler() { return $this->readOneof(1); } + public function hasConstantSampler() + { + return $this->hasOneof(1); + } + /** * Generated from protobuf field .opentelemetry.proto.trace.v1.ConstantSampler constant_sampler = 1; * @param \Opentelemetry\Proto\Trace\V1\ConstantSampler $var @@ -98,13 +103,18 @@ public function setConstantSampler($var) /** * Generated from protobuf field .opentelemetry.proto.trace.v1.TraceIdRatioBased trace_id_ratio_based = 2; - * @return \Opentelemetry\Proto\Trace\V1\TraceIdRatioBased + * @return \Opentelemetry\Proto\Trace\V1\TraceIdRatioBased|null */ public function getTraceIdRatioBased() { return $this->readOneof(2); } + public function hasTraceIdRatioBased() + { + return $this->hasOneof(2); + } + /** * Generated from protobuf field .opentelemetry.proto.trace.v1.TraceIdRatioBased trace_id_ratio_based = 2; * @param \Opentelemetry\Proto\Trace\V1\TraceIdRatioBased $var @@ -120,13 +130,18 @@ public function setTraceIdRatioBased($var) /** * Generated from protobuf field .opentelemetry.proto.trace.v1.RateLimitingSampler rate_limiting_sampler = 3; - * @return \Opentelemetry\Proto\Trace\V1\RateLimitingSampler + * @return \Opentelemetry\Proto\Trace\V1\RateLimitingSampler|null */ public function getRateLimitingSampler() { return $this->readOneof(3); } + public function hasRateLimitingSampler() + { + return $this->hasOneof(3); + } + /** * Generated from protobuf field .opentelemetry.proto.trace.v1.RateLimitingSampler rate_limiting_sampler = 3; * @param \Opentelemetry\Proto\Trace\V1\RateLimitingSampler $var diff --git a/proto/otel/Opentelemetry/Proto/Trace/V1/TraceIdRatioBased.php b/proto/otel/Opentelemetry/Proto/Trace/V1/TraceIdRatioBased.php index cf958f022..a04435c36 100644 --- a/proto/otel/Opentelemetry/Proto/Trace/V1/TraceIdRatioBased.php +++ b/proto/otel/Opentelemetry/Proto/Trace/V1/TraceIdRatioBased.php @@ -21,7 +21,7 @@ class TraceIdRatioBased extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double samplingRatio = 1; */ - private $samplingRatio = 0.0; + protected $samplingRatio = 0.0; /** * Constructor. diff --git a/proto/otel/VERSION b/proto/otel/VERSION index fd2726c91..cfe6c0094 100644 --- a/proto/otel/VERSION +++ b/proto/otel/VERSION @@ -1 +1 @@ -v0.11.0 +v0.16.0 diff --git a/script/proto_gen.sh b/script/proto_gen.sh index 71851b9e8..37bc699e8 100755 --- a/script/proto_gen.sh +++ b/script/proto_gen.sh @@ -1,31 +1,35 @@ -apk update && apk add git - -DESTINATION_DIR=/mnt/proto/otel +#!/usr/bin/env bash +DESTINATION_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")/../proto/otel +GPBMETA_DIR="GPBMetadata" +OTEL_DIR="Opentelemetry" REPO_DIR=opentelemetry-proto -mkdir -p $DESTINATION_DIR -rm -R ./$REPO_DIR -git clone https://github.com/open-telemetry/$REPO_DIR +cd "${DESTINATION_DIR}" || exit +[[ -d ./${REPO_DIR} ]] && rm -rf ./${REPO_DIR} +git clone https://github.com/open-telemetry/${REPO_DIR} -TAG=$( - # shellcheck disable=SC2164 - cd ./$REPO_DIR +( + cd ${REPO_DIR} + git config --add advice.detachedHead false + TAG=$( + TAG=$(git describe --tags `git rev-list --tags --max-count=1`) - # shellcheck disable=SC2046 - # shellcheck disable=SC2006 - TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + git checkout "${TAG}" - git checkout "${TAG}" + echo "${TAG}" + ) - echo "$TAG" + echo "Generating protobuf files for version ${TAG} ..." + make gen-php + [[ -d ${GPBMETA_DIR} ]] && rm -rf ${GPBMETA_DIR} + [[ -d ${OTEL_DIR} ]] && rm -rf ${OTEL_DIR} + echo "${TAG}" > "${DESTINATION_DIR}/VERSION" ) -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 "Copying generated source..." +cp -r ${REPO_DIR}/gen/php/${GPBMETA_DIR} . +cp -r ${REPO_DIR}/gen/php/${OTEL_DIR} . +echo "Cleaning up..." +rm -rf ./${REPO_DIR} echo "Done!" diff --git a/src/API/Metrics/MeterProviderInterface.php b/src/API/Metrics/MeterProviderInterface.php index 7453f3c7a..74a0a6085 100644 --- a/src/API/Metrics/MeterProviderInterface.php +++ b/src/API/Metrics/MeterProviderInterface.php @@ -8,13 +8,13 @@ interface MeterProviderInterface { /** * @access public - * @param string $name - (required) - This name must identify the instrumentation library + * @param string $name - (required) - This name must identify the instrumentation scope * (e.g. io.opentelemetry.contrib.mongodb) and not the instrumented library. * In case an invalid name (null or empty string) is specified, a working default Meter implementation is returned * as a fallback rather than returning null or throwing an exception. * A MeterProvider could also return a no-op Meter here if application owners configure the SDK to suppress * telemetry produced by this library. - * @param ?string $version - (optional) - Specifies the version of the instrumentation library (e.g. semver:1.0.0) + * @param ?string $version - (optional) - Specifies the version of the instrumentation scope (e.g. semver:1.0.0) * @return MeterInterface */ public function getMeter(string $name, ?string $version = null): MeterInterface; diff --git a/src/Contrib/Jaeger/SpanConverter.php b/src/Contrib/Jaeger/SpanConverter.php index d1bfaddef..ded2770e5 100644 --- a/src/Contrib/Jaeger/SpanConverter.php +++ b/src/Contrib/Jaeger/SpanConverter.php @@ -25,8 +25,8 @@ class SpanConverter implements SpanConverterInterface const STATUS_ERROR = 'ERROR'; const KEY_ERROR_FLAG = 'error'; const STATUS_DESCRIPTION_TAG_KEY = 'otel.status_description'; - const KEY_INSTRUMENTATION_LIBRARY_NAME = 'otel.library.name'; - const KEY_INSTRUMENTATION_LIBRARY_VERSION = 'otel.library.version'; + const KEY_INSTRUMENTATION_SCOPE_NAME = 'otel.scope.name'; + const KEY_INSTRUMENTATION_SCOPE_VERSION = 'otel.scope.version'; const KEY_SPAN_KIND = 'span.kind'; const JAEGER_SPAN_KIND_CLIENT = 'client'; const JAEGER_SPAN_KIND_SERVER = 'server'; @@ -150,12 +150,12 @@ private static function convertOtelSpanDataToJaegerTags(SpanDataInterface $span) } } - if (!empty($span->getInstrumentationLibrary()->getName())) { - $tags[SpanConverter::KEY_INSTRUMENTATION_LIBRARY_NAME] = $span->getInstrumentationLibrary()->getName(); + if (!empty($span->getInstrumentationScope()->getName())) { + $tags[SpanConverter::KEY_INSTRUMENTATION_SCOPE_NAME] = $span->getInstrumentationScope()->getName(); } - if ($span->getInstrumentationLibrary()->getVersion() !== null) { - $tags[SpanConverter::KEY_INSTRUMENTATION_LIBRARY_VERSION] = $span->getInstrumentationLibrary()->getVersion(); + if ($span->getInstrumentationScope()->getVersion() !== null) { + $tags[SpanConverter::KEY_INSTRUMENTATION_SCOPE_VERSION] = $span->getInstrumentationScope()->getVersion(); } $jaegerSpanKind = self::convertOtelSpanKindToJaeger($span); diff --git a/src/Contrib/Otlp/SpanConverter.php b/src/Contrib/Otlp/SpanConverter.php index 5b5cbdaae..f24867e83 100644 --- a/src/Contrib/Otlp/SpanConverter.php +++ b/src/Contrib/Otlp/SpanConverter.php @@ -9,11 +9,11 @@ use OpenTelemetry\API\Trace as API; use Opentelemetry\Proto\Common\V1\AnyValue; use Opentelemetry\Proto\Common\V1\ArrayValue; -use Opentelemetry\Proto\Common\V1\InstrumentationLibrary; +use Opentelemetry\Proto\Common\V1\InstrumentationScope; use Opentelemetry\Proto\Common\V1\KeyValue; use Opentelemetry\Proto\Resource\V1\Resource; -use Opentelemetry\Proto\Trace\V1\InstrumentationLibrarySpans; use Opentelemetry\Proto\Trace\V1\ResourceSpans; +use Opentelemetry\Proto\Trace\V1\ScopeSpans; use Opentelemetry\Proto\Trace\V1\Span as CollectorSpan; use Opentelemetry\Proto\Trace\V1\Span\Event; use Opentelemetry\Proto\Trace\V1\Span\Link; @@ -186,30 +186,30 @@ private function as_otlp_resource_span(iterable $spans): ResourceSpans { $isSpansEmpty = true; //Waiting for the loop to prove otherwise - $ils = $convertedSpans = $schemas = []; + $instrumentationScopes = $convertedSpans = $schemas = []; foreach ($spans as /** @var SpanDataInterface $span */ $span) { $isSpansEmpty = false; - $il = $span->getInstrumentationLibrary(); - $ilKey = KeyGenerator::generateInstanceKey($il->getName(), $il->getVersion(), $il->getSchemaUrl()); - if (!isset($ils[$ilKey])) { - $convertedSpans[$ilKey] = []; - $ils[$ilKey] = new InstrumentationLibrary(['name' => $il->getName(), 'version' => $il->getVersion() ?? '']); - $schemas[$ilKey] = $il->getSchemaUrl(); + $scope = $span->getInstrumentationScope(); + $isKey = KeyGenerator::generateInstanceKey($scope->getName(), $scope->getVersion(), $scope->getSchemaUrl()); + if (!isset($instrumentationScopes[$isKey])) { + $convertedSpans[$isKey] = []; + $instrumentationScopes[$isKey] = new InstrumentationScope(['name' => $scope->getName(), 'version' => $scope->getVersion() ?? '']); + $schemas[$isKey] = $scope->getSchemaUrl(); } - $convertedSpans[$ilKey][] = $this->as_otlp_span($span); + $convertedSpans[$isKey][] = $this->as_otlp_span($span); } if ($isSpansEmpty == true) { return new ResourceSpans(); } - $ilSpans = []; - foreach ($ils as $ilKey => $il) { - $ilSpans[] = new InstrumentationLibrarySpans([ - 'instrumentation_library' => $il, - 'spans' => $convertedSpans[$ilKey], - 'schema_url' => $schemas[$ilKey] ?? '', + $isSpans = []; + foreach ($instrumentationScopes as $isKey => $scope) { + $isSpans[] = new ScopeSpans([ + 'scope' => $scope, + 'spans' => $convertedSpans[$isKey], + 'schema_url' => $schemas[$isKey] ?? '', ]); } @@ -217,7 +217,7 @@ private function as_otlp_resource_span(iterable $spans): ResourceSpans 'resource' => new Resource([ 'attributes' => $this->as_otlp_resource_attributes($spans), ]), - 'instrumentation_library_spans' => $ilSpans, + 'scope_spans' => $isSpans, ]); } } diff --git a/src/Contrib/OtlpGrpc/Exporter.php b/src/Contrib/OtlpGrpc/Exporter.php index de9e33253..6687d2ae2 100644 --- a/src/Contrib/OtlpGrpc/Exporter.php +++ b/src/Contrib/OtlpGrpc/Exporter.php @@ -119,6 +119,8 @@ protected function doExport(iterable $spans): int [$response, $status] = $this->client->Export($request)->wait(); if ($status->code === \Grpc\STATUS_OK) { + self::logDebug('Exported span(s)', ['spans' => $resourceSpans]); + return self::STATUS_SUCCESS; } diff --git a/src/Contrib/Zipkin/SpanConverter.php b/src/Contrib/Zipkin/SpanConverter.php index 717f2c66e..4857d16dc 100644 --- a/src/Contrib/Zipkin/SpanConverter.php +++ b/src/Contrib/Zipkin/SpanConverter.php @@ -17,8 +17,8 @@ class SpanConverter implements SpanConverterInterface { const STATUS_CODE_TAG_KEY = 'otel.status_code'; const STATUS_DESCRIPTION_TAG_KEY = 'error'; - const KEY_INSTRUMENTATION_LIBRARY_NAME = 'otel.library.name'; - const KEY_INSTRUMENTATION_LIBRARY_VERSION = 'otel.library.version'; + const KEY_INSTRUMENTATION_SCOPE_NAME = 'otel.scope.name'; + const KEY_INSTRUMENTATION_SCOPE_VERSION = 'otel.scope.version'; const REMOTE_ENDPOINT_PREFERRED_ATTRIBUTE_TO_RANK_MAP = [ 'peer.service' => 1, @@ -107,12 +107,12 @@ private function convertSpan(SpanDataInterface $span): array $row['tags'][self::STATUS_DESCRIPTION_TAG_KEY] = $span->getStatus()->getDescription(); } - if (!empty($span->getInstrumentationLibrary()->getName())) { - $row[SpanConverter::KEY_INSTRUMENTATION_LIBRARY_NAME] = $span->getInstrumentationLibrary()->getName(); + if (!empty($span->getInstrumentationScope()->getName())) { + $row[SpanConverter::KEY_INSTRUMENTATION_SCOPE_NAME] = $span->getInstrumentationScope()->getName(); } - if ($span->getInstrumentationLibrary()->getVersion() !== null) { - $row[SpanConverter::KEY_INSTRUMENTATION_LIBRARY_VERSION] = $span->getInstrumentationLibrary()->getVersion(); + if ($span->getInstrumentationScope()->getVersion() !== null) { + $row[SpanConverter::KEY_INSTRUMENTATION_SCOPE_VERSION] = $span->getInstrumentationScope()->getVersion(); } foreach ($span->getAttributes() as $k => $v) { diff --git a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php index 6a49be3ce..476e7c950 100644 --- a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php +++ b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php @@ -5,7 +5,7 @@ namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC; use OpenTelemetry\SDK\Common\Dev\Compatibility\Util; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary as Moved; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope as Moved; /** * @codeCoverageIgnoreStart diff --git a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationScopeInterface.php similarity index 79% rename from src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php rename to src/SDK/Common/Dev/Compatibility/BC/InstrumentationScopeInterface.php index 6c01083b1..5a69a4ce6 100644 --- a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php +++ b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationScopeInterface.php @@ -4,7 +4,7 @@ namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface as Moved; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface as Moved; interface InstrumentationLibraryInterface extends Moved { diff --git a/src/SDK/Common/Dev/Compatibility/_load.php b/src/SDK/Common/Dev/Compatibility/_load.php index d2773d97a..7ea1647cb 100644 --- a/src/SDK/Common/Dev/Compatibility/_load.php +++ b/src/SDK/Common/Dev/Compatibility/_load.php @@ -10,5 +10,5 @@ require_once __DIR__ . '/BC/AbstractClock.php'; require_once __DIR__ . '/BC/SystemClock.php'; require_once __DIR__ . '/BC/GlobalLoggerHolder.php'; -require_once __DIR__ . '/BC/InstrumentationLibraryInterface.php'; +require_once __DIR__ . '/BC/InstrumentationScopeInterface.php'; require_once __DIR__ . '/BC/InstrumentationLibrary.php'; diff --git a/src/SDK/Common/Instrumentation/InstrumentationLibrary.php b/src/SDK/Common/Instrumentation/InstrumentationScope.php similarity index 78% rename from src/SDK/Common/Instrumentation/InstrumentationLibrary.php rename to src/SDK/Common/Instrumentation/InstrumentationScope.php index 4e6cd180a..e0012ecab 100644 --- a/src/SDK/Common/Instrumentation/InstrumentationLibrary.php +++ b/src/SDK/Common/Instrumentation/InstrumentationScope.php @@ -5,9 +5,9 @@ namespace OpenTelemetry\SDK\Common\Instrumentation; /** - * Represents the instrumentation library information associated with the Tracer or Meter + * Represents the instrumentation scope information associated with the Tracer or Meter */ -final class InstrumentationLibrary implements InstrumentationLibraryInterface +final class InstrumentationScope implements InstrumentationScopeInterface { private static ?self $empty = null; @@ -26,7 +26,7 @@ public function __construct(string $name, ?string $version = null, ?string $sche * @internal * @psalm-internal OpenTelemetry */ - public static function getEmpty(): InstrumentationLibrary + public static function getEmpty(): InstrumentationScope { return self::$empty ?? self::$empty = new self('', null, null); } diff --git a/src/SDK/Common/Instrumentation/InstrumentationLibraryInterface.php b/src/SDK/Common/Instrumentation/InstrumentationScopeInterface.php similarity index 83% rename from src/SDK/Common/Instrumentation/InstrumentationLibraryInterface.php rename to src/SDK/Common/Instrumentation/InstrumentationScopeInterface.php index c62efac5d..806099441 100644 --- a/src/SDK/Common/Instrumentation/InstrumentationLibraryInterface.php +++ b/src/SDK/Common/Instrumentation/InstrumentationScopeInterface.php @@ -4,7 +4,7 @@ namespace OpenTelemetry\SDK\Common\Instrumentation; -interface InstrumentationLibraryInterface +interface InstrumentationScopeInterface { public function getName(): string; diff --git a/src/SDK/Common/Instrumentation/KeyGenerator.php b/src/SDK/Common/Instrumentation/KeyGenerator.php index 27868f49e..d7598feb1 100644 --- a/src/SDK/Common/Instrumentation/KeyGenerator.php +++ b/src/SDK/Common/Instrumentation/KeyGenerator.php @@ -7,7 +7,7 @@ class KeyGenerator { /** - * Generate a unique key for an instance of InstrumentationLibrary, with parameters matching those of the + * Generate a unique key for an instance of InstrumentationScope, with parameters matching those of the * class' constructor. * @param string $name * @param ?string $version diff --git a/src/SDK/Trace/ImmutableSpan.php b/src/SDK/Trace/ImmutableSpan.php index 39305d09a..86a67640a 100644 --- a/src/SDK/Trace/ImmutableSpan.php +++ b/src/SDK/Trace/ImmutableSpan.php @@ -7,7 +7,7 @@ use function max; use OpenTelemetry\API\Trace as API; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; use OpenTelemetry\SDK\Resource\ResourceInfo; /** @@ -102,9 +102,9 @@ public function getEndEpochNanos(): int return $this->endEpochNanos; } - public function getInstrumentationLibrary(): InstrumentationLibraryInterface + public function getInstrumentationScope(): InstrumentationScopeInterface { - return $this->span->getInstrumentationLibrary(); + return $this->span->getInstrumentationScope(); } public function getResource(): ResourceInfo diff --git a/src/SDK/Trace/ReadableSpanInterface.php b/src/SDK/Trace/ReadableSpanInterface.php index e6ad2a307..40704ab4e 100644 --- a/src/SDK/Trace/ReadableSpanInterface.php +++ b/src/SDK/Trace/ReadableSpanInterface.php @@ -5,7 +5,7 @@ namespace OpenTelemetry\SDK\Trace; use OpenTelemetry\API\Trace as API; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; /** * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/sdk.md#additional-span-interfaces @@ -18,7 +18,7 @@ public function getContext(): API\SpanContextInterface; public function getParentContext(): API\SpanContextInterface; - public function getInstrumentationLibrary(): InstrumentationLibraryInterface; + public function getInstrumentationScope(): InstrumentationScopeInterface; public function hasEnded(): bool; diff --git a/src/SDK/Trace/Span.php b/src/SDK/Trace/Span.php index 3db01336d..2711970b7 100644 --- a/src/SDK/Trace/Span.php +++ b/src/SDK/Trace/Span.php @@ -16,7 +16,7 @@ use OpenTelemetry\SDK\Common\Attribute\AttributeLimits; use OpenTelemetry\SDK\Common\Attribute\Attributes; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; use OpenTelemetry\SDK\Common\Time\ClockFactory; use OpenTelemetry\SDK\Resource\ResourceInfo; use function sprintf; @@ -55,7 +55,7 @@ final class Span extends API\AbstractSpan implements ReadWriteSpanInterface private ResourceInfo $resource; /** @readonly */ - private InstrumentationLibraryInterface $instrumentationLibrary; + private InstrumentationScopeInterface $instrumentationScope; /** @readonly */ private int $startEpochNanos; @@ -79,7 +79,7 @@ final class Span extends API\AbstractSpan implements ReadWriteSpanInterface private function __construct( string $name, API\SpanContextInterface $context, - InstrumentationLibraryInterface $instrumentationLibrary, + InstrumentationScopeInterface $instrumentationScope, int $kind, API\SpanContextInterface $parentSpanContext, SpanLimits $spanLimits, @@ -91,7 +91,7 @@ private function __construct( int $startEpochNanos ) { $this->context = $context; - $this->instrumentationLibrary = $instrumentationLibrary; + $this->instrumentationScope = $instrumentationScope; $this->parentSpanContext = $parentSpanContext; $this->links = $links; $this->totalRecordedLinks = $totalRecordedLinks; @@ -119,7 +119,7 @@ private function __construct( public static function startSpan( string $name, API\SpanContextInterface $context, - InstrumentationLibraryInterface $instrumentationLibrary, + InstrumentationScopeInterface $instrumentationScope, int $kind, API\SpanInterface $parentSpan, Context $parentContext, @@ -134,7 +134,7 @@ public static function startSpan( $span = new self( $name, $context, - $instrumentationLibrary, + $instrumentationScope, $kind, $parentSpan->getContext(), $spanLimits, @@ -338,9 +338,9 @@ public function getParentContext(): API\SpanContextInterface return $this->parentSpanContext; } - public function getInstrumentationLibrary(): InstrumentationLibraryInterface + public function getInstrumentationScope(): InstrumentationScopeInterface { - return $this->instrumentationLibrary; + return $this->instrumentationScope; } public function hasEnded(): bool diff --git a/src/SDK/Trace/SpanBuilder.php b/src/SDK/Trace/SpanBuilder.php index 75bbef2cc..4caaefec8 100644 --- a/src/SDK/Trace/SpanBuilder.php +++ b/src/SDK/Trace/SpanBuilder.php @@ -10,7 +10,7 @@ use OpenTelemetry\SDK\Common\Attribute\AttributeLimits; use OpenTelemetry\SDK\Common\Attribute\Attributes; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; final class SpanBuilder implements API\SpanBuilderInterface { @@ -21,7 +21,7 @@ final class SpanBuilder implements API\SpanBuilderInterface private string $spanName; /** @readonly */ - private InstrumentationLibraryInterface $instrumentationLibrary; + private InstrumentationScopeInterface $instrumentationScope; /** @readonly */ private TracerSharedState $tracerSharedState; @@ -46,12 +46,12 @@ final class SpanBuilder implements API\SpanBuilderInterface /** @param non-empty-string $spanName */ public function __construct( string $spanName, - InstrumentationLibraryInterface $instrumentationLibrary, + InstrumentationScopeInterface $instrumentationScope, TracerSharedState $tracerSharedState, SpanLimits $spanLimits ) { $this->spanName = $spanName; - $this->instrumentationLibrary = $instrumentationLibrary; + $this->instrumentationScope = $instrumentationScope; $this->tracerSharedState = $tracerSharedState; $this->spanLimits = $spanLimits; } @@ -206,7 +206,7 @@ public function startSpan(): API\SpanInterface return Span::startSpan( $this->spanName, $spanContext, - $this->instrumentationLibrary, + $this->instrumentationScope, $this->spanKind, $parentSpan, $parentContext, diff --git a/src/SDK/Trace/SpanDataInterface.php b/src/SDK/Trace/SpanDataInterface.php index b3ea59142..ac5c61c2b 100644 --- a/src/SDK/Trace/SpanDataInterface.php +++ b/src/SDK/Trace/SpanDataInterface.php @@ -6,7 +6,7 @@ use OpenTelemetry\API\Trace as API; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; use OpenTelemetry\SDK\Resource\ResourceInfo; /** @@ -35,7 +35,7 @@ public function getLinks(): array; public function getEndEpochNanos(): int; public function hasEnded(): bool; - public function getInstrumentationLibrary(): InstrumentationLibraryInterface; + public function getInstrumentationScope(): InstrumentationScopeInterface; public function getResource(): ResourceInfo; /** @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/sdk_exporters/non-otlp.md#dropped-events-count */ diff --git a/src/SDK/Trace/Tracer.php b/src/SDK/Trace/Tracer.php index 953b1b9b3..06478904b 100644 --- a/src/SDK/Trace/Tracer.php +++ b/src/SDK/Trace/Tracer.php @@ -6,7 +6,7 @@ use function ctype_space; use OpenTelemetry\API\Trace as API; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface; class Tracer implements API\TracerInterface { @@ -16,14 +16,14 @@ class Tracer implements API\TracerInterface private TracerSharedState $tracerSharedState; /** @readonly */ - private InstrumentationLibraryInterface $instrumentationLibrary; + private InstrumentationScopeInterface $instrumentationScope; public function __construct( TracerSharedState $tracerSharedState, - InstrumentationLibraryInterface $instrumentationLibrary + InstrumentationScopeInterface $instrumentationScope ) { $this->tracerSharedState = $tracerSharedState; - $this->instrumentationLibrary = $instrumentationLibrary; + $this->instrumentationScope = $instrumentationScope; } /** @inheritDoc */ @@ -39,14 +39,14 @@ public function spanBuilder(string $spanName): API\SpanBuilderInterface return new SpanBuilder( $spanName, - $this->instrumentationLibrary, + $this->instrumentationScope, $this->tracerSharedState, $this->tracerSharedState->getSpanLimits() ); } - public function getInstrumentationLibrary(): InstrumentationLibraryInterface + public function getInstrumentationScope(): InstrumentationScopeInterface { - return $this->instrumentationLibrary; + return $this->instrumentationScope; } } diff --git a/src/SDK/Trace/TracerProvider.php b/src/SDK/Trace/TracerProvider.php index 837d089e2..ddf1c0a5e 100644 --- a/src/SDK/Trace/TracerProvider.php +++ b/src/SDK/Trace/TracerProvider.php @@ -7,7 +7,7 @@ use function is_array; use OpenTelemetry\API\Trace as API; use OpenTelemetry\API\Trace\NoopTracer; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Common\Instrumentation\KeyGenerator; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Resource\ResourceInfoFactory; @@ -74,11 +74,11 @@ public function getTracer(string $name = self::DEFAULT_TRACER_NAME, ?string $ver return $this->tracers[$key]; } - $instrumentationLibrary = new InstrumentationLibrary($name, $version, $schemaUrl); + $instrumentationScope = new InstrumentationScope($name, $version, $schemaUrl); $tracer = new Tracer( $this->tracerSharedState, - $instrumentationLibrary, + $instrumentationScope, ); if (null === self::$defaultTracer) { self::$defaultTracer = $tracer; diff --git a/tests/Integration/SDK/TracerTest.php b/tests/Integration/SDK/TracerTest.php index a158f45b0..09c1f64e9 100644 --- a/tests/Integration/SDK/TracerTest.php +++ b/tests/Integration/SDK/TracerTest.php @@ -68,20 +68,20 @@ public function test_sampler_may_override_parents_trace_state(): void $this->assertEquals($newTraceState, $span->getContext()->getTraceState()); } - public function test_span_should_receive_instrumentation_library(): void + public function test_span_should_receive_instrumentation_scope(): void { $tracerProvider = new TracerProvider(); $tracer = $tracerProvider->getTracer('OpenTelemetry.TracerTest', 'dev', 'http://url'); /** @var Span $span */ $span = $tracer->spanBuilder('test.span')->startSpan(); - $spanInstrumentationLibrary = $span->getInstrumentationLibrary(); + $spanInstrumentationScope = $span->getInstrumentationScope(); - $this->assertEquals('OpenTelemetry.TracerTest', $spanInstrumentationLibrary->getName()); - $this->assertEquals('dev', $spanInstrumentationLibrary->getVersion()); - $this->assertEquals('http://url', $spanInstrumentationLibrary->getSchemaUrl()); + $this->assertEquals('OpenTelemetry.TracerTest', $spanInstrumentationScope->getName()); + $this->assertEquals('dev', $spanInstrumentationScope->getVersion()); + $this->assertEquals('http://url', $spanInstrumentationScope->getSchemaUrl()); } - public function test_span_builder_propagates_instrumentation_library_info_to_span(): void + public function test_span_builder_propagates_instrumentation_scope_info_to_span(): void { /** @var Span $span */ $span = (new TracerProvider()) @@ -89,7 +89,7 @@ public function test_span_builder_propagates_instrumentation_library_info_to_spa ->spanBuilder('span') ->startSpan(); - $this->assertSame('name', $span->getInstrumentationLibrary()->getName()); - $this->assertSame('version', $span->getInstrumentationLibrary()->getVersion()); + $this->assertSame('name', $span->getInstrumentationScope()->getName()); + $this->assertSame('version', $span->getInstrumentationScope()->getVersion()); } } diff --git a/tests/Unit/Contrib/JaegerSpanConverterTest.php b/tests/Unit/Contrib/JaegerSpanConverterTest.php index cf75563db..8d275e84e 100644 --- a/tests/Unit/Contrib/JaegerSpanConverterTest.php +++ b/tests/Unit/Contrib/JaegerSpanConverterTest.php @@ -9,7 +9,7 @@ use OpenTelemetry\API\Trace\StatusCode; use OpenTelemetry\Contrib\Jaeger\SpanConverter; use OpenTelemetry\SDK\Common\Attribute\Attributes; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Trace\Event; use OpenTelemetry\SDK\Trace\Link; @@ -53,9 +53,9 @@ public function test_should_correctly_generate_jaeger_thrift_tags() 'status_description' ) ) - ->setInstrumentationLibrary(new InstrumentationLibrary( - 'instrumentation_library_name', - 'instrumentation_library_version' + ->setInstrumentationScope(new InstrumentationScope( + 'instrumentation_scope_name', + 'instrumentation_scope_version' )) ->addAttribute('keyForBoolean', true) ->addAttribute('keyForArray', ['1stElement', '2ndElement', true]) @@ -81,11 +81,11 @@ public function test_should_correctly_generate_jaeger_thrift_tags() $this->assertSame('otel.status_description', $convertedSpan->tags[1]->key); $this->assertSame('status_description', $convertedSpan->tags[1]->vStr); - $this->assertSame('otel.library.name', $convertedSpan->tags[2]->key); - $this->assertSame('instrumentation_library_name', $convertedSpan->tags[2]->vStr); + $this->assertSame('otel.scope.name', $convertedSpan->tags[2]->key); + $this->assertSame('instrumentation_scope_name', $convertedSpan->tags[2]->vStr); - $this->assertSame('otel.library.version', $convertedSpan->tags[3]->key); - $this->assertSame('instrumentation_library_version', $convertedSpan->tags[3]->vStr); + $this->assertSame('otel.scope.version', $convertedSpan->tags[3]->key); + $this->assertSame('instrumentation_scope_version', $convertedSpan->tags[3]->vStr); $this->assertSame('keyForBoolean', $convertedSpan->tags[4]->key); $this->assertTrue($convertedSpan->tags[4]->vBool); diff --git a/tests/Unit/Contrib/OTLPSpanConverterTest.php b/tests/Unit/Contrib/OTLPSpanConverterTest.php index 9c8da828c..8364b70a0 100644 --- a/tests/Unit/Contrib/OTLPSpanConverterTest.php +++ b/tests/Unit/Contrib/OTLPSpanConverterTest.php @@ -13,11 +13,11 @@ use Opentelemetry\Proto\Common\V1\KeyValue; use Opentelemetry\Proto\Resource\V1\Resource; use Opentelemetry\Proto\Trace\V1; -use Opentelemetry\Proto\Trace\V1\InstrumentationLibrarySpans; use Opentelemetry\Proto\Trace\V1\ResourceSpans; +use Opentelemetry\Proto\Trace\V1\ScopeSpans; use Opentelemetry\Proto\Trace\V1\Span\SpanKind as ProtoSpanKind; use OpenTelemetry\SDK\Common\Attribute\Attributes; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Trace\StatusData; use OpenTelemetry\Tests\Unit\SDK\Util\SpanData; @@ -41,7 +41,7 @@ public function test_convert_span_to_payload(): void ->setHasEnded(true); $converter = new SpanConverter(); - $row = $converter->convert([$span])[0]->getInstrumentationLibrarySpans()[0]->getSpans()[0]; + $row = $converter->convert([$span])[0]->getScopeSpans()[0]->getSpans()[0]; $this->assertSame($span->getContext()->getSpanId(), bin2hex($row->getSpanId())); $this->assertSame($span->getContext()->getTraceId(), bin2hex($row->getTraceId())); @@ -69,7 +69,7 @@ public function test_attribute_are_coerced_correctly($actual, $expected): void $converter = new SpanConverter(); $converted = $converter->convert([$span])[0]; - $attributes = $converted->getInstrumentationLibrarySpans()[0]->getSpans()[0]->getAttributes(); + $attributes = $converted->getScopeSpans()[0]->getSpans()[0]->getAttributes(); // Check that we can convert all attributes to tags $this->assertCount(1, $attributes); @@ -164,7 +164,7 @@ public function test_otlp_happy_path_span(): void ->setStartEpochNanos($start_time) ->setEndEpochNanos($end_time) ->setName('http_get') - ->setInstrumentationLibrary(new InstrumentationLibrary('lib-test', 'v0.1.0', 'http://url')) + ->setInstrumentationScope(new InstrumentationScope('lib-test', 'v0.1.0', 'http://url')) ->addAttribute('user', 'alice') ->addAttribute('authenticated', true) ->addEvent('Event1', new Attributes(['success' => 'yes']), 1617313804325769955) @@ -197,9 +197,9 @@ public function test_otlp_happy_path_span(): void ]), ], ]), - 'instrumentation_library_spans' => [ - new InstrumentationLibrarySpans([ - 'instrumentation_library' => new \Opentelemetry\Proto\Common\V1\InstrumentationLibrary([ + 'scope_spans' => [ + new ScopeSpans([ + 'scope' => new \Opentelemetry\Proto\Common\V1\InstrumentationScope([ 'name' => 'lib-test', 'version' => 'v0.1.0', ]), @@ -276,7 +276,7 @@ public function test_otlp_no_spans(): void public function test_span_kind($kind, $expected): void { $span = (new SpanData())->setKind($kind); - $row = (new SpanConverter())->convert([$span])[0]->getInstrumentationLibrarySpans()[0]->getSpans()[0]; + $row = (new SpanConverter())->convert([$span])[0]->getScopeSpans()[0]->getSpans()[0]; $this->assertSame($expected, $row->getKind()); } @@ -295,7 +295,7 @@ public function spanKindProvider(): array public function test_span_with_error_status(): void { $span = (new SpanData())->setStatus(StatusData::error()); - $row = (new SpanConverter())->convert([$span])[0]->getInstrumentationLibrarySpans()[0]->getSpans()[0]; + $row = (new SpanConverter())->convert([$span])[0]->getScopeSpans()[0]->getSpans()[0]; $this->assertSame(V1\Status\StatusCode::STATUS_CODE_ERROR, $row->getStatus()->getCode()); } } diff --git a/tests/Unit/Contrib/ZipkinSpanConverterTest.php b/tests/Unit/Contrib/ZipkinSpanConverterTest.php index 677cc5de5..8cc0d4a28 100644 --- a/tests/Unit/Contrib/ZipkinSpanConverterTest.php +++ b/tests/Unit/Contrib/ZipkinSpanConverterTest.php @@ -10,7 +10,7 @@ use OpenTelemetry\Contrib\Zipkin\SpanConverter; use OpenTelemetry\Contrib\Zipkin\SpanKind as ZipkinSpanKind; use OpenTelemetry\SDK\Common\Attribute\Attributes; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Trace\StatusData; use OpenTelemetry\Tests\Unit\SDK\Util\SpanData; @@ -38,9 +38,9 @@ public function test_should_convert_a_span_to_a_payload_for_zipkin(): void 'status_description' ) ) - ->setInstrumentationLibrary(new InstrumentationLibrary( - 'instrumentation_library_name', - 'instrumentation_library_version' + ->setInstrumentationScope(new InstrumentationScope( + 'instrumentation_scope_name', + 'instrumentation_scope_version' )) ->addAttribute('service', 'guard') ->addAttribute('net.peer.name', 'authorizationservice.com') @@ -85,8 +85,8 @@ public function test_should_convert_a_span_to_a_payload_for_zipkin(): void $this->assertSame('test-a', $row['tags']['instance']); $this->assertSame('unknown_service', $row['tags']['service.name']); - $this->assertSame('instrumentation_library_name', $row['otel.library.name']); - $this->assertSame('instrumentation_library_version', $row['otel.library.version']); + $this->assertSame('instrumentation_scope_name', $row['otel.scope.name']); + $this->assertSame('instrumentation_scope_version', $row['otel.scope.version']); $attribute = $span->getAttributes()->get('service'); $this->assertSame($attribute, $row['tags']['service']); @@ -109,8 +109,8 @@ public function test_should_omit_empty_keys_from_zipkin_span(): void $this->assertArrayNotHasKey('kind', $row); $this->assertArrayNotHasKey('parentId', $row); $this->assertArrayNotHasKey('tags', $row); - $this->assertArrayNotHasKey('otel.library.name', $row); - $this->assertArrayNotHasKey('otel.library.version', $row); + $this->assertArrayNotHasKey('otel.scope.name', $row); + $this->assertArrayNotHasKey('otel.scope.version', $row); } /** diff --git a/tests/Unit/SDK/Common/Instrumentation/InstrumentationLibraryTest.php b/tests/Unit/SDK/Common/Instrumentation/InstrumentationLibraryTest.php deleted file mode 100644 index e04ed1814..000000000 --- a/tests/Unit/SDK/Common/Instrumentation/InstrumentationLibraryTest.php +++ /dev/null @@ -1,36 +0,0 @@ -assertEmpty($library->getName()); - $this->assertNull($library->getVersion()); - $this->assertNull($library->getSchemaUrl()); - } - - public function test_getters(): void - { - $name = 'foo'; - $version = 'bar'; - $schemaUrl = 'http://baz'; - - $library = new InstrumentationLibrary($name, $version, $schemaUrl); - - $this->assertSame($name, $library->getName()); - $this->assertSame($version, $library->getVersion()); - $this->assertSame($schemaUrl, $library->getSchemaUrl()); - } -} diff --git a/tests/Unit/SDK/Common/Instrumentation/InstrumentationScopeTest.php b/tests/Unit/SDK/Common/Instrumentation/InstrumentationScopeTest.php new file mode 100644 index 000000000..498b55c30 --- /dev/null +++ b/tests/Unit/SDK/Common/Instrumentation/InstrumentationScopeTest.php @@ -0,0 +1,36 @@ +assertEmpty($scope->getName()); + $this->assertNull($scope->getVersion()); + $this->assertNull($scope->getSchemaUrl()); + } + + public function test_getters(): void + { + $name = 'foo'; + $version = 'bar'; + $schemaUrl = 'http://baz'; + + $scope = new InstrumentationScope($name, $version, $schemaUrl); + + $this->assertSame($name, $scope->getName()); + $this->assertSame($version, $scope->getVersion()); + $this->assertSame($schemaUrl, $scope->getSchemaUrl()); + } +} diff --git a/tests/Unit/SDK/Trace/ImmutableSpanTest.php b/tests/Unit/SDK/Trace/ImmutableSpanTest.php index eb55fe531..e100d9f31 100644 --- a/tests/Unit/SDK/Trace/ImmutableSpanTest.php +++ b/tests/Unit/SDK/Trace/ImmutableSpanTest.php @@ -7,7 +7,7 @@ use OpenTelemetry\API\Trace as API; use OpenTelemetry\API\Trace\SpanKind; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Trace\ImmutableSpan; use OpenTelemetry\SDK\Trace\Span; @@ -22,7 +22,7 @@ class ImmutableSpanTest extends TestCase private Span $span; private AttributesInterface $attributes; private StatusDataInterface $status; - private InstrumentationLibrary $instrumentationLibrary; + private InstrumentationScope $instrumentationScope; private ResourceInfo $resource; private API\SpanContextInterface $context; private API\SpanContextInterface $parentContext; @@ -40,7 +40,7 @@ protected function setUp():void { $this->context = $this->createMock(API\SpanContextInterface::class); $this->parentContext = $this->createMock(API\SpanContextInterface::class); - $this->instrumentationLibrary = $this->createMock(InstrumentationLibrary::class); + $this->instrumentationScope = $this->createMock(InstrumentationScope::class); $this->resource = $this->createMock(ResourceInfo::class); $this->span = $this->createMock(Span::class); @@ -50,7 +50,7 @@ protected function setUp():void $this->span->method('getKind')->willReturn(SpanKind::KIND_INTERNAL); $this->span->method('getContext')->willReturn($this->context); $this->span->method('getParentContext')->willReturn($this->parentContext); - $this->span->method('getInstrumentationLibrary')->willReturn($this->instrumentationLibrary); + $this->span->method('getInstrumentationScope')->willReturn($this->instrumentationScope); $this->span->method('getResource')->willReturn($this->resource); $this->span->method('getStartEpochNanos')->willReturn($this->startEpochNanes); $this->span->method('getTotalRecordedLinks')->willReturn($this->totalRecordedLinks); @@ -82,7 +82,7 @@ public function test_getters(): void $this->assertSame($this->parentSpanId, $span->getParentSpanId()); $this->assertSame($this->startEpochNanes, $span->getStartEpochNanos()); $this->assertSame($this->endEpochNanos, $span->getEndEpochNanos()); - $this->assertSame($this->instrumentationLibrary, $span->getInstrumentationLibrary()); + $this->assertSame($this->instrumentationScope, $span->getInstrumentationScope()); $this->assertSame($this->resource, $span->getResource()); $this->assertSame('name', $span->getName()); $this->assertSame([], $span->getLinks()); diff --git a/tests/Unit/SDK/Trace/SpanTest.php b/tests/Unit/SDK/Trace/SpanTest.php index e8afe5343..b6a9c8679 100644 --- a/tests/Unit/SDK/Trace/SpanTest.php +++ b/tests/Unit/SDK/Trace/SpanTest.php @@ -15,7 +15,7 @@ use OpenTelemetry\Context\Context; use OpenTelemetry\SDK\Common\Attribute\Attributes; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Common\Time\ClockFactory; use OpenTelemetry\SDK\Common\Time\ClockInterface; use OpenTelemetry\SDK\Common\Time\Util as TimeUtil; @@ -56,7 +56,7 @@ class SpanTest extends MockeryTestCase private IdGeneratorInterface $idGenerator; private ResourceInfo $resource; - private InstrumentationLibrary $instrumentationLibrary; + private InstrumentationScope $instrumentationScope; private API\SpanContextInterface $spanContext; private TestClock $testClock; @@ -71,7 +71,7 @@ protected function setUp():void { $this->idGenerator = new RandomIdGenerator(); $this->resource = ResourceInfoFactory::emptyResource(); - $this->instrumentationLibrary = new InstrumentationLibrary('test_library', '0.1.2'); + $this->instrumentationScope = new InstrumentationScope('test_scope', '0.1.2'); $this->spanProcessor = Mockery::spy(SpanProcessorInterface::class); @@ -385,10 +385,10 @@ public function test_set_attribute_empty_key(): void $this->assertEmpty($span->toSpanData()->getAttributes()); } - public function test_get_instrumentation_library_info(): void + public function test_get_instrumentation_scope_info(): void { $span = $this->createTestSpanWithAttributes(self::ATTRIBUTES); - $this->assertSame($this->instrumentationLibrary, $span->getInstrumentationLibrary()); + $this->assertSame($this->instrumentationScope, $span->getInstrumentationScope()); $span->end(); } @@ -697,7 +697,7 @@ private function createTestSpan( $span = Span::startSpan( self::SPAN_NAME, $this->spanContext, - $this->instrumentationLibrary, + $this->instrumentationScope, $kind, $parentSpanId ? Span::wrap(SpanContext::create($this->traceId, $parentSpanId)) : Span::getInvalid(), Context::getRoot(), @@ -781,7 +781,7 @@ private function assertSpanData( $this->assertSame($this->parentSpanId, $spanData->getParentSpanId()); $this->assertNull($spanData->getContext()->getTraceState()); $this->assertSame($this->resource, $spanData->getResource()); - $this->assertSame($this->instrumentationLibrary, $spanData->getInstrumentationLibrary()); + $this->assertSame($this->instrumentationScope, $spanData->getInstrumentationScope()); $this->assertEquals($events, $spanData->getEvents()); $this->assertEquals($links, $spanData->getLinks()); $this->assertSame($startEpochNanos, $spanData->getStartEpochNanos()); diff --git a/tests/Unit/SDK/Trace/TracerTest.php b/tests/Unit/SDK/Trace/TracerTest.php index 2634605f4..dd0049f12 100644 --- a/tests/Unit/SDK/Trace/TracerTest.php +++ b/tests/Unit/SDK/Trace/TracerTest.php @@ -4,7 +4,7 @@ namespace OpenTelemetry\Tests\Unit\SDK\Trace; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Trace\Tracer; use OpenTelemetry\SDK\Trace\TracerSharedState; use PHPUnit\Framework\TestCase; @@ -16,13 +16,13 @@ class TracerTest extends TestCase { private Tracer $tracer; private TracerSharedState $tracerSharedState; - private InstrumentationLibrary $instrumentationLibrary; + private InstrumentationScope $instrumentationScope; protected function setUp(): void { $this->tracerSharedState = $this->createMock(TracerSharedState::class); - $this->instrumentationLibrary = $this->createMock(InstrumentationLibrary::class); - $this->tracer = (new Tracer($this->tracerSharedState, $this->instrumentationLibrary)); + $this->instrumentationScope = $this->createMock(InstrumentationScope::class); + $this->tracer = (new Tracer($this->tracerSharedState, $this->instrumentationScope)); } /** @@ -49,8 +49,8 @@ public function nameProvider(): array /** */ - public function test_get_instrumentation_library(): void + public function test_get_instrumentation_scope(): void { - $this->assertSame($this->instrumentationLibrary, $this->tracer->getInstrumentationLibrary()); + $this->assertSame($this->instrumentationScope, $this->tracer->getInstrumentationScope()); } } diff --git a/tests/Unit/SDK/Util/SpanData.php b/tests/Unit/SDK/Util/SpanData.php index 254c41d20..0711ec08a 100644 --- a/tests/Unit/SDK/Util/SpanData.php +++ b/tests/Unit/SDK/Util/SpanData.php @@ -9,7 +9,7 @@ use OpenTelemetry\API\Trace as API; use OpenTelemetry\SDK\Common\Attribute\Attributes; use OpenTelemetry\SDK\Common\Attribute\AttributesInterface; -use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibrary; +use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope; use OpenTelemetry\SDK\Common\Time\ClockFactory; use OpenTelemetry\SDK\Resource\ResourceInfo; use OpenTelemetry\SDK\Resource\ResourceInfoFactory; @@ -34,7 +34,7 @@ class SpanData implements SDK\SpanDataInterface private int $kind; private StatusData $status; private ResourceInfo $resource; - private InstrumentationLibrary $instrumentationLibrary; + private InstrumentationScope $instrumentationScope; private API\SpanContextInterface $context; private API\SpanContextInterface $parentContext; private int $totalAttributeCount = 0; @@ -50,7 +50,7 @@ public function __construct() $this->kind = API\SpanKind::KIND_INTERNAL; $this->status = StatusData::unset(); $this->resource = ResourceInfoFactory::emptyResource(); - $this->instrumentationLibrary = InstrumentationLibrary::getEmpty(); /** @phan-suppress-current-line PhanAccessMethodInternal */ + $this->instrumentationScope = InstrumentationScope::getEmpty(); /** @phan-suppress-current-line PhanAccessMethodInternal */ $this->context = API\SpanContext::getInvalid(); $this->parentContext = API\SpanContext::getInvalid(); } @@ -237,14 +237,14 @@ public function setResource(ResourceInfo $resource): self return $this; } - public function getInstrumentationLibrary(): InstrumentationLibrary + public function getInstrumentationScope(): InstrumentationScope { - return $this->instrumentationLibrary; + return $this->instrumentationScope; } - public function setInstrumentationLibrary(InstrumentationLibrary $instrumentationLibrary): self + public function setInstrumentationScope(InstrumentationScope $instrumentationScope): self { - $this->instrumentationLibrary = $instrumentationLibrary; + $this->instrumentationScope = $instrumentationScope; return $this; }