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

@ -160,6 +160,8 @@ func (r *networkAreaRouteResource) Create(ctx context.Context, req resource.Crea
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
ctx = tflog.SetField(ctx, "organization_id", organizationId)
networkAreaId := model.NetworkAreaId.ValueString()
@ -178,6 +180,9 @@ func (r *networkAreaRouteResource) Create(ctx context.Context, req resource.Crea
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating network area route", fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
if routes.Items == nil || len(*routes.Items) == 0 {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating network area route.", "Empty response from API")
return
@ -221,6 +226,9 @@ func (r *networkAreaRouteResource) Read(ctx context.Context, req resource.ReadRe
organizationId := model.OrganizationId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "organization_id", organizationId)
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
@ -236,6 +244,8 @@ func (r *networkAreaRouteResource) Read(ctx context.Context, req resource.ReadRe
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(ctx, networkAreaRouteResp, &model)
if err != nil {
@ -264,6 +274,9 @@ func (r *networkAreaRouteResource) Delete(ctx context.Context, req resource.Dele
organizationId := model.OrganizationId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "organization_id", organizationId)
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
@ -275,6 +288,8 @@ func (r *networkAreaRouteResource) Delete(ctx context.Context, req resource.Dele
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Network area route deleted")
}
@ -291,6 +306,9 @@ func (r *networkAreaRouteResource) Update(ctx context.Context, req resource.Upda
organizationId := model.OrganizationId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
ctx = core.InitProviderContext(ctx)
ctx = tflog.SetField(ctx, "organization_id", organizationId)
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
@ -316,6 +334,8 @@ func (r *networkAreaRouteResource) Update(ctx context.Context, req resource.Upda
return
}
ctx = core.LogResponse(ctx)
err = mapFields(ctx, networkAreaRouteResp, &model)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network area route", fmt.Sprintf("Processing API payload: %v", err))