Line data Source code
1 : // Licensed under the Apache License, Version 2.0
2 : // Copyright 2025, Michael Bushe, All rights reserved.
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 69 : 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 276 : _validateCertificates(certificate, clientKey, clientCertificate);
44 : }
45 :
46 69 : static void _validateCertificates(
47 : String? cert, String? key, String? clientCert) {
48 69 : CertificateUtils.validateCertificates(
49 : certificate: cert,
50 : clientKey: key,
51 : clientCertificate: clientCert,
52 : );
53 : }
54 : }
|