Line data Source code
1 : // Copyright The OpenTelemetry Authors
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : import '../../../trace/export/otlp/certificate_utils.dart';
5 : import '../metrics_sdk_config.dart';
6 :
7 : /// Configuration for the OtlpGrpcMetricExporter.
8 : class OtlpGrpcMetricExporterConfig {
9 : /// The OTLP endpoint to export to (e.g. http://localhost:4317).
10 : final String endpoint;
11 :
12 : /// Whether to use an insecure connection (HTTP instead of HTTPS).
13 : final bool insecure;
14 :
15 : /// The filter to apply to exemplars during export.
16 : /// Default: `MetricsExemplarFilter.traceBased`
17 : final MetricsExemplarFilter exemplarFilter;
18 :
19 : /// Headers to include in the OTLP request.
20 : final Map<String, String>? headers;
21 :
22 : /// Timeout for export operations in milliseconds.
23 : final int timeoutMillis;
24 :
25 : /// Path to the TLS certificate file for secure connections.
26 : final String? certificate;
27 :
28 : /// Path to the client key file for secure connections with client authentication.
29 : final String? clientKey;
30 :
31 : /// Path to the client certificate file for secure connections with client authentication.
32 : final String? clientCertificate;
33 :
34 : /// Whether to enable gRPC compression for requests.
35 : final bool compression;
36 :
37 : /// Creates a new configuration for the OtlpGrpcMetricExporter.
38 6 : OtlpGrpcMetricExporterConfig({
39 : required this.endpoint,
40 : this.insecure = false,
41 : this.headers,
42 : this.timeoutMillis = 10000,
43 : this.certificate,
44 : this.clientKey,
45 : this.clientCertificate,
46 : this.compression = false,
47 : this.exemplarFilter = MetricsExemplarFilter.traceBased,
48 : }) {
49 24 : _validateCertificates(certificate, clientKey, clientCertificate);
50 : }
51 :
52 6 : static void _validateCertificates(
53 : String? cert,
54 : String? key,
55 : String? clientCert,
56 : ) {
57 6 : CertificateUtils.validateCertificates(
58 : certificate: cert,
59 : clientKey: key,
60 : clientCertificate: clientCert,
61 : );
62 : }
63 : }
|