You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(core): make tracing opt-in per method
Previously `#[Trace]` on a class traced all public methods, filtered
by include/exclude lists on the class attribute. Method selection now
relies solely on the presence of `#[TraceMethod]`, so each method is
traced explicitly regardless of visibility.
Remove the include/exclude constructor from `Trace`, since scoping is
no longer driven by the class attribute. Scan all methods and skip
those without `#[TraceMethod]`, moving the attribute lookup into the
loop and passing it straight to `scanMethod`.
* test(class): align fixtures and tests with opt-in tracing
Drop fixtures and cases for the removed include/exclude method
filtering and consolidate the per-type argument fixtures onto the
shared MixedArgument, since tracing is now opt-in via TraceMethod.
Rework MixedVisibility to trace all visibilities and assert every
level is hooked. Exclude Fixtures from php-cs-fixer so intentional
test shapes aren't reformatted.
* docs(readme): reframe messaging around opt-in per-method tracing
Rewrite package descriptions and README examples to match the
opt-in model shipped in b7e57c9. The old "one tag, full
visibility" pitch implied `#[Trace]` alone spans every method,
which is no longer true — `#[Trace]` only marks a class and each
method needs its own `#[TraceMethod]`. Drop the stale
`include`/`exclude` method-selection docs and lead with the value
users actually get: capturing what methods received, returned,
and threw.
One tag, full visibility — every method call in your PHP app shows up in your traces, no boilerplate, no framework required.
8
+
Trace what your methods received, returned, and threw — without writing a single span. No framework required.
9
9
10
10
This is a read-only sub-split. Please open issues and pull requests in the [monorepo](https://github.com/eerzho/opentelemetry-auto-class-monorepo).
11
11
@@ -40,21 +40,20 @@ class Address
40
40
}
41
41
```
42
42
43
-
### 1. `#[Trace]` — a span per method
43
+
### 1. `#[Trace]` — mark a class for tracing
44
44
45
45
```php
46
46
use Eerzho\Instrumentation\Class\Attribute\Trace;
47
47
48
-
#[Trace(exclude: ['healthCheck'])] // trace every public method but healthCheck
49
-
// #[Trace(include: ['pay'])] // or: only pay
48
+
#[Trace] // mark the class for tracing
50
49
class OrderService
51
50
{
52
51
public function pay(int $orderId, string $card, Address $address): string {}
53
52
public function healthCheck(): bool {}
54
53
}
55
54
```
56
55
57
-
### 2. `#[TraceMethod]` — capture arguments, return value, and exceptions
56
+
### 2. `#[TraceMethod]` — trace a method
58
57
59
58
```php
60
59
use Eerzho\Instrumentation\Class\Attribute\TraceMethod;
@@ -64,7 +63,7 @@ use Eerzho\Instrumentation\Class\Attribute\TraceMethod;
64
63
public function pay(int $orderId, string $card, Address $address): string {}
65
64
```
66
65
67
-
By default, it captures the arguments and the return value, and records exceptions. Turn each off with `arguments: false`, `return: false`, or `exception: false` (a disabled exception still sets the span status to `ERROR`, only its event is omitted).
66
+
A method gets a span with `#[TraceMethod]`. By default, it captures the arguments and the return value, and records exceptions. Turn each off with `arguments: false`, `return: false`, or `exception: false` (a disabled exception still sets the span status to `ERROR`, only its event is omitted).
68
67
69
68
### 3. `#[TraceProperties]` — expand an object argument
70
69
@@ -114,7 +113,7 @@ Each method maps to its `arguments` (`name => position`) plus the `return` and `
114
113
115
114
### Selecting what to trace
116
115
117
-
`include` and `exclude` behave the same wherever they appear — `#[Trace]`, `#[TraceMethod]`, `#[TraceProperties]`:
116
+
`include` and `exclude` behave the same wherever they appear — `#[TraceMethod]` (arguments) and `#[TraceProperties]` (properties):
@@ -125,7 +124,7 @@ Each method maps to its `arguments` (`name => position`) plus the `return` and `
125
124
126
125
An empty `include` means "no allowlist" (everything), **not** "nothing".
127
126
128
-
Only **public**methods are traced and only **public**properties are expanded — protected and private are ignored.
127
+
Only **public** properties are expanded — non-public properties are ignored.
129
128
130
129
### Argument serialization
131
130
@@ -179,7 +178,7 @@ With `exception: false` the status still becomes `ERROR`, but the event above is
179
178
180
179
1. Skips abstract classes, interfaces, traits, and enums.
181
180
2. Reads `#[Trace]` on the class — no attribute, no instrumentation.
182
-
3. Collects the public methods allowed by `include` / `exclude`, and for each the arguments, return value, and exception recording configured by `#[TraceMethod]`.
181
+
3. Collects every method carrying `#[TraceMethod]`, and for each the arguments, return value, and exception recording it configures.
183
182
184
183
It returns a `class → method → {arguments, return, exception}` map. `ClassInstrumentation::register()` then installs an `ext-opentelemetry` hook on every mapped method:
One tag, full visibility — every method call in your Laravel app shows up in your traces, zero config.
8
+
Trace what your Laravel methods received, returned, and threw — without writing a single span.
9
9
10
10
The Laravel integration for [opentelemetry-auto-class](https://github.com/eerzho/opentelemetry-auto-class) — your classes are discovered and registered automatically.
11
11
@@ -52,14 +52,14 @@ use Eerzho\Instrumentation\Class\Attribute\Trace;
52
52
use Eerzho\Instrumentation\Class\Attribute\TraceMethod;
53
53
use Eerzho\Instrumentation\Class\Attribute\TraceProperties;
54
54
55
-
#[Trace(exclude: ['healthCheck'])] // trace public methods, but hide "healthCheck"
55
+
#[Trace]// mark the class for tracing
56
56
class OrderService
57
57
{
58
58
// span "App\Services\OrderService::pay"
59
59
#[TraceMethod(exclude: ['card'])] // hide "card" from the span
60
60
public function pay(int $orderId, string $card, Address $address): void {}
61
61
62
-
public function healthCheck(): bool {}
62
+
public function healthCheck(): bool {} // no #[TraceMethod] -> not traced
63
63
}
64
64
65
65
#[TraceProperties(exclude: ['zip'])] // expand public props, but hide "zip"
One tag, full visibility — every method call in your Symfony app shows up in your traces, zero config.
8
+
Trace what your Symfony methods received, returned, and threw — without writing a single span.
9
9
10
10
The Symfony integration for [opentelemetry-auto-class](https://github.com/eerzho/opentelemetry-auto-class) — your classes are discovered and registered automatically.
11
11
@@ -43,14 +43,14 @@ use Eerzho\Instrumentation\Class\Attribute\Trace;
43
43
use Eerzho\Instrumentation\Class\Attribute\TraceMethod;
44
44
use Eerzho\Instrumentation\Class\Attribute\TraceProperties;
45
45
46
-
#[Trace(exclude: ['healthCheck'])] // trace public methods, but hide "healthCheck"
46
+
#[Trace]// mark the class for tracing
47
47
class OrderService
48
48
{
49
49
// span "App\Service\OrderService::pay"
50
50
#[TraceMethod(exclude: ['card'])] // hide "card" from the span
51
51
public function pay(int $orderId, string $card, Address $address): void {}
52
52
53
-
public function healthCheck(): bool {}
53
+
public function healthCheck(): bool {} // no #[TraceMethod] -> not traced
54
54
}
55
55
56
56
#[TraceProperties(exclude: ['zip'])] // expand public props, but hide "zip"
0 commit comments