Debian Codegraph @

exporter/exporterhelper/xexporterhelper/new_request.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package xexporterhelper // import "go.opentelemetry.io/collector/exporter/exporterhelper/xexporterhelper"
5
6 import (
7 "context"
8
9 "go.opentelemetry.io/collector/exporter"
10 "go.opentelemetry.io/collector/exporter/exporterhelper"
11 "go.opentelemetry.io/collector/exporter/exporterhelper/internal"
12 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/queuebatch"
13 "go.opentelemetry.io/collector/pdata/plog"
14 "go.opentelemetry.io/collector/pdata/pmetric"
15 "go.opentelemetry.io/collector/pdata/ptrace"
16 )
17
18 // NewLogsRequest creates new logs exporter based on custom LogsConverter and Sender.
19 // Experimental: This API is at the early stage of development and may change without backward compatibility
20 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
21 func NewLogsRequest(
22 ctx context.Context,
23 set exporter.Settings,
24 converter RequestConverterFunc[plog.Logs],
25 pusher RequestConsumeFunc,
26 options ...exporterhelper.Option,
27 ) (exporter.Logs, error) {
28 return internal.NewLogsRequest(ctx, set, converter, pusher, options...)
29 }
30
31 // NewMetricsRequest creates new metrics exporter based on custom MetricsConverter and Sender.
32 // Experimental: This API is at the early stage of development and may change without backward compatibility
33 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
34 func NewMetricsRequest(
35 ctx context.Context,
36 set exporter.Settings,
37 converter RequestConverterFunc[pmetric.Metrics],
38 pusher RequestConsumeFunc,
39 options ...exporterhelper.Option,
40 ) (exporter.Metrics, error) {
41 return internal.NewMetricsRequest(ctx, set, converter, pusher, options...)
42 }
43
44 // NewTracesRequest creates new traces exporter based on custom TracesConverter and Sender.
45 // Experimental: This API is at the early stage of development and may change without backward compatibility
46 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
47 func NewTracesRequest(
48 ctx context.Context,
49 set exporter.Settings,
50 converter RequestConverterFunc[ptrace.Traces],
51 pusher RequestConsumeFunc,
52 options ...exporterhelper.Option,
53 ) (exporter.Traces, error) {
54 return internal.NewTracesRequest(ctx, set, converter, pusher, options...)
55 }
56
57 // QueueBatchSettings are settings for the QueueBatch component.
58 // They include things line Encoding to be used with persistent queue, or the available Sizers, etc.
59 type QueueBatchSettings = queuebatch.Settings[Request]
60
61 // NewMetricsQueueBatchSettings returns a new QueueBatchSettings to configure to WithQueueBatch when using pmetric.Metrics.
62 // Experimental: This API is at the early stage of development and may change without backward compatibility
63 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
64 func NewMetricsQueueBatchSettings() QueueBatchSettings {
65 return queuebatch.NewMetricsQueueBatchSettings()
66 }
67
68 // NewLogsQueueBatchSettings returns a new QueueBatchSettings to configure to WithQueueBatch when using plog.Logs.
69 // Experimental: This API is at the early stage of development and may change without backward compatibility
70 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
71 func NewLogsQueueBatchSettings() QueueBatchSettings {
72 return queuebatch.NewLogsQueueBatchSettings()
73 }
74
75 // NewTracesQueueBatchSettings returns a new QueueBatchSettings to configure to WithQueueBatch when using ptrace.Traces.
76 // Experimental: This API is at the early stage of development and may change without backward compatibility
77 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
78 func NewTracesQueueBatchSettings() QueueBatchSettings {
79 return queuebatch.NewTracesQueueBatchSettings()
80 }
81
82 // WithQueueBatch enables queueing and batching for an exporter.
83 // This option should be used with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
84 // Experimental: This API is at the early stage of development and may change without backward compatibility
85 // until https://github.com/open-telemetry/opentelemetry-collector/issues/8122 is resolved.
86 func WithQueueBatch(cfg exporterhelper.QueueBatchConfig, set QueueBatchSettings) exporterhelper.Option {
87 return internal.WithQueueBatch(cfg, set)
88 }