Skip to content

Commit cde6d4d

Browse files
authored
chore(examples-express): call setupTracing before module imports (#2992)
1 parent 0c59990 commit cde6d4d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/express/src/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
import { setupTracing } from './tracer';
1818

19+
// Initialize tracing before importing other moduless
20+
const tracer = setupTracing('example-express-client');
21+
1922
import * as api from '@opentelemetry/api';
2023
import * as axios from 'axios';
2124

22-
const tracer = setupTracing('example-express-client');
23-
2425
async function makeRequest() {
2526
const span = tracer.startSpan('client.makeRequest()', {
2627
kind: api.SpanKind.CLIENT,

examples/express/src/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
import { setupTracing } from './tracer';
1818

19+
// Initialize tracing before importing other modules
20+
setupTracing('example-express-server');
21+
1922
// Require in rest of modules
2023
import * as express from 'express';
2124
import * as axios from 'axios';
2225
import { RequestHandler } from 'express';
2326

24-
setupTracing('example-express-server');
25-
2627
// Setup express
2728
const app = express();
2829
const PORT = 8080;

0 commit comments

Comments
 (0)