// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 package opencensusexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter" import ( "context" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/opencensusexporter/internal/metadata" ) // NewFactory creates a factory for OTLP exporter. func NewFactory() exporter.Factory { return exporter.NewFactory( metadata.Type, createDefaultConfig, exporter.WithTraces(createTracesExporter, metadata.TracesStability), exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability)) } func createDefaultConfig() component.Config { return &Config{ GRPCClientSettings: configgrpc.GRPCClientSettings{ // We almost read 0 bytes, so no need to tune ReadBufferSize. WriteBufferSize: 512 * 1024, }, NumWorkers: 2, } } func createTracesExporter(ctx context.Context, set exporter.CreateSettings, cfg component.Config) (exporter.Traces, error) { oCfg := cfg.(*Config) oce, err := newTracesExporter(ctx, oCfg, set.TelemetrySettings) if err != nil { return nil, err } return exporterhelper.NewTracesExporter( ctx, set, cfg, oce.pushTraces, exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), exporterhelper.WithRetry(oCfg.RetrySettings), exporterhelper.WithQueue(oCfg.QueueSettings), exporterhelper.WithStart(oce.start), exporterhelper.WithShutdown(oce.shutdown)) } func createMetricsExporter(ctx context.Context, set exporter.CreateSettings, cfg component.Config) (exporter.Metrics, error) { oCfg := cfg.(*Config) oce, err := newMetricsExporter(ctx, oCfg, set.TelemetrySettings) if err != nil { return nil, err } return exporterhelper.NewMetricsExporter( ctx, set, cfg, oce.pushMetrics, exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}), exporterhelper.WithRetry(oCfg.RetrySettings), exporterhelper.WithQueue(oCfg.QueueSettings), exporterhelper.WithStart(oce.start), exporterhelper.WithShutdown(oce.shutdown)) }