admin管理员组文章数量:1122832
I am trying to build a bespoke OTEL package for our internal applications, but run into a weird type mismatch error, that I cannot explain to myself.
export class OtelConfigurator {
otelEndpoint: string;
sdkConfiguration: Partial<NodeSDKConfiguration>;
sdk: NodeSDK | undefined;
metadata: Metadata;
constructor({ authHeader, serviceName, serviceVersion, otelCollectorEndpoint, loglevel }: obsProps) {
// omitted
}
enableMetrics(additionalConfig?: OTLPGRPCExporterConfigNode) {
const config: OTLPGRPCExporterConfigNode = {
url: `${this.otelEndpoint}/v1/metrics`,
metadata: this.metadata,
...additionalConfig,
};
const exporter = new OTLPMetricExporter(config);
this.sdkConfiguration.metricReader = new PeriodicExportingMetricReader({
exporter,
});
}
}
The error happens at the following line:
this.sdkConfiguration.metricReader = new PeriodicExportingMetricReader({
exporter,
});
Type 'PeriodicExportingMetricReader' is not assignable to type 'MetricReader'. Types have separate declarations of a private property '_shutdown'.ts(2322)
Which is weird since the PeriodicExportingMetricReader extends the Metric Reader:
export declare class PeriodicExportingMetricReader extends MetricReader {
}
And also the docs demonstrate this usage:
So my best guess is, that I have mismatching versions, but can't find an error there either:
"peerDependencies": {
"@grpc/grpc-js": "^1.12.2",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-node": "0.53.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
"@opentelemetry/instrumentation-dataloader": "^0.12.0",
"@opentelemetry/instrumentation-graphql": "^0.43.0",
"@opentelemetry/instrumentation-grpc": "0.53.0",
"@opentelemetry/instrumentation-http": "0.53.0",
"@opentelemetry/instrumentation-ioredis": "^0.43.0",
"@opentelemetry/instrumentation-net": "^0.39.0",
"@opentelemetry/instrumentation-pino": "^0.42.0",
"@opentelemetry/sdk-metrics": "1.28.0",
"@opentelemetry/sdk-node": "0.53.0",
"@opentelemetry/sdk-trace-node": "1.26.0",
"@opentelemetry/semantic-conventions": "1.26"
},
What am I doing wrong here?
本文标签:
版权声明:本文标题:typescript - Why am I unable to assign an PeriodicExportingMetricReader instance to an otel SdkConficguration - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304771a1932351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论