Skip to content

Commit

Permalink
chore: remove exporters depending on old metrics SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Nov 4, 2021
1 parent 25af185 commit 0ee39de
Show file tree
Hide file tree
Showing 37 changed files with 122 additions and 2,996 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@opentelemetry/exporter-metrics-otlp-grpc",
"version": "0.26.0",
"private": true,
"description": "OpenTelemetry Collector Metrics Exporter allows user to send collected metrics to the OpenTelemetry Collector",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,17 @@
* limitations under the License.
*/

import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
import { toOTLPExportMetricServiceRequest } from '@opentelemetry/exporter-metrics-otlp-http'
import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import {
OTLPExporterConfigNode,
OTLPExporterNodeBase,
ServiceClientType,
validateAndNormalizeUrl
} from '@opentelemetry/exporter-trace-otlp-grpc';
import { baggageUtils, getEnv } from '@opentelemetry/core';
import { Metadata } from '@grpc/grpc-js';

const DEFAULT_COLLECTOR_URL = 'localhost:4317';
import { ExportResult } from '@opentelemetry/core';
import { MetricExporter, MetricRecord } from '@opentelemetry/sdk-metrics-base';

/**
* OTLP Metric Exporter for Node
*/
export class OTLPMetricExporter
extends OTLPExporterNodeBase<
MetricRecord,
otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest
>
implements MetricExporter {
// Converts time to nanoseconds
protected readonly _startTime = new Date().getTime() * 1000000;

constructor(config: OTLPExporterConfigNode = {}) {
super(config);
const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
this.metadata ||= new Metadata();
for (const [k, v] of Object.entries(headers)) {
this.metadata.set(k, v)
}
export class OTLPMetricExporter implements MetricExporter {
export(metrics: MetricRecord[], resultCallback: (result: ExportResult) => void): void {
throw new Error('Method not implemented.');
}

convert(
metrics: MetricRecord[]
): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {
return toOTLPExportMetricServiceRequest(
metrics,
this._startTime,
this
);
}

getDefaultUrl(config: OTLPExporterConfigNode): string {
return typeof config.url === 'string'
? validateAndNormalizeUrl(config.url)
: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)
: DEFAULT_COLLECTOR_URL;
}

getServiceClientType(): ServiceClientType {
return ServiceClientType.METRICS;
}

getServiceProtoPath(): string {
return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
shutdown(): Promise<void> {
throw new Error('Method not implemented.');
}
}
}

This file was deleted.

Empty file.
Loading

0 comments on commit 0ee39de

Please sign in to comment.