To simplify capturing parameters, we can allow a mapping from parameters to attributes. This can be useful if simple values and no preprocessing is required so they can be directly moved into metadata.
For example, it could look like this:
function test(string $name) {
}
instrument(null, "test", spanAttributes: ['description' => 'name']);
setEndCallback(static function(array $data) {
$data['metadata']['name'] // contains 'example'
});
test('example');
We can also extend it to allow one level of property access:
function test(Request $request) {
}
instrument(null, "test", spanAttributes: ['description' => ['request', 'getUrl()']]);
This would add the value of $request->getUrl() into $data['metadata']['description']
If the parameter name doesn't exist or any function/property doesn't exist, it should do nothing and not crash the user application
To simplify capturing parameters, we can allow a mapping from parameters to attributes. This can be useful if simple values and no preprocessing is required so they can be directly moved into metadata.
For example, it could look like this:
We can also extend it to allow one level of property access:
This would add the value of
$request->getUrl()into$data['metadata']['description']If the parameter name doesn't exist or any function/property doesn't exist, it should do nothing and not crash the user application