harbor run -t openthoughts/tasktrove-mix-h2-language-balanced-v2-mix-h2-lang-balanced-2774
harbor download openthoughts/tasktrove-mix-h2-language-balanced-v2-mix-h2-lang-balanced-2774
solution file
import { createExportTraceServiceRequest } from '@opentelemetry/otlp-transformer' import { ExportServiceError, OTLPExporterError } from '@opentelemetry/otlp-exporter-base' import { ExportResult, ExportResultCode } from '@opentelemetry/core' import { SpanExporter } from '@opentelemetry/sdk-trace-base' import { unwrap } from './wrap.js' export interface OTLPExporterConfig { url: string headers?: Record<string, string> } const defaultHeaders: Record<string, string> = { accept: 'application/json', 'content-type': 'application/json', } export class OTLPExporter implements SpanExporter { private headers: Record<string, string> private url: string constructor(config: OTLPExporterConfig) { this.url = config.url this.headers = Object.assign({}, defaultHeaders, config.headers) } export(items: any[], resultCallback: (result: ExportResult) => void): void { this._export(items) .then(() => { resultCallback({ code: ExportResultCode.SUCCESS }) }) .catch((error: ExportServiceError) => { resultCallback({ code: ExportResultCode.FAILED, error }) }) } private _export(items: any[]): Promise<unknown> { return new Promise<void>((resolve, reject) => { try { this.send(items, resolve, reject) } catch (e) { reject(e) } }) } send(items: any[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void { const exportMessage = createExportTraceServiceRequest(items, true) const body = JSON.stringify(exportMessage) const params: RequestInit = { method: 'POST', headers: this.headers, body, } unwrap(fetch)(this.url, params) .then((response) => { if (response.ok) { onSuccess() } else { onError(new OTLPExporterError(`Exporter received a statusCode: ${response.status}`)) } })
Complete the code above, taking into account the cross-file context provided. Your solution must work correctly with the related files in the project.
Place your complete solution in /app/solution.py
/app/solution.py