You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cli/azd/docs/extension-framework.md
+18-26Lines changed: 18 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -336,40 +336,32 @@ The build process automatically creates binaries for multiple platforms and arch
336
336
337
337
### Distributed Tracing
338
338
339
-
`azd` uses OpenTelemetry and W3C Trace Context for distributed tracing. To ensure your extension's operations are correctly correlated with the parent `azd`process, you must hydrate the context in your extension's entry point.
339
+
`azd` uses OpenTelemetry and W3C Trace Context for distributed tracing. Trace context is propagated through gRPC metadata, and `azd`sets `TRACEPARENT` in the environment when it launches an extension.
340
340
341
-
**Update `main.go`:**
341
+
Use `azdext.NewContext()` to hydrate the root context with trace context:
342
342
343
343
```go
344
-
import (
345
-
"context"
346
-
"os"
347
-
"github.com/azure/azure-dev/cli/azd/pkg/azdext"
348
-
)
349
-
350
344
funcmain() {
351
-
ctx:= context.Background()
345
+
ctx:= azdext.NewContext()
346
+
rootCmd:= cmd.NewRootCommand()
347
+
iferr:= rootCmd.ExecuteContext(ctx); err != nil {
348
+
// Handle error
349
+
}
350
+
}
351
+
```
352
352
353
-
// Hydrate context with traceparent from environment if present
354
-
// This ensures the extension process participates in the active trace
0 commit comments