UNPKG

@sap/opentelemetry-exporter-for-sap-cloud-logging

Version:
66 lines 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CloudLoggingCredentials = void 0; const api_1 = require("@opentelemetry/api"); class CloudLoggingCredentials { constructor() { this.diagLogger = api_1.diag.createComponentLogger({ namespace: "CloudLoggingCredentials" }); } static parse(credentials) { let parsed = new CloudLoggingCredentials(); parsed.endpoint = credentials[CloudLoggingCredentials.CRED_OTLP_ENDPOINT]; parsed.clientKey = Buffer.from(credentials[CloudLoggingCredentials.CRED_OTLP_CLIENT_KEY], "utf-8"); parsed.clientCert = Buffer.from(credentials[CloudLoggingCredentials.CRED_OTLP_CLIENT_CERT], "utf-8"); parsed.serverCert = Buffer.from(credentials[CloudLoggingCredentials.CRED_OTLP_SERVER_CERT], "utf-8"); return parsed; } validate() { if (this.isUndefinedOrEmpty(this.endpoint)) { this.diagLogger.warn(`Credential "${CloudLoggingCredentials.CRED_OTLP_ENDPOINT}" not found. Skipping cloud-logging exporter configuration.`); return false; } if (this.isUndefinedOrEmpty(this.clientKey)) { this.diagLogger.warn(`Credential "${CloudLoggingCredentials.CRED_OTLP_CLIENT_KEY}" not found. Skipping cloud-logging exporter configuration.`); return false; } if (this.isUndefinedOrEmpty(this.clientCert)) { this.diagLogger.warn(`Credential "${CloudLoggingCredentials.CRED_OTLP_CLIENT_CERT}" not found. Skipping cloud-logging exporter configuration.`); return false; } if (this.isUndefinedOrEmpty(this.serverCert)) { this.diagLogger.warn(`Credential "${CloudLoggingCredentials.CRED_OTLP_SERVER_CERT}" not found. Skipping cloud-logging exporter configuration.`); return false; } return true; } isUndefinedOrEmpty(value) { if (value === undefined) { return true; } if (value.length == 0) { return true; } return false; } getEndpoint() { return CloudLoggingCredentials.CLOUD_LOGGING_ENDPOINT_PREFIX + this.endpoint; } getClientKey() { return this.clientKey; } getClientCert() { return this.clientCert; } getServerCert() { return this.serverCert; } } exports.CloudLoggingCredentials = CloudLoggingCredentials; CloudLoggingCredentials.CRED_OTLP_ENDPOINT = "ingest-otlp-endpoint"; CloudLoggingCredentials.CRED_OTLP_CLIENT_KEY = "ingest-otlp-key"; CloudLoggingCredentials.CRED_OTLP_CLIENT_CERT = "ingest-otlp-cert"; CloudLoggingCredentials.CRED_OTLP_SERVER_CERT = "server-ca"; CloudLoggingCredentials.CLOUD_LOGGING_ENDPOINT_PREFIX = "https://"; //# sourceMappingURL=cloudLoggingCredentials.js.map