File tree 4 files changed +61
-0
lines changed
4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ interface ExceptionWithCode {
18
+ code : string ;
19
+ name ?: string ;
20
+ message ?: string ;
21
+ stack ?: string ;
22
+ }
23
+
24
+ interface ExceptionWithMessage {
25
+ code ?: string ;
26
+ message : string ;
27
+ name ?: string ;
28
+ stack ?: string ;
29
+ }
30
+
31
+ interface ExceptionWithName {
32
+ code ?: string ;
33
+ message ?: string ;
34
+ name : string ;
35
+ stack ?: string ;
36
+ }
37
+
38
+ /**
39
+ * Defines Exception.
40
+ *
41
+ * string or an object with one of (message or name or code) and optional stack
42
+ */
43
+ export type Exception =
44
+ | ExceptionWithCode
45
+ | ExceptionWithMessage
46
+ | ExceptionWithName
47
+ | string ;
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ export * from './common/Exception' ;
17
18
export * from './common/Logger' ;
18
19
export * from './common/Time' ;
19
20
export * from './context/propagation/getter' ;
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ import { Exception } from '../common/Exception' ;
17
18
import { TimeInput } from '../common/Time' ;
18
19
import { Attributes } from './attributes' ;
19
20
import { Span } from './span' ;
@@ -76,6 +77,9 @@ export class NoopSpan implements Span {
76
77
isRecording ( ) : boolean {
77
78
return false ;
78
79
}
80
+
81
+ // By default does nothing
82
+ recordException ( exception : Exception , time ?: TimeInput ) : void { }
79
83
}
80
84
81
85
export const NOOP_SPAN = new NoopSpan ( ) ;
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ import { Exception } from '../common/Exception' ;
17
18
import { Attributes } from './attributes' ;
18
19
import { SpanContext } from './span_context' ;
19
20
import { Status } from './status' ;
@@ -114,4 +115,12 @@ export interface Span {
114
115
* with the `AddEvent` operation and attributes using `setAttributes`.
115
116
*/
116
117
isRecording ( ) : boolean ;
118
+
119
+ /**
120
+ * Sets exception as a span event
121
+ * @param exception the exception the only accepted values are string or Error
122
+ * @param [time] the time to set as Span's event time. If not provided,
123
+ * use the current time.
124
+ */
125
+ recordException ( exception : Exception , time ?: TimeInput ) : void ;
117
126
}
You can’t perform that action at this time.
0 commit comments