Skip to content

Commit

Permalink
test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Nov 8, 2024
1 parent b46c476 commit 025c94e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions internal/extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,27 @@ func (em *ExtensionManager) SendEndInvocationRequest(ctx context.Context, functi
}

func dumpContext(ctx context.Context) {
contextValues := reflect.ValueOf(ctx).Elem()
contextKeys := reflect.TypeOf(ctx).Elem()
val := reflect.ValueOf(ctx)
typ := reflect.TypeOf(ctx)

if contextKeys.Kind() == reflect.Struct {
for i := 0; i < contextValues.NumField(); i++ {
field := contextValues.Field(i)
fieldName := contextKeys.Field(i).Name
fmt.Printf("%s: %v\n", fieldName, field.Interface())
// If it's a pointer, get the underlying element
if val.Kind() == reflect.Ptr {
val = val.Elem()
typ = typ.Elem()
}

if typ.Kind() == reflect.Struct {
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
fieldType := typ.Field(i)

// Just print the field name and type, since we can't safely access unexported fields
fmt.Printf("Field: %s, Type: %v\n", fieldType.Name, fieldType.Type)

// If this field is itself a context, recurse into it
if field.Type().Implements(reflect.TypeOf((*context.Context)(nil)).Elem()) {
if !field.IsNil() {
fmt.Printf("Nested context in %s:\n", fieldName)
fmt.Printf("Nested context in %s:\n", fieldType.Name)
dumpContext(field.Interface().(context.Context))
}
}
Expand Down

0 comments on commit 025c94e

Please sign in to comment.