GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs
Stackdriver Trace Integration
- Langage dominant
- TypeScript
- Étoiles
- 1.4k
- Forks
- 181
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
## Stackdriver 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",
```
```ts
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`;
}
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par la bibliothèque cloud-trace-nodejs et l’exemple TypeScript de l’issue ; aucun fichier du dépôt, test ou point d’entrée n’est indiqué. Commencez par déterminer si l’intégration doit appartenir à Functions Framework ou à un tutoriel, puis définissez le comportement pris en charge et les vérifications d’acceptation. L’implémentation terminée doit correspondre au périmètre convenu et démontrer la prise en charge de Stackdriver Trace.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- google-cloud, node.js, typescript
- Domaine
- cloud, observability-sre
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100