feat: add logging for trace id (#1061)

relates to STACKITTPR-290
This commit is contained in:
Marcel Jacek 2025-11-27 11:06:18 +01:00 committed by GitHub
parent d1e12fcf64
commit 24b7387db9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 1597 additions and 7 deletions

View file

@ -144,6 +144,9 @@ func (d *networkInterfaceDataSource) Read(ctx context.Context, req datasource.Re
projectId := model.ProjectId.ValueString()
networkId := model.NetworkId.ValueString()
networkInterfaceId := model.NetworkInterfaceId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "network_id", networkId)
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
@ -164,6 +167,8 @@ func (d *networkInterfaceDataSource) Read(ctx context.Context, req datasource.Re
return
}
ctx = core.LogResponse(ctx)
err = mapFields(ctx, networkInterfaceResp, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network interface", fmt.Sprintf("Processing API payload: %v", err))

View file

@ -257,6 +257,8 @@ func (r *networkInterfaceResource) Create(ctx context.Context, req resource.Crea
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
networkId := model.NetworkId.ValueString()
@ -276,6 +278,8 @@ func (r *networkInterfaceResource) Create(ctx context.Context, req resource.Crea
return
}
ctx = core.LogResponse(ctx)
networkInterfaceId := *networkInterface.Id
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
@ -306,6 +310,9 @@ func (r *networkInterfaceResource) Read(ctx context.Context, req resource.ReadRe
projectId := model.ProjectId.ValueString()
networkId := model.NetworkId.ValueString()
networkInterfaceId := model.NetworkInterfaceId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "network_id", networkId)
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
@ -321,6 +328,8 @@ func (r *networkInterfaceResource) Read(ctx context.Context, req resource.ReadRe
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(ctx, networkInterfaceResp, &model)
if err != nil {
@ -348,6 +357,9 @@ func (r *networkInterfaceResource) Update(ctx context.Context, req resource.Upda
projectId := model.ProjectId.ValueString()
networkId := model.NetworkId.ValueString()
networkInterfaceId := model.NetworkInterfaceId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "network_id", networkId)
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
@ -373,6 +385,8 @@ func (r *networkInterfaceResource) Update(ctx context.Context, req resource.Upda
return
}
ctx = core.LogResponse(ctx)
err = mapFields(ctx, nicResp, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network interface", fmt.Sprintf("Processing API payload: %v", err))
@ -399,6 +413,9 @@ func (r *networkInterfaceResource) Delete(ctx context.Context, req resource.Dele
projectId := model.ProjectId.ValueString()
networkId := model.NetworkId.ValueString()
networkInterfaceId := model.NetworkInterfaceId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "network_id", networkId)
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
@ -410,6 +427,8 @@ func (r *networkInterfaceResource) Delete(ctx context.Context, req resource.Dele
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Network interface deleted")
}