File tree Expand file tree Collapse file tree 5 files changed +39
-1
lines changed
test/OpenTelemetry.Tests/Trace Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -23,3 +23,4 @@ static OpenTelemetry.Context.RuntimeContext.GetValue(string slotName) -> object
23
23
static OpenTelemetry.Context.RuntimeContext.GetValue<T>(string slotName) -> T
24
24
static OpenTelemetry.Context.RuntimeContext.SetValue(string slotName, object value) -> void
25
25
static OpenTelemetry.Context.RuntimeContext.SetValue<T>(string slotName, T value) -> void
26
+ OpenTelemetry.Trace.TelemetrySpan.ParentSpanId.get -> System.Diagnostics.ActivitySpanId
Original file line number Diff line number Diff line change @@ -16,4 +16,5 @@ OpenTelemetry.Metrics.MeterProviderBuilder.MeterProviderBuilder() -> void
16
16
static OpenTelemetry.Context.RuntimeContext.GetValue(string slotName) -> object
17
17
static OpenTelemetry.Context.RuntimeContext.GetValue<T>(string slotName) -> T
18
18
static OpenTelemetry.Context.RuntimeContext.SetValue(string slotName, object value) -> void
19
- static OpenTelemetry.Context.RuntimeContext.SetValue<T>(string slotName, T value) -> void
19
+ static OpenTelemetry.Context.RuntimeContext.SetValue<T>(string slotName, T value) -> void
20
+ OpenTelemetry.Trace.TelemetrySpan.ParentSpanId.get -> System.Diagnostics.ActivitySpanId
Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ * Added ` ParentSpanId ` to ` TelemetrySpan ` ([ #2740 ] ( https://github.com/open-telemetry/opentelemetry-dotnet/pull/2740 ) )
6
+
5
7
## 1.2.0-rc1
6
8
7
9
Released 2021-Nov-29
Original file line number Diff line number Diff line change @@ -64,6 +64,24 @@ public bool IsRecording
64
64
}
65
65
}
66
66
67
+ /// <summary>
68
+ /// Gets the identity of the parent span id, if any.
69
+ /// </summary>
70
+ public ActivitySpanId ParentSpanId
71
+ {
72
+ get
73
+ {
74
+ if ( this . Activity == null )
75
+ {
76
+ return default ;
77
+ }
78
+ else
79
+ {
80
+ return this . Activity . ParentSpanId ;
81
+ }
82
+ }
83
+ }
84
+
67
85
/// <summary>
68
86
/// Sets the status of the span execution.
69
87
/// </summary>
Original file line number Diff line number Diff line change @@ -67,5 +67,21 @@ public void CheckRecordExceptionEmpty()
67
67
telemetrySpan . RecordException ( null ) ;
68
68
Assert . Empty ( activity . Events ) ;
69
69
}
70
+
71
+ [ Fact ]
72
+ public void ParentIds ( )
73
+ {
74
+ using var parentActivity = new Activity ( "parentOperation" ) ;
75
+ parentActivity . Start ( ) ; // can't generate the Id until the operation is started
76
+ using var parentSpan = new TelemetrySpan ( parentActivity ) ;
77
+
78
+ // ParentId should be unset
79
+ Assert . Equal ( default , parentSpan . ParentSpanId ) ;
80
+
81
+ using var childActivity = new Activity ( "childOperation" ) . SetParentId ( parentActivity . Id ) ;
82
+ using var childSpan = new TelemetrySpan ( childActivity ) ;
83
+
84
+ Assert . Equal ( parentSpan . Context . SpanId , childSpan . ParentSpanId ) ;
85
+ }
70
86
}
71
87
}
You can’t perform that action at this time.
0 commit comments