Stackdriver Trace Integration
See original GitHub issueStackdriver Trace Integration
Add Stackdriver Trace support to the Functions Framework.
Library: https://github.com/googleapis/cloud-trace-nodejs Google Issue: https://issuetracker.google.com/issues/124761993
@stew-r Can you add details as to what this would do? Would this be a tutorial or part of the actual framework?
Example Code
"@google-cloud/debug-agent": "^4.0.1",
"@google-cloud/profiler": "^2.0.2",
"@google-cloud/trace-agent": "^4.1.0",
import * as debugAgent from '@google-cloud/debug-agent';
import * as profiler from '@google-cloud/profiler';
import * as trace from '@google-cloud/trace-agent';
let toolsAreSetup = false;
/**
* Starts Google Cloud tooling.
* - StackDriver Trace
* - StackDriver Profiler
* - StackDriver Debugger
*/
export function startTooling() {
// Ensure tools are only setup once per process.
if (toolsAreSetup) {
return null;
} else {
toolsAreSetup = true;
}
// Start Trace
trace.start();
// Start profiler
profiler
.start({
serviceContext: {
service: getServiceName(),
version: 'v1',
},
})
.catch(err => {
console.error('Failed to start profiler', err);
});
// Start debugger
const debug = debugAgent.start({
serviceContext: {
service: getServiceName(),
version: 'v1',
// version: functions.config().tsc.version
},
});
// Return all tools
return {
trace,
profiler,
debug,
};
}
/**
* Gets the name of the function for logging.
* @returns {string} The name of the function with a '_function' suffix.
*/
function getServiceName(): string {
const serviceName = process.env.FUNCTION_TARGET || 'unknown_cloud';
return `${serviceName}_function`;
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:18 (11 by maintainers)
Top Results From Across the Web
Cloud Trace | Google Cloud
Cloud Trace is a distributed tracing system that collects latency data from your applications and finds performance bottlenecks in production.
Read more >Introduction to Stackdriver Distributed Tracing (Part 1) - Medium
Introduction to Stackdriver Distributed Tracing (Part 1) · 1 — gRPC Server · 2 — gRPC Client · 3 — Trace Instrumentation ·...
Read more >Micronaut GCP
Sets the location to the service account credential key file. 3 Stackdriver Trace. Improve this doc. The micronaut-gcp-tracing integrates Micronaut with Cloud ...
Read more >10. Spring Cloud Sleuth
You must enable Stackdriver Trace API from the Google Cloud Console in order to ... This integration enables Brave to use the StackdriverTracePropagation...
Read more >Distributed tracing with Spring Cloud Sleuth and Cloud Trace
Use a Stackdriver Trace Zipkin Proxy and simply configure Spring Cloud ... Or, use Spring Cloud GCP Trace, which seamlessly integrates with Spring...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@grant Below is the config helper we are using in our codebase, with some comments to clarify what each config means. Note that it’s not necessary to explicitly add the plugins, as those will be autodetected. Note also that this code is using OpenTelemetry 0.10, as there are some breaking changes in the last version and the google pacakges have not been updated yet.
@grant I think your suggestion will work, but keep in mind that @google-cloud/trace-agent is will be deprecated in favour of OpenTelemetry sometime the next 2-6 months.