16
16
17
17
import * as assert from 'assert' ;
18
18
import { 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' ;
23
20
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks' ;
24
21
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' ;
25
22
import {
@@ -161,7 +158,7 @@ describe('fastify', () => {
161
158
assert . deepStrictEqual ( span . attributes , {
162
159
'fastify.type' : 'request_handler' ,
163
160
'plugin.name' : 'fastify -> @fastify/express' ,
164
- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
161
+ [ ATTR_HTTP_ROUTE ] : '/test' ,
165
162
} ) ;
166
163
assert . strictEqual (
167
164
span . name ,
@@ -190,7 +187,7 @@ describe('fastify', () => {
190
187
'fastify.type' : 'request_handler' ,
191
188
'fastify.name' : 'namedHandler' ,
192
189
'plugin.name' : 'fastify -> @fastify/express' ,
193
- [ SEMATTRS_HTTP_ROUTE ] : '/test' ,
190
+ [ ATTR_HTTP_ROUTE ] : '/test' ,
194
191
} ) ;
195
192
assert . strictEqual ( span . name , 'request handler - namedHandler' ) ;
196
193
@@ -502,7 +499,7 @@ describe('fastify', () => {
502
499
describe ( 'using requestHook in config' , ( ) => {
503
500
it ( 'calls requestHook provided function when set in config' , async ( ) => {
504
501
const requestHook = ( span : Span , info : FastifyRequestInfo ) => {
505
- span . setAttribute ( SEMATTRS_HTTP_METHOD , info . request . method ) ;
502
+ span . setAttribute ( 'my.http.method' , info . request . method ) ;
506
503
} ;
507
504
508
505
instrumentation . setConfig ( {
@@ -523,14 +520,14 @@ describe('fastify', () => {
523
520
assert . deepStrictEqual ( span . attributes , {
524
521
'fastify.type' : 'request_handler' ,
525
522
'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' ,
528
525
} ) ;
529
526
} ) ;
530
527
531
528
it ( 'does not propagate an error from a requestHook that throws exception' , async ( ) => {
532
529
const requestHook = ( span : Span , info : FastifyRequestInfo ) => {
533
- span . setAttribute ( SEMATTRS_HTTP_METHOD , info . request . method ) ;
530
+ span . setAttribute ( 'my.http.method' , info . request . method ) ;
534
531
535
532
throw Error ( 'error thrown in requestHook' ) ;
536
533
} ;
@@ -553,8 +550,8 @@ describe('fastify', () => {
553
550
assert . deepStrictEqual ( span . attributes , {
554
551
'fastify.type' : 'request_handler' ,
555
552
'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' ,
558
555
} ) ;
559
556
} ) ;
560
557
} ) ;
0 commit comments