@@ -5,10 +5,7 @@ import {
55 SimpleSpanProcessor ,
66} from "@opentelemetry/sdk-trace-base" ;
77import { describe , expect , test } from "vite-plus/test" ;
8- import {
9- isBlockedTelemetryAttribute ,
10- SanitizingSpanProcessor ,
11- } from "../src/telemetry/sanitize" ;
8+ import { isBlockedTelemetryAttribute , SanitizingSpanProcessor } from "../src/telemetry/sanitize" ;
129
1310describe ( "telemetry span sanitization" , ( ) => {
1411 test . each ( [
@@ -48,9 +45,7 @@ describe("telemetry span sanitization", () => {
4845 test ( "removes sensitive span, event, and link values before export" , async ( ) => {
4946 const exporter = new InMemorySpanExporter ( ) ;
5047 const provider = new BasicTracerProvider ( {
51- spanProcessors : [
52- new SanitizingSpanProcessor ( new SimpleSpanProcessor ( exporter ) ) ,
53- ] ,
48+ spanProcessors : [ new SanitizingSpanProcessor ( new SimpleSpanProcessor ( exporter ) ) ] ,
5449 } ) ;
5550 const tracer = provider . getTracer ( "sanitize-test" ) ;
5651 const sensitive = "fixture-private-value" ;
@@ -60,26 +55,29 @@ describe("telemetry span sanitization", () => {
6055 traceFlags : 1 ,
6156 } ) ;
6257
63- tracer . startSpan ( "safe-operation" , {
64- attributes : {
65- "http.request.method" : "POST" ,
66- "http.request.header.authorization" : sensitive ,
67- "request.body" : sensitive ,
68- "db.statement" : `select '${ sensitive } '` ,
69- "db.query.parameters" : sensitive ,
70- "url.full" : `https://example.com/path?token=${ sensitive } ` ,
71- } ,
72- links : [
73- {
74- context : trace . getSpanContext ( linkedContext ) ! ,
75- attributes : { "session.token" : sensitive } ,
58+ tracer
59+ . startSpan ( "safe-operation" , {
60+ attributes : {
61+ "http.request.method" : "POST" ,
62+ "http.request.header.authorization" : sensitive ,
63+ "request.body" : sensitive ,
64+ "db.statement" : `select '${ sensitive } '` ,
65+ "db.query.parameters" : sensitive ,
66+ "url.full" : `https://example.com/path?token=${ sensitive } ` ,
7667 } ,
77- ] ,
78- } ) . addEvent ( "failure" , {
79- "exception.type" : "Error" ,
80- "exception.message" : sensitive ,
81- "exception.stacktrace" : sensitive ,
82- } ) . end ( ) ;
68+ links : [
69+ {
70+ context : trace . getSpanContext ( linkedContext ) ! ,
71+ attributes : { "session.token" : sensitive } ,
72+ } ,
73+ ] ,
74+ } )
75+ . addEvent ( "failure" , {
76+ "exception.type" : "Error" ,
77+ "exception.message" : sensitive ,
78+ "exception.stacktrace" : sensitive ,
79+ } )
80+ . end ( ) ;
8381 await provider . forceFlush ( ) ;
8482
8583 const finishedSpan = exporter . getFinishedSpans ( ) [ 0 ] ! ;
0 commit comments