CloudMonitoringExporter

CloudMonitoringExporter

A custom OpenTelemetry MetricExporter that sends metrics data to Google Cloud Monitoring.

This class extends the base MetricExporter from @google-cloud/opentelemetry-cloud-monitoring-exporter and handles the process of converting OpenTelemetry metrics data into the format required by the Google Cloud Monitoring API. It uses the MetricServiceClient to send the data to Google Cloud Monitoring's createTimeSeries method.

Constructor

new CloudMonitoringExporter()

Example
// Create an instance of the CloudMonitoringExporter
  const exporter = new CloudMonitoringExporter();

  // Use the exporter with a MeterProvider
  const meterProvider = new MeterProvider({
    resource: new Resource({
      'service.name': 'my-service',
      // ... other resource attributes
    }),
    readers: [new PeriodicExportingMetricReader({
        exporter: exporter,
        exportIntervalMillis: 10000 // Export every 10 seconds
    })]
  });

  // Now start instrumenting your application using the meter
  const meter = meterProvider.getMeter('my-meter');
  // ... create counters, histograms, etc.