PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.22
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.22
1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 All 168 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Serializer / EnvelopItems / MetricsItem.php

MetricsItem.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.22, at vendor_prefixed/sentry/sentry/src/Serializer/EnvelopItems/MetricsItem.php

27 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry\Serializer\EnvelopItems;
5
6 use WCPOS\Vendor\Sentry\Attributes\Attribute;
7 use WCPOS\Vendor\Sentry\Event;
8 use WCPOS\Vendor\Sentry\EventType;
9 use WCPOS\Vendor\Sentry\Metrics\Types\Metric;
10 use WCPOS\Vendor\Sentry\Util\JSON;
11 /**
12 * @internal
13 */
14 class MetricsItem implements EnvelopeItemInterface
15 {
16 public static function toEnvelopeItem(Event $event) : string
17 {
18 $metrics = $event->getMetrics();
19 $header = ['type' => (string) EventType::metrics(), 'item_count' => \count($metrics), 'content_type' => 'application/vnd.sentry.items.trace-metric+json'];
20 return \sprintf("%s\n%s", JSON::encode($header), JSON::encode(['items' => \array_map(static function (Metric $metric) : array {
21 return ['timestamp' => $metric->getTimestamp(), 'trace_id' => (string) $metric->getTraceId(), 'span_id' => (string) $metric->getSpanId(), 'name' => $metric->getName(), 'value' => $metric->getValue(), 'unit' => $metric->getUnit() ? (string) $metric->getUnit() : null, 'type' => $metric->getType(), 'attributes' => \array_map(static function (Attribute $attribute) : array {
22 return ['type' => $attribute->getType(), 'value' => $attribute->getValue()];
23 }, $metric->getAttributes()->all())];
24 }, $metrics)]));
25 }
26 }
27