@@ -18,7 +18,7 @@ describe('Prometheus', () => {
18
18
afterEach ( ( ) => {
19
19
registry . clear ( ) ;
20
20
} ) ;
21
- it ( 'http flag should work and do not send headers by default ' , async ( ) => {
21
+ it ( 'http flag should work' , async ( ) => {
22
22
const yoga = createYoga ( {
23
23
schema,
24
24
plugins : [
@@ -47,21 +47,20 @@ describe('Prometheus', () => {
47
47
expect ( metrics ) . toContain ( 'graphql_yoga_http_duration_bucket' ) ;
48
48
expect ( metrics ) . toContain ( 'operationName="TestProm"' ) ;
49
49
expect ( metrics ) . toContain ( 'operationType="query"' ) ;
50
- expect ( metrics ) . toContain ( 'url="http://localhost:4000/graphql"' ) ;
51
50
expect ( metrics ) . toContain ( 'method="POST"' ) ;
52
51
expect ( metrics ) . toContain ( 'statusCode="200"' ) ;
53
- expect ( metrics ) . toContain ( 'statusText="OK"' ) ;
54
- expect ( metrics ) . not . toContain ( 'requestHeaders' ) ;
55
- expect ( metrics ) . not . toContain ( 'x-test=test' ) ;
56
52
} ) ;
57
- it ( 'httpRequestHeaders should work ' , async ( ) => {
53
+ it ( 'labels should be excluded ' , async ( ) => {
58
54
const yoga = createYoga ( {
59
55
schema,
60
56
plugins : [
61
57
usePrometheus ( {
62
58
http : true ,
63
- httpRequestHeaders : true ,
64
59
registry,
60
+ labels : {
61
+ operationName : false ,
62
+ operationType : false ,
63
+ } ,
65
64
} ) ,
66
65
] ,
67
66
} ) ;
@@ -82,54 +81,12 @@ describe('Prometheus', () => {
82
81
await result . text ( ) ;
83
82
const metrics = await registry . metrics ( ) ;
84
83
expect ( metrics ) . toContain ( 'graphql_yoga_http_duration_bucket' ) ;
85
- expect ( metrics ) . toContain ( 'operationName="TestProm"' ) ;
86
- expect ( metrics ) . toContain ( 'operationType="query"' ) ;
87
- expect ( metrics ) . toContain ( 'url="http://localhost:4000/graphql"' ) ;
88
- expect ( metrics ) . toContain ( 'method="POST"' ) ;
89
- expect ( metrics ) . toContain ( 'statusCode="200"' ) ;
90
- expect ( metrics ) . toContain ( 'statusText="OK"' ) ;
91
- expect ( metrics ) . toContain (
92
- 'requestHeaders="{\\"content-type\\":\\"application/json\\",\\"x-test\\":\\"test\\",\\"content-length\\":\\"82\\"}"}' ,
93
- ) ;
94
- } ) ;
95
- it ( 'httpResponseHeaders should work' , async ( ) => {
96
- const yoga = createYoga ( {
97
- schema,
98
- plugins : [
99
- usePrometheus ( {
100
- http : true ,
101
- httpResponseHeaders : true ,
102
- registry,
103
- } ) ,
104
- ] ,
105
- } ) ;
106
- const result = await yoga . fetch ( 'http://localhost:4000/graphql' , {
107
- method : 'POST' ,
108
- headers : {
109
- 'Content-Type' : 'application/json' ,
110
- 'x-test' : 'test' ,
111
- } ,
112
- body : JSON . stringify ( {
113
- query : /* GraphQL */ `
114
- query TestProm {
115
- hello
116
- }
117
- ` ,
118
- } ) ,
119
- } ) ;
120
- await result . text ( ) ;
121
- const metrics = await registry . metrics ( ) ;
122
- expect ( metrics ) . toContain ( 'graphql_yoga_http_duration_bucket' ) ;
123
- expect ( metrics ) . toContain ( 'operationName="TestProm"' ) ;
124
- expect ( metrics ) . toContain ( 'operationType="query"' ) ;
125
- expect ( metrics ) . toContain ( 'url="http://localhost:4000/graphql"' ) ;
84
+ expect ( metrics ) . not . toContain ( 'operationName="TestProm"' ) ;
85
+ expect ( metrics ) . not . toContain ( 'operationType="query"' ) ;
126
86
expect ( metrics ) . toContain ( 'method="POST"' ) ;
127
87
expect ( metrics ) . toContain ( 'statusCode="200"' ) ;
128
- expect ( metrics ) . toContain ( 'statusText="OK"' ) ;
129
- expect ( metrics ) . toContain (
130
- `responseHeaders="{\\"content-type\\":\\"application/json; charset=utf-8\\",\\"content-length\\":\\"33\\"}"}` ,
131
- ) ;
132
88
} ) ;
89
+
133
90
it ( 'endpoint should work' , async ( ) => {
134
91
const yoga = createYoga ( {
135
92
schema,
@@ -162,9 +119,7 @@ describe('Prometheus', () => {
162
119
expect ( metrics ) . toContain ( 'graphql_yoga_http_duration_bucket' ) ;
163
120
expect ( metrics ) . toContain ( 'operationName="TestProm"' ) ;
164
121
expect ( metrics ) . toContain ( 'operationType="query"' ) ;
165
- expect ( metrics ) . toContain ( 'url="http://localhost:4000/graphql"' ) ;
166
122
expect ( metrics ) . toContain ( 'method="POST"' ) ;
167
123
expect ( metrics ) . toContain ( 'statusCode="200"' ) ;
168
- expect ( metrics ) . toContain ( 'statusText="OK"' ) ;
169
124
} ) ;
170
125
} ) ;
0 commit comments