Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ability to add a new tag for a Span using interface #51

Closed
ellisv opened this issue Feb 25, 2018 · 0 comments
Closed

No ability to add a new tag for a Span using interface #51

ellisv opened this issue Feb 25, 2018 · 0 comments

Comments

@ellisv
Copy link
Contributor

ellisv commented Feb 25, 2018

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:

$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.

Proposal

Get rid of setTags() and introduce setTag(). All other OpenTracing libraries do so.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant