1616
1717import * as assert from 'assert' ;
1818import { context , SpanStatusCode } from '@opentelemetry/api' ;
19- import {
20- SEMATTRS_HTTP_ROUTE ,
21- SEMATTRS_HTTP_METHOD ,
22- } from '@opentelemetry/semantic-conventions' ;
19+ import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions' ;
2320import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks' ;
2421import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' ;
2522import {
@@ -161,7 +158,7 @@ describe('fastify', () => {
161158 assert . deepStrictEqual ( span . attributes , {
162159 'fastify.type' : 'request_handler' ,
163160 'plugin.name' : 'fastify -> @fastify/express' ,
164- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
161+ [ ATTR_HTTP_ROUTE ] : '/test' ,
165162 } ) ;
166163 assert . strictEqual (
167164 span . name ,
@@ -190,7 +187,7 @@ describe('fastify', () => {
190187 'fastify.type' : 'request_handler' ,
191188 'fastify.name' : 'namedHandler' ,
192189 'plugin.name' : 'fastify -> @fastify/express' ,
193- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
190+ [ ATTR_HTTP_ROUTE ] : '/test' ,
194191 } ) ;
195192 assert . strictEqual ( span . name , 'request handler - namedHandler' ) ;
196193
@@ -502,7 +499,7 @@ describe('fastify', () => {
502499 describe ( 'using requestHook in config' , ( ) => {
503500 it ( 'calls requestHook provided function when set in config' , async ( ) => {
504501 const requestHook = ( span : Span , info : FastifyRequestInfo ) => {
505- span . setAttribute ( SEMATTRS_HTTP_METHOD , info . request . method ) ;
502+ span . setAttribute ( 'my.http.method' , info . request . method ) ;
506503 } ;
507504
508505 instrumentation . setConfig ( {
@@ -523,14 +520,14 @@ describe('fastify', () => {
523520 assert . deepStrictEqual ( span . attributes , {
524521 'fastify.type' : 'request_handler' ,
525522 'plugin.name' : 'fastify -> @fastify/express' ,
526- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
527- [ SEMATTRS_HTTP_METHOD ] : 'GET' ,
523+ [ ATTR_HTTP_ROUTE ] : '/test' ,
524+ 'my.http.method' : 'GET' ,
528525 } ) ;
529526 } ) ;
530527
531528 it ( 'does not propagate an error from a requestHook that throws exception' , async ( ) => {
532529 const requestHook = ( span : Span , info : FastifyRequestInfo ) => {
533- span . setAttribute ( SEMATTRS_HTTP_METHOD , info . request . method ) ;
530+ span . setAttribute ( 'my.http.method' , info . request . method ) ;
534531
535532 throw Error ( 'error thrown in requestHook' ) ;
536533 } ;
@@ -553,8 +550,8 @@ describe('fastify', () => {
553550 assert . deepStrictEqual ( span . attributes , {
554551 'fastify.type' : 'request_handler' ,
555552 'plugin.name' : 'fastify -> @fastify/express' ,
556- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
557- [ SEMATTRS_HTTP_METHOD ] : 'GET' ,
553+ [ ATTR_HTTP_ROUTE ] : '/test' ,
554+ 'my.http.method' : 'GET' ,
558555 } ) ;
559556 } ) ;
560557 } ) ;
0 commit comments