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 :
6 : /// Configuration for the OtlpGrpcMetricExporter.
7 : class OtlpGrpcMetricExporterConfig {
8 : /// The OTLP endpoint to export to (e.g. http://localhost:4317).
9 : final String endpoint;
10 :
11 : /// Whether to use an insecure connection (HTTP instead of HTTPS).
12 : final bool insecure;
13 :
14 : /// Headers to include in the OTLP request.
15 : final Map<String, String>? headers;
16 :
17 : /// Timeout for export operations in milliseconds.
18 : final int timeoutMillis;
19 :
20 : /// Path to the TLS certificate file for secure connections.
21 : final String? certificate;
22 :
23 : /// Path to the client key file for secure connections with client authentication.
24 : final String? clientKey;
25 :
26 : /// Path to the client certificate file for secure connections with client authentication.
27 : final String? clientCertificate;
28 :
29 : /// Whether to enable gRPC compression for requests.
30 : final bool compression;
31 :
32 : /// Creates a new configuration for the OtlpGrpcMetricExporter.
33 2 : OtlpGrpcMetricExporterConfig({
34 : required this.endpoint,
35 : this.insecure = false,
36 : this.headers,
37 : this.timeoutMillis = 10000,
38 : this.certificate,
39 : this.clientKey,
40 : this.clientCertificate,
41 : this.compression = false,
42 : }) {
43 8 : _validateCertificates(certificate, clientKey, clientCertificate);
44 : }
45 :
46 2 : static void _validateCertificates(
47 : String? cert,
48 : String? key,
49 : String? clientCert,
50 : ) {
51 2 : CertificateUtils.validateCertificates(
52 : certificate: cert,
53 : clientKey: key,
54 : clientCertificate: clientCert,
55 : );
56 : }
57 : }
|