Skip to content

Commit 46daa71

Browse files
committed
updated how traceparent is created
1 parent d6f6cce commit 46daa71

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/Modules/Microsoft.Azure.Functions.PowerShellWorker/Microsoft.Azure.Functions.PowerShellWorker.psm1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,36 @@ function Start-DurableOrchestration {
133133

134134
$Body = $InputObject | ConvertTo-Json -Compress
135135

136+
$invokeParams = @{
137+
Uri = $Uri
138+
Method = 'POST'
139+
ContentType = 'application/json'
140+
Body = $Body
141+
}
142+
136143
try {
137-
$activity = Start-FunctionsOpenTelemetrySpan
138-
$traceID = $activity.activity.TraceId
144+
$activity = Start-FunctionsOpenTelemetrySpan -ActivityName "Starting orchestration"
145+
146+
$traceId = $activity.activity.TraceId
147+
$spanId = $activity.activity.SpanId
148+
149+
# Construct the traceparent header
150+
$traceParent = "00-$traceId-$spanId-01"
151+
152+
$traceState = $activity.activity.TraceState
153+
154+
$invokeParams.Headers = @{
155+
'traceparent' = $traceParent
156+
'tracestate' = $traceState
157+
}
139158
# Do whatever you need to do with the trace information using the activity here
140159
} catch {
141160
# Do something better - correctly handle errors when the OTel SDK is not available
142161
# Output errors from this command in a reasonable way
143162
# Detect if calling Stop-FunctionsOpenTelemetrySpan is necessary and change that logic too
144163
}
145164

146-
$null = Invoke-RestMethod -Uri $Uri -Method 'POST' -ContentType 'application/json' -Body $Body
165+
$null = Invoke-RestMethod @invokeParams
147166

148167
try {
149168
Stop-FunctionsOpenTelemetrySpan -Activity $activity

0 commit comments

Comments
 (0)