Closed ellisv closed 6 years ago
Currently we have an ability to setTags() on a Span but no way to add an additional tag using the interface. So in order to add aditional tag you would have to keep the state of tags yourself as such:
setTags()
$tags = [ Tags\SPAN_KIND => Tags\SPAN_KIND_CLIENT, Tags\HTTP_URL => $httpUrl, Tags\HTTP_METHOD => $httpMethod, ]; $span = $tracer->startSpan('api_call', [ 'tags' => $tags, ]); try { // making the api call $span->setTags(array_merge($tags, [Tags\HTTP_STATUS_CODE => $responseCode])); } catch (ApiException $e) { // ... $span->setTags(array_merge($tags, [Tags\ERROR => true])); // ... } finally { $span->finish(); }
This would look worse if you'd like to pass it between functions.
Get rid of setTags() and introduce setTag(). All other OpenTracing libraries do so.
setTag()
Usage would look as such:
$span = $tracer->startSpan('api_call', [ 'tags' => [ Tags\SPAN_KIND => Tags\SPAN_KIND_CLIENT, Tags\HTTP_URL => $httpUrl, Tags\HTTP_METHOD => $httpMethod, ], ]); try { // making the api call $span->setTag(Tags\HTTP_STATUS_CODE, $responseCode); } catch (ApiException $e) { // ... $span->setTag(Tags\ERROR, true); // ... } finally { $span->finish(); }
This will also help having more consistent interface between libraries.
Problem
Currently we have an ability to
setTags()
on a Span but no way to add an additional tag using the interface. So in order to add aditional tag you would have to keep the state of tags yourself as such:This would look worse if you'd like to pass it between functions.
Proposal
Get rid of
setTags()
and introducesetTag()
. All other OpenTracing libraries do so.Usage would look as such:
This will also help having more consistent interface between libraries.