Skip to content

Commit

Permalink
Fix metrics export 400 Bad Request issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danopia committed May 24, 2024
1 parent 0eb6d1a commit 51edd0d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions otel-platform/otlp-json-exporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
type IExportTraceServiceRequest,
type IExportMetricsServiceRequest,
type IExportLogsServiceRequest,
type OtlpEncodingOptions,
} from "../opentelemetry/otlp-transformer.js";

import type {
Expand Down Expand Up @@ -120,6 +121,11 @@ abstract class OTLPFetchExporterBase<
}
}

const otlpConfig: OtlpEncodingOptions = {
useHex: true,
useLongBits: false,
};

/**
* Collector Trace Exporter for Deno using fetch()
*/
Expand All @@ -136,10 +142,7 @@ export class OTLPTracesExporter
}

convert(spans: ReadableSpan[]) {
return createExportTraceServiceRequest(spans, {
useHex: true,
useLongBits: false,
});
return createExportTraceServiceRequest(spans, otlpConfig);
}
}

Expand All @@ -154,7 +157,10 @@ export class OTLPMetricsExporter
envKey: 'METRICS',
});
}
convert = createExportMetricsServiceRequest

convert(logs: ResourceMetrics[]) {
return createExportMetricsServiceRequest(logs, otlpConfig);
}
}

export class OTLPLogsExporter
Expand All @@ -170,10 +176,7 @@ export class OTLPLogsExporter
}

convert(logs: ReadableLogRecord[]) {
return createExportLogsServiceRequest(logs, {
useHex: true,
useLongBits: false,
});
return createExportLogsServiceRequest(logs, otlpConfig);
}
}
// btw, events are event.name and event.domain

0 comments on commit 51edd0d

Please sign in to comment.