function AttributesBuilder::merge
Overrides AttributesBuilderInterface::merge
File
-
vendor/
open-telemetry/ sdk/ Common/ Attribute/ AttributesBuilder.php, line 30
Class
- AttributesBuilder
- @internal
Namespace
OpenTelemetry\SDK\Common\AttributeCode
public function merge(AttributesInterface $old, AttributesInterface $updating) : AttributesInterface {
$new = $old->toArray();
$dropped = $old->getDroppedAttributesCount() + $updating->getDroppedAttributesCount();
foreach ($updating->toArray() as $key => $value) {
if (count($new) === $this->attributeCountLimit && !array_key_exists($key, $new)) {
$dropped++;
}
else {
$new[$key] = $value;
}
}
return new Attributes($new, $dropped);
}