From bee9c64ae90f5a1714585473188a3ec224aa3f22 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Sat, 31 Aug 2024 09:17:53 +1000 Subject: [PATCH] adding auto-instrumentation attribute to API (#1371) adding WithSpan and SpanAttribute attributes to the API. These attributes are used by an upcoming feature in auto-instrumentation which allows users to add attributes to their code to enable auto-instrumentation. --- src/API/Instrumentation/SpanAttribute.php | 24 ++++++++++++++++ src/API/Instrumentation/WithSpan.php | 28 +++++++++++++++++++ .../API/Instrumentation/SpanAttributeTest.php | 19 +++++++++++++ .../Unit/API/Instrumentation/WithSpanTest.php | 22 +++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/API/Instrumentation/SpanAttribute.php create mode 100644 src/API/Instrumentation/WithSpan.php create mode 100644 tests/Unit/API/Instrumentation/SpanAttributeTest.php create mode 100644 tests/Unit/API/Instrumentation/WithSpanTest.php diff --git a/src/API/Instrumentation/SpanAttribute.php b/src/API/Instrumentation/SpanAttribute.php new file mode 100644 index 000000000..b2dcd1ef8 --- /dev/null +++ b/src/API/Instrumentation/SpanAttribute.php @@ -0,0 +1,24 @@ +assertSame('foo', $attr->name); + } +} diff --git a/tests/Unit/API/Instrumentation/WithSpanTest.php b/tests/Unit/API/Instrumentation/WithSpanTest.php new file mode 100644 index 000000000..9dfd1824f --- /dev/null +++ b/tests/Unit/API/Instrumentation/WithSpanTest.php @@ -0,0 +1,22 @@ + 'bar']); + $this->assertSame('foo', $attr->span_name); + $this->assertSame(SpanKind::KIND_PRODUCER, $attr->span_kind); + $this->assertSame(['foo' => 'bar'], $attr->attributes); + } +}