Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README configuration Typescript errors: NodeJSConfiguration interface doesn't have metricExporter and metricInterval properties #395

Open
laurencefass opened this issue Feb 14, 2023 · 3 comments

Comments

@laurencefass
Copy link

laurencefass commented Feb 14, 2023

NodeSJConfiguration interface does not have metricExporter and metricInterval properties causing TS errors using the README config. Im using latest nest-otel and latest versions of. all dependencies.

Im using the following combination of packages

        "@nestjs/common": "^9.0.0",
        "@nestjs/core": "^9.0.0",
        "nestjs-otel": "^5.0.0",
	"@opentelemetry/auto-instrumentations-node": "^0.36.3",
	"@opentelemetry/exporter-jaeger": "^1.9.1",
	"@opentelemetry/exporter-prometheus": "^0.35.1",
        "@opentelemetry/sdk-node": "^0.35.1",

with the following config copied from the README (note I aded a jaeger trace exporter)

const otelSDK = new NodeSDK({
	metricExporter: new PrometheusExporter(),
	metricInterval: 1000,
        traceExporter: new JaegerExporter(),
	spanProcessor: new BatchSpanProcessor(new JaegerExporter()),
	contextManager: new AsyncLocalStorageContextManager(),
	textMapPropagator: new CompositePropagator({
		propagators: [
			new JaegerPropagator(),
			new W3CTraceContextPropagator(),
			new W3CBaggagePropagator(),
			new B3Propagator(),
			new B3Propagator({
				injectEncoding: B3InjectEncoding.MULTI_HEADER,
			}),
		],
	}),
	instrumentations: [getNodeAutoInstrumentations()],
});

Neither metricExporter nor metricInterval are defined on the NodeSDKConfiguration interface passed to NodeSDK()

export interface NodeSDKConfiguration {
    autoDetectResources: boolean;
    contextManager: ContextManager;
    defaultAttributes: SpanAttributes;
    textMapPropagator: TextMapPropagator;
    metricReader: MetricReader;
    views: View[];
    instrumentations: InstrumentationOption[];
    resource: Resource;
    resourceDetectors: Detector[];
    sampler: Sampler;
    serviceName?: string;
    spanProcessor: SpanProcessor;
    traceExporter: SpanExporter;
    spanLimits: SpanLimits;
}

Aside from addressing the type incompatibility, how/where do i define my metric parameters if they don't exist on NodeSDKConfiguration? Is that possible with this configuration and package combination?

Thanks

@laurencefass laurencefass changed the title NodeSJConfiguration interface does not have metricExporter and metricInterval properties README configuration is in error because NodeSJConfiguration interface doesn't have metricExporter and metricInterval properties Feb 15, 2023
@laurencefass laurencefass changed the title README configuration is in error because NodeSJConfiguration interface doesn't have metricExporter and metricInterval properties README configuration Typescript errors: NodeSJConfiguration interface doesn't have metricExporter and metricInterval properties Feb 15, 2023
@laurencefass laurencefass changed the title README configuration Typescript errors: NodeSJConfiguration interface doesn't have metricExporter and metricInterval properties README configuration Typescript errors: NodeJSConfiguration interface doesn't have metricExporter and metricInterval properties Feb 15, 2023
@mateorider
Copy link

@laurencefass I ran into the same issue. After playing around with the example apps in the README, I noticed the versions for @opentelemetry/sdk-node were different. For example, the config you've shared works in this example because the node sdk version is "^0.24.0". However, in this other example your config would not work because the package version is "^0.34.0". I'm not sure what version changed the interface but I do know that metricExporter and metricInterval are no longer available options, as you pointed out.

The good news is that the metricReader field in the latest version will accept valid metric exporters (eg PrometheusExporter). I ended up using the setup from this example and things are working as expected.

Hope that helps!

@coler-j
Copy link

coler-j commented Feb 21, 2023

@pragmaticivan do you have any context? Do dependencies need to be updated on this lib?

@laurencefass
Copy link
Author

Im not sure if this package is being actively maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants