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

@ -78,6 +78,8 @@ func (d *routingTableRouteDataSource) Read(ctx context.Context, req datasource.R
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
region := d.providerData.GetRegionWithOverride(model.Region)
routingTableId := model.RoutingTableId.ValueString()
@ -106,6 +108,8 @@ func (d *routingTableRouteDataSource) Read(ctx context.Context, req datasource.R
return
}
ctx = core.LogResponse(ctx)
err = shared.MapRouteModel(ctx, routeResp, &model, region)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table route", fmt.Sprintf("Processing API payload: %v", err))

View file

@ -237,6 +237,8 @@ func (r *routeResource) Create(ctx context.Context, req resource.CreateRequest,
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -260,6 +262,8 @@ func (r *routeResource) Create(ctx context.Context, req resource.CreateRequest,
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFieldsFromList(ctx, routeResp, &model, region)
if err != nil {
@ -284,6 +288,9 @@ func (r *routeResource) Read(ctx context.Context, req resource.ReadRequest, resp
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -302,6 +309,8 @@ func (r *routeResource) Read(ctx context.Context, req resource.ReadRequest, resp
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = shared.MapRouteModel(ctx, routeResp, &model, region)
if err != nil {
@ -328,6 +337,8 @@ func (r *routeResource) Update(ctx context.Context, req resource.UpdateRequest,
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -361,6 +372,8 @@ func (r *routeResource) Update(ctx context.Context, req resource.UpdateRequest,
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = shared.MapRouteModel(ctx, route, &model, region)
if err != nil {
@ -385,6 +398,8 @@ func (r *routeResource) Delete(ctx context.Context, req resource.DeleteRequest,
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -403,6 +418,8 @@ func (r *routeResource) Delete(ctx context.Context, req resource.DeleteRequest,
core.LogAndAddError(ctx, &resp.Diagnostics, "Error routing table route", fmt.Sprintf("Calling API: %v", err))
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Routing table route deleted")
}

View file

@ -89,6 +89,8 @@ func (d *routingTableRoutesDataSource) Read(ctx context.Context, req datasource.
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
region := d.providerData.GetRegionWithOverride(model.Region)
networkAreaId := model.NetworkAreaId.ValueString()
@ -114,6 +116,8 @@ func (d *routingTableRoutesDataSource) Read(ctx context.Context, req datasource.
return
}
ctx = core.LogResponse(ctx)
err = mapDataSourceRoutingTableRoutes(ctx, routesResp, &model, region)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table routes", fmt.Sprintf("Processing API payload: %v", err))

View file

@ -81,6 +81,8 @@ func (d *routingTableDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
region := d.providerData.GetRegionWithOverride(model.Region)
routingTableId := model.RoutingTableId.ValueString()
@ -106,6 +108,8 @@ func (d *routingTableDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}
ctx = core.LogResponse(ctx)
err = mapDatasourceFields(ctx, routingTableResp, &model, region)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table", fmt.Sprintf("Processing API payload: %v", err))

View file

@ -228,6 +228,8 @@ func (r *routingTableResource) Create(ctx context.Context, req resource.CreateRe
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
region := r.providerData.GetRegionWithOverride(model.Region)
@ -249,6 +251,8 @@ func (r *routingTableResource) Create(ctx context.Context, req resource.CreateRe
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(ctx, routingTable, &model, region)
if err != nil {
@ -273,6 +277,8 @@ func (r *routingTableResource) Read(ctx context.Context, req resource.ReadReques
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -299,6 +305,8 @@ func (r *routingTableResource) Read(ctx context.Context, req resource.ReadReques
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(ctx, routingTableResp, &model, region)
if err != nil {
@ -324,6 +332,8 @@ func (r *routingTableResource) Update(ctx context.Context, req resource.UpdateRe
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
routingTableId := model.RoutingTableId.ValueString()
networkAreaId := model.NetworkAreaId.ValueString()
@ -355,6 +365,8 @@ func (r *routingTableResource) Update(ctx context.Context, req resource.UpdateRe
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(ctx, routingTable, &model, region)
if err != nil {
@ -380,6 +392,8 @@ func (r *routingTableResource) Delete(ctx context.Context, req resource.DeleteRe
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
region := r.providerData.GetRegionWithOverride(model.Region)
routingTableId := model.RoutingTableId.ValueString()
@ -396,6 +410,8 @@ func (r *routingTableResource) Delete(ctx context.Context, req resource.DeleteRe
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Routing table deleted")
}

View file

@ -123,6 +123,8 @@ func (d *routingTablesDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
ctx = core.InitProviderContext(ctx)
organizationId := model.OrganizationId.ValueString()
region := d.providerData.GetRegionWithOverride(model.Region)
networkAreaId := model.NetworkAreaId.ValueString()
@ -146,6 +148,8 @@ func (d *routingTablesDataSource) Read(ctx context.Context, req datasource.ReadR
return
}
ctx = core.LogResponse(ctx)
err = mapDataSourceRoutingTables(ctx, routingTablesResp, &model, region)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table", fmt.Sprintf("Processing API payload: %v", err))