File tree Expand file tree Collapse file tree 4 files changed +11
-14
lines changed
Expand file tree Collapse file tree 4 files changed +11
-14
lines changed Original file line number Diff line number Diff line change 3131 "@opentelemetry/api" : " ^1.9.0" ,
3232 "@opentelemetry/exporter-trace-otlp-proto" : " ^0.54.2" ,
3333 "@opentelemetry/instrumentation" : " ^0.54.2" ,
34- "@opentelemetry/instrumentation-express" : " ^0.44 .0" ,
34+ "@opentelemetry/instrumentation-express" : " ^0.56 .0" ,
3535 "@opentelemetry/instrumentation-http" : " ^0.54.2" ,
36- "@opentelemetry/resources" : " ^1.27 .0" ,
36+ "@opentelemetry/resources" : " ^2.2 .0" ,
3737 "@opentelemetry/sdk-trace-base" : " ^1.27.0" ,
3838 "@opentelemetry/sdk-trace-node" : " ^1.27.0" ,
3939 "@opentelemetry/semantic-conventions" : " ^1.27.0" ,
4040 "axios" : " ^1.6.0" ,
41- "express" : " ^4.17.1 "
41+ "express" : " ^5.1.0 "
4242 },
4343 "devDependencies" : {
44- "@types/express" : " ^4.17.13 " ,
44+ "@types/express" : " ^5.0.5 " ,
4545 "@types/node" : " 18.18.14" ,
4646 "ts-node" : " ^10.6.0" ,
4747 "typescript" : " 5.0.4"
Original file line number Diff line number Diff line change @@ -54,4 +54,4 @@ async function makeRequest() {
5454 ) ;
5555}
5656
57- makeRequest ( ) . catch ( err => console . log ( err ) ) ;
57+ makeRequest ( ) . catch ( err => console . error ( err ) ) ;
Original file line number Diff line number Diff line change @@ -23,14 +23,15 @@ setupTracing('example-express-server');
2323import * as express from 'express' ;
2424import * as axios from 'axios' ;
2525import { RequestHandler } from 'express' ;
26+ import type { Resource } from '@opentelemetry/resources' ;
2627
2728// Setup express
2829const app = express ( ) ;
2930const PORT = 8080 ;
3031
3132const getCrudController = ( ) => {
3233 const router = express . Router ( ) ;
33- const resources : any [ ] = [ ] ;
34+ const resources : Resource [ ] = [ ] ;
3435 router . get ( '/' , ( req , res ) => res . send ( resources ) ) ;
3536 router . post ( '/' , ( req , res ) => {
3637 resources . push ( req . body ) ;
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- import {
18- trace ,
19- SamplingDecision ,
20- SpanKind ,
21- Attributes ,
22- } from '@opentelemetry/api' ;
17+ import { trace , SpanKind , Attributes } from '@opentelemetry/api' ;
2318import { registerInstrumentations } from '@opentelemetry/instrumentation' ;
2419import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' ;
2520import {
2621 Sampler ,
2722 AlwaysOnSampler ,
2823 SimpleSpanProcessor ,
24+ SamplingDecision ,
2925} from '@opentelemetry/sdk-trace-base' ;
3026import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto' ;
31- import { Resource } from '@opentelemetry/resources' ;
3227import {
3328 ATTR_SERVICE_NAME ,
3429 ATTR_HTTP_ROUTE ,
3530} from '@opentelemetry/semantic-conventions' ;
3631import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express' ;
3732import { HttpInstrumentation } from '@opentelemetry/instrumentation-http' ;
33+ import { resourceFromAttributes } from '@opentelemetry/resources' ;
3834
3935export const setupTracing = ( serviceName : string ) => {
4036 const exporter = new OTLPTraceExporter ( { } ) ;
4137 const provider = new NodeTracerProvider ( {
42- resource : new Resource ( {
38+ resource : resourceFromAttributes ( {
4339 [ ATTR_SERVICE_NAME ] : serviceName ,
4440 } ) ,
4541 spanProcessors : [ new SimpleSpanProcessor ( exporter ) ] ,
You can’t perform that action at this time.
0 commit comments