File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,13 @@ export function newLogger(options) {
129
129
130
130
return {
131
131
info : ( message ) => {
132
+ childLogger . info ( { message } ) ;
133
+
134
+ if ( ! _compasSentryExport . getActiveSpan ( ) ) {
135
+ // Don't add breadcrumbs if we don't have a span. This prevents unmatched logs from showing up in a random span.
136
+ return ;
137
+ }
138
+
132
139
if ( ! addedContextAsBreadcrumb ) {
133
140
// @ts -expect-error
134
141
_compasSentryExport . addBreadcrumb ( {
@@ -150,10 +157,15 @@ export function newLogger(options) {
150
157
level : "info" ,
151
158
type : "default" ,
152
159
} ) ;
153
-
154
- childLogger . info ( { message } ) ;
155
160
} ,
156
161
error : ( message ) => {
162
+ childLogger . error ( { message } ) ;
163
+
164
+ if ( ! _compasSentryExport . getActiveSpan ( ) ) {
165
+ // Don't add breadcrumbs if we don't have a span. This prevents unmatched logs from showing up in a random span.
166
+ return ;
167
+ }
168
+
157
169
if ( ! addedContextAsBreadcrumb ) {
158
170
// @ts -expect-error
159
171
_compasSentryExport . addBreadcrumb ( {
@@ -175,8 +187,6 @@ export function newLogger(options) {
175
187
level : "error" ,
176
188
type : "error" ,
177
189
} ) ;
178
-
179
- childLogger . error ( { message } ) ;
180
190
} ,
181
191
} ;
182
192
}
You can’t perform that action at this time.
0 commit comments