123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- // Copyright The OpenTelemetry Authors
- // SPDX-License-Identifier: Apache-2.0
- package skywalkingexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/skywalkingexporter"
- 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/skywalkingexporter/internal/metadata"
- )
- // NewFactory creates a factory for Skywalking exporter.
- func NewFactory() exporter.Factory {
- return exporter.NewFactory(
- metadata.Type,
- createDefaultConfig,
- exporter.WithLogs(createLogsExporter, metadata.LogsStability),
- exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability))
- }
- func createDefaultConfig() component.Config {
- return &Config{
- RetrySettings: exporterhelper.NewDefaultRetrySettings(),
- QueueSettings: exporterhelper.NewDefaultQueueSettings(),
- TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
- GRPCClientSettings: configgrpc.GRPCClientSettings{
- // We almost read 0 bytes, so no need to tune ReadBufferSize.
- WriteBufferSize: 512 * 1024,
- },
- NumStreams: 2,
- }
- }
- func createLogsExporter(
- ctx context.Context,
- set exporter.CreateSettings,
- cfg component.Config,
- ) (exporter.Logs, error) {
- oCfg := cfg.(*Config)
- oce := newLogsExporter(ctx, oCfg, set.TelemetrySettings)
- return exporterhelper.NewLogsExporter(
- ctx,
- set,
- cfg,
- oce.pushLogs,
- exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
- exporterhelper.WithRetry(oCfg.RetrySettings),
- exporterhelper.WithQueue(oCfg.QueueSettings),
- exporterhelper.WithTimeout(oCfg.TimeoutSettings),
- 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 := newMetricsExporter(ctx, oCfg, set.TelemetrySettings)
- return exporterhelper.NewMetricsExporter(
- ctx,
- set,
- cfg,
- oce.pushMetrics,
- exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
- exporterhelper.WithRetry(oCfg.RetrySettings),
- exporterhelper.WithQueue(oCfg.QueueSettings),
- exporterhelper.WithTimeout(oCfg.TimeoutSettings),
- exporterhelper.WithStart(oce.start),
- exporterhelper.WithShutdown(oce.shutdown))
- }
|