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

@ -130,6 +130,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
serverId := model.ServerId.ValueString()
@ -144,6 +146,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
return
}
ctx = core.LogResponse(ctx)
model.Id = utils.BuildInternalTerraformId(projectId, serverId, networkInterfaceId)
// Set state to fully populated data
@ -163,6 +167,9 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
serverId := model.ServerId.ValueString()
@ -181,6 +188,8 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
return
}
ctx = core.LogResponse(ctx)
if nics == nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network interface attachment", "List of network interfaces attached to the server is nil")
return
@ -221,6 +230,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
serverId := model.ServerId.ValueString()
@ -235,6 +246,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Network interface attachment deleted")
}