File tree Expand file tree Collapse file tree 4 files changed +109
-0
lines changed
dev-packages/node-integration-tests/suites/public-api/metrics Expand file tree Collapse file tree 4 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/node' ;
2+ import { loggingTransport } from '@sentry-internal/node-integration-tests' ;
3+
4+ Sentry . init ( {
5+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
6+ release : '1.0.0' ,
7+ environment : 'test' ,
8+ serverName : 'mi-servidor.com' ,
9+ transport : loggingTransport ,
10+ } ) ;
11+
12+ async function run ( ) : Promise < void > {
13+ Sentry . metrics . count ( 'test.counter' , 1 , { attributes : { endpoint : '/api/test' } } ) ;
14+
15+ await Sentry . flush ( ) ;
16+ }
17+
18+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
19+ run ( ) ;
Original file line number Diff line number Diff line change 1+ import { afterAll , describe , expect , test } from 'vitest' ;
2+ import { cleanupChildProcesses , createRunner } from '../../../../utils/runner' ;
3+
4+ describe ( 'metrics server.address' , ( ) => {
5+ afterAll ( ( ) => {
6+ cleanupChildProcesses ( ) ;
7+ } ) ;
8+
9+ test ( 'should add server.address attribute to metrics when serverName is set' , async ( ) => {
10+ const runner = createRunner ( __dirname , 'scenario.ts' )
11+ . expect ( {
12+ trace_metric : {
13+ items : [
14+ {
15+ timestamp : expect . any ( Number ) ,
16+ trace_id : expect . any ( String ) ,
17+ name : 'test.counter' ,
18+ type : 'counter' ,
19+ value : 1 ,
20+ attributes : {
21+ endpoint : { value : '/api/test' , type : 'string' } ,
22+ 'server.address' : { value : 'mi-servidor.com' , type : 'string' } ,
23+ 'sentry.release' : { value : '1.0.0' , type : 'string' } ,
24+ 'sentry.environment' : { value : 'test' , type : 'string' } ,
25+ 'sentry.sdk.name' : { value : 'sentry.javascript.node' , type : 'string' } ,
26+ 'sentry.sdk.version' : { value : expect . any ( String ) , type : 'string' } ,
27+ } ,
28+ } ,
29+ ] ,
30+ } ,
31+ } )
32+ . start ( ) ;
33+
34+ await runner . completed ( ) ;
35+ } ) ;
36+ } ) ;
Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/node' ;
2+ import { loggingTransport } from '@sentry-internal/node-integration-tests' ;
3+
4+ Sentry . init ( {
5+ dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
6+ release : '1.0.0' ,
7+ environment : 'test' ,
8+ transport : loggingTransport ,
9+ } ) ;
10+
11+ async function run ( ) : Promise < void > {
12+ Sentry . metrics . count ( 'test.counter' , 1 , { attributes : { endpoint : '/api/test' } } ) ;
13+
14+ await Sentry . flush ( ) ;
15+ }
16+
17+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
18+ run ( ) ;
Original file line number Diff line number Diff line change 1+ import { afterAll , describe , expect , test } from 'vitest' ;
2+ import { cleanupChildProcesses , createRunner } from '../../../../utils/runner' ;
3+
4+ describe ( 'metrics server.address' , ( ) => {
5+ afterAll ( ( ) => {
6+ cleanupChildProcesses ( ) ;
7+ } ) ;
8+
9+ test ( 'should add server.address attribute to metrics when serverName is set' , async ( ) => {
10+ const runner = createRunner ( __dirname , 'scenario.ts' )
11+ . expect ( {
12+ trace_metric : {
13+ items : [
14+ {
15+ timestamp : expect . any ( Number ) ,
16+ trace_id : expect . any ( String ) ,
17+ name : 'test.counter' ,
18+ type : 'counter' ,
19+ value : 1 ,
20+ attributes : {
21+ endpoint : { value : '/api/test' , type : 'string' } ,
22+ 'server.address' : { value : expect . any ( String ) , type : 'string' } ,
23+ 'sentry.release' : { value : '1.0.0' , type : 'string' } ,
24+ 'sentry.environment' : { value : 'test' , type : 'string' } ,
25+ 'sentry.sdk.name' : { value : 'sentry.javascript.node' , type : 'string' } ,
26+ 'sentry.sdk.version' : { value : expect . any ( String ) , type : 'string' } ,
27+ } ,
28+ } ,
29+ ] ,
30+ } ,
31+ } )
32+ . start ( ) ;
33+
34+ await runner . completed ( ) ;
35+ } ) ;
36+ } ) ;
You can’t perform that action at this time.
0 commit comments