Skip to content

Commit 0baefbc

Browse files
committed
chore: fix the imports
1 parent 7bb65f8 commit 0baefbc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/express/src/tracer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { SpanKind, Attributes } from "@opentelemetry/api";
44

5-
const opentelemetry = require('@opentelemetry/api');
5+
import opentelemetry = require('@opentelemetry/api');
66

77
// Not functionally required but gives some insight what happens behind the scenes
88
const { diag, DiagConsoleLogger, DiagLogLevel } = opentelemetry;
@@ -13,25 +13,25 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
1313
import { Sampler, AlwaysOnSampler, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
1414
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
1515
import { Resource } from '@opentelemetry/resources';
16-
import { SEMRESATTRS_SERVICE_NAME, SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
16+
import { ATTR_SERVICE_NAME, ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
1717

1818
const Exporter = OTLPTraceExporter;
1919
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
20-
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
20+
import {HttpInstrumentation} from '@opentelemetry/instrumentation-http';
2121

2222
export const setupTracing = (serviceName: string) => {
2323
const provider = new NodeTracerProvider({
2424
resource: new Resource({
25-
[SEMRESATTRS_SERVICE_NAME]: serviceName,
25+
[ATTR_SERVICE_NAME]: serviceName,
2626
}),
2727
sampler: filterSampler(ignoreHealthCheck, new AlwaysOnSampler()),
2828
});
2929
registerInstrumentations({
3030
tracerProvider: provider,
3131
instrumentations: [
3232
// Express instrumentation expects HTTP layer to be instrumented
33-
HttpInstrumentation,
34-
ExpressInstrumentation,
33+
new HttpInstrumentation(),
34+
new ExpressInstrumentation(),
3535
],
3636
});
3737

@@ -62,5 +62,5 @@ function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler {
6262
}
6363

6464
function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: Attributes) {
65-
return spanKind !== opentelemetry.SpanKind.SERVER || attributes[SEMATTRS_HTTP_ROUTE] !== "/health";
65+
return spanKind !== opentelemetry.SpanKind.SERVER || attributes[ATTR_HTTP_ROUTE] !== "/health";
6666
}

0 commit comments

Comments
 (0)