|
4 | 4 | getActiveSpan, |
5 | 5 | getCapturedScopesOnSpan, |
6 | 6 | getRootSpan, |
7 | | - SEMANTIC_ATTRIBUTE_SENTRY_OP, |
8 | | - SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE, |
9 | 7 | spanToJSON, |
| 8 | + spanToStaticSpanJSON, |
10 | 9 | SPAN_STATUS_ERROR, |
11 | 10 | SPAN_STATUS_OK, |
12 | 11 | startSpanManual, |
@@ -136,30 +135,34 @@ describe('SentryTracerProvider', () => { |
136 | 135 | it('finalizes span statuses like the OpenTelemetry exporter', () => { |
137 | 136 | const okSpan = trace.getTracer('test').startSpan('ok'); |
138 | 137 | applyOtelSpanData(okSpan as Span, { finalizeStatus: true }); |
| 138 | + expect(spanToStaticSpanJSON(okSpan as Span).status).toBe('ok'); |
139 | 139 | expect(spanToJSON(okSpan as Span).status).toBe('ok'); |
| 140 | + expect(spanToJSON(okSpan as Span).attributes).not.toHaveProperty('sentry.status.message'); |
140 | 141 |
|
141 | 142 | const httpErrorSpan = trace.getTracer('test').startSpan('http-error'); |
142 | 143 | httpErrorSpan.setAttribute('http.response.status_code', 500); |
143 | 144 | applyOtelSpanData(httpErrorSpan as Span, { finalizeStatus: true }); |
144 | | - expect(spanToJSON(httpErrorSpan as Span).attributes[SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]).toBe( |
145 | | - 'internal_error', |
146 | | - ); |
| 145 | + expect(spanToStaticSpanJSON(httpErrorSpan as Span).status).toBe('internal_error'); |
| 146 | + expect(spanToJSON(httpErrorSpan as Span).status).toBe('error'); |
| 147 | + expect(spanToJSON(httpErrorSpan as Span).attributes).toMatchObject({ |
| 148 | + 'sentry.status.message': 'internal_error', |
| 149 | + }); |
147 | 150 |
|
148 | 151 | const legacyHttpErrorSpan = trace.getTracer('test').startSpan('legacy-http-error'); |
149 | 152 | legacyHttpErrorSpan.setAttribute('http.status_code', 500); |
150 | 153 | applyOtelSpanData(legacyHttpErrorSpan as Span, { finalizeStatus: true }); |
| 154 | + expect(spanToStaticSpanJSON(legacyHttpErrorSpan as Span).status).toBe('internal_error'); |
| 155 | + expect(spanToJSON(legacyHttpErrorSpan as Span).status).toBe('error'); |
151 | 156 | expect(spanToJSON(legacyHttpErrorSpan as Span).attributes).toMatchObject({ |
152 | | - [SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]: 'internal_error', |
153 | 157 | 'http.response.status_code': 500, |
154 | 158 | 'http.status_code': 500, |
| 159 | + 'sentry.status.message': 'internal_error', |
155 | 160 | }); |
156 | 161 |
|
157 | 162 | const customErrorSpan = trace.getTracer('test').startSpan('custom-error'); |
158 | 163 | customErrorSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'This is a custom error' }); |
159 | 164 | applyOtelSpanData(customErrorSpan as Span, { finalizeStatus: true }); |
160 | | - expect(spanToJSON(customErrorSpan as Span).attributes[SEMANTIC_ATTRIBUTE_SENTRY_STATUS_MESSAGE]).toBe( |
161 | | - 'internal_error', |
162 | | - ); |
| 165 | + expect(spanToStaticSpanJSON(customErrorSpan as Span).status).toBe('internal_error'); |
163 | 166 | }); |
164 | 167 |
|
165 | 168 | it('preserves an explicit OK status when finalizing', () => { |
@@ -194,20 +197,4 @@ describe('SentryTracerProvider', () => { |
194 | 197 | expect(streamed.status).toBe('error'); |
195 | 198 | expect(streamed.attributes?.['sentry.status.message']).toBe('Cannot enqueue Query after fatal error.'); |
196 | 199 | }); |
197 | | -<<<<<<< HEAD |
198 | | -======= |
199 | | - |
200 | | - it('infers op for HTTP server spans', () => { |
201 | | - const span = trace.getTracer('test').startSpan('GET', { |
202 | | - kind: SpanKind.SERVER, |
203 | | - attributes: { |
204 | | - 'http.method': 'GET', |
205 | | - 'http.route': '/my-path/:id', |
206 | | - }, |
207 | | - }); |
208 | | - |
209 | | - const json = spanToJSON(span as Span); |
210 | | - expect(json.attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP]).toBe('http.server'); |
211 | | - }); |
212 | | ->>>>>>> 598470e78d (feat(core)!: Return `StreamedSpanJSON` from `spanToJSON`) |
213 | 200 | }); |
0 commit comments