-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Stackdriver Trace sample code for the doc #561
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
Conversation
@@ -65,6 +65,7 @@ do | |||
fi | |||
fi | |||
pushd ${DIR} | |||
mkdir -p build/logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
trace/trace-sample.php
Outdated
} | ||
|
||
# [START exporter_setup] | ||
$exporter = new StackdriverExporter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in the PSR coding standards, but I've been doing these like this, so it'd be better for internal sample consistency:
$exporter = new StackdriverExporter([
'clientConfig' => [
'projectId' => $projectId
]
]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (with the next commit)
trace/trace-sample.php
Outdated
|
||
function use_trace() | ||
{ | ||
# [START span_with_closure] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference block here is off.. the END
ref should be inside the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
trace/trace-sample.php
Outdated
'projectId' => $projectId | ||
]]); | ||
# [END exporter_setup] | ||
// For testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this comment instead?
// When running tests, use a null exporter instead.
But a better question is, why not just use StackdriverExporter
?
Or, in the tests, just call Trace::start(new NullExporter);
before calling use_trace()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having integration test is good in general, but unfortunately now there's no way to fetch the trace from the API. I would just have the unit test like this for now.
trace/trace-sample.php
Outdated
Tracer::start($exporter); | ||
# [END tracer_start] | ||
|
||
function use_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like a more descriptive name for this function here. How about trace_callable()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@bshaffer Thanks, PTAL |
LGTM |
cc @chingor13