func()

in confgenerator/config.go [200:238]


func (rc *RunMonitoringConfig) OTelReceiverPipeline() (*otel.ReceiverPipeline, error) {
	scrapeConfig, err := rc.scrapeConfigs()
	if err != nil {
		return nil, err
	}

	// Prefix the `instance` resource label with the faas.id.
	processors := []otel.Component{
		otel.GCPResourceDetector(),
		otel.TransformationMetrics(otel.PrefixResourceAttribute("service.instance.id", "faas.id", ":")),
	}

	// If the users configure to add the instance metadata, add it as a metric label.
	if rc.Spec.TargetLabels.Metadata != nil && contains(*rc.Spec.TargetLabels.Metadata, "instance") {
		processors = append(processors, otel.TransformationMetrics(otel.FlattenResourceAttribute("faas.id", cloudRunInstanceLabel)))
	}

	// Group by the GMP attributes.
	processors = append(processors, otel.GroupByGMPAttrs())

	// If the user updates the `project_id` label, we need to update the gcp.project.id resource attribute
	// so the exporter can pick it up.
	processors = append(processors, otel.TransformationMetrics(otel.GroupByAttribute("gcp.project.id", "project_id"), otel.DeleteMetricAttribute("project_id")))

	return &otel.ReceiverPipeline{
		Receiver: otel.Component{
			Type: "prometheus",
			Config: map[string]interface{}{
				"use_start_time_metric":             true,
				"use_collector_start_time_fallback": true,
				"allow_cumulative_resets":           true,
				"config": map[string]interface{}{
					"scrape_configs": scrapeConfig,
				},
			},
		},
		Processors: processors,
	}, nil
}