@genkit-ai/google-cloud v0.5.0-rc.8
GCP Plugin - Google Cloud OpenTelemetry Export Plugin
Genkit's tracing and metrics functionality is built on top of OpenTelemetry (OT). Genkit seamlessly plugs into existing OT-instrumented applications as well as applications that do not use OT. Logging is facilitated via Winston due to the OpenTelemetry Node.js logging APIs not being generally available as of Q1 2024.
This plugin exports telemetry and logging data to Google Cloud Operations Suite.
Adding the plugin
Genkit's configuration supports a telemetry
block that exposes hooks for instrumentation and logging. Add googleCloud()
to the plugins
array within genkit.config.ts
and apecify 'googleCloud'
for both instrumentation
and logger
within the telemetry
block to add this plugin to your project.
import { googleCloud } from '@genkit-ai/google-cloud';
export default configureGenkit({
plugins: [
...,
googleCloud({...}),
],
...,
telemetry: {
instrumentation: 'googleCloud',
logger: 'googleCloud',
}
});
Configuring the plugin
There are four available configuration fields:
sampler
autoInstrumentation
autoInstrumentationConfig
metricsExportIntervalMillis
A sample configuration may look similar to:
googleCloud({
telemetryConfig: {
sampler: new AlwaysOnSampler(),
autoInstrumentation: true,
autoInstrumentationConfig: {
'@opentelemetry/instrumentation-fs': { enabled: false },
'@opentelemetry/instrumentation-dns': { enabled: false },
'@opentelemetry/instrumentation-net': { enabled: false },
},
metricExportIntervalMillis: 5_000,
},
});
sampler
For cases where exporting all traces isn't practical, OpenTelemetry allows trace sampling.
There are four preconfigured samplers:
- AlwaysOnSampler - samples all traces
- AlwaysOffSampler - samples no traces
- ParentBased - samples based on parent span
- TraceIdRatioBased - samples a configurable percentage of traces
autoInstrumentation
& autoInstrumentationConfig
Enabling automatic instrumentation allows OpenTelemetry to capture telemetry data from third-party libraries without the need to modify code.
metricsExportInterval
This field specifies the metrics export interval in milliseconds. The minimum export interval for GCP Monitoring is 5000ms.
5 days ago
6 days ago
7 days ago
17 days ago
18 days ago
20 days ago
1 month ago
1 month ago
1 month ago