Skip to content

Commit

Permalink
Downgrade noisy unstable operation log to debug (#2780)
Browse files Browse the repository at this point in the history
* downgrade log to write in debug mode only

* downgrade log to debug only

---------

Co-authored-by: amaskara-dd <[email protected]>
  • Loading branch information
skarimo and amaskara-dd authored Nov 12, 2024
1 parent 5fed5ae commit a4c3059
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 186 deletions.
9 changes: 6 additions & 3 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ func (a *{{ classname }}) {{ operation.operationId }}(ctx _context.Context{% for
{%- if "x-unstable" in operation %}

operationId := "{{ version }}.{{ operation.operationId }}"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId);
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return {% if returnType %} localVarReturnValue, {% endif %}nil, {{ common_package_name }}.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

{%- endif %}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "{{ version }}.{{ classname }}.{{ operation.operationId }}")
Expand Down
40 changes: 25 additions & 15 deletions api/datadogV2/api_api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ func (a *APIManagementApi) CreateOpenAPI(ctx _context.Context, o ...CreateOpenAP
}

operationId := "v2.CreateOpenAPI"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.CreateOpenAPI")
if err != nil {
Expand Down Expand Up @@ -154,11 +156,13 @@ func (a *APIManagementApi) DeleteOpenAPI(ctx _context.Context, id uuid.UUID) (*_
)

operationId := "v2.DeleteOpenAPI"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.DeleteOpenAPI")
if err != nil {
Expand Down Expand Up @@ -232,11 +236,13 @@ func (a *APIManagementApi) GetOpenAPI(ctx _context.Context, id uuid.UUID) (_io.R
)

operationId := "v2.GetOpenAPI"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.GetOpenAPI")
if err != nil {
Expand Down Expand Up @@ -350,11 +356,13 @@ func (a *APIManagementApi) ListAPIs(ctx _context.Context, o ...ListAPIsOptionalP
}

operationId := "v2.ListAPIs"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.ListAPIs")
if err != nil {
Expand Down Expand Up @@ -471,11 +479,13 @@ func (a *APIManagementApi) UpdateOpenAPI(ctx _context.Context, id uuid.UUID, o .
}

operationId := "v2.UpdateOpenAPI"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.APIManagementApi.UpdateOpenAPI")
if err != nil {
Expand Down
16 changes: 10 additions & 6 deletions api/datadogV2/api_dora_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ func (a *DORAMetricsApi) CreateDORADeployment(ctx _context.Context, body DORADep
)

operationId := "v2.CreateDORADeployment"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.CreateDORADeployment")
if err != nil {
Expand Down Expand Up @@ -124,11 +126,13 @@ func (a *DORAMetricsApi) CreateDORAIncident(ctx _context.Context, body DORAIncid
)

operationId := "v2.CreateDORAIncident"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.CreateDORAIncident")
if err != nil {
Expand Down
40 changes: 25 additions & 15 deletions api/datadogV2/api_incident_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ func (a *IncidentServicesApi) CreateIncidentService(ctx _context.Context, body I
)

operationId := "v2.CreateIncidentService"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentServicesApi.CreateIncidentService")
if err != nil {
Expand Down Expand Up @@ -111,11 +113,13 @@ func (a *IncidentServicesApi) DeleteIncidentService(ctx _context.Context, servic
)

operationId := "v2.DeleteIncidentService"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentServicesApi.DeleteIncidentService")
if err != nil {
Expand Down Expand Up @@ -208,11 +212,13 @@ func (a *IncidentServicesApi) GetIncidentService(ctx _context.Context, serviceId
}

operationId := "v2.GetIncidentService"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentServicesApi.GetIncidentService")
if err != nil {
Expand Down Expand Up @@ -337,11 +343,13 @@ func (a *IncidentServicesApi) ListIncidentServices(ctx _context.Context, o ...Li
}

operationId := "v2.ListIncidentServices"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentServicesApi.ListIncidentServices")
if err != nil {
Expand Down Expand Up @@ -428,11 +436,13 @@ func (a *IncidentServicesApi) UpdateIncidentService(ctx _context.Context, servic
)

operationId := "v2.UpdateIncidentService"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentServicesApi.UpdateIncidentService")
if err != nil {
Expand Down
40 changes: 25 additions & 15 deletions api/datadogV2/api_incident_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ func (a *IncidentTeamsApi) CreateIncidentTeam(ctx _context.Context, body Inciden
)

operationId := "v2.CreateIncidentTeam"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentTeamsApi.CreateIncidentTeam")
if err != nil {
Expand Down Expand Up @@ -111,11 +113,13 @@ func (a *IncidentTeamsApi) DeleteIncidentTeam(ctx _context.Context, teamId strin
)

operationId := "v2.DeleteIncidentTeam"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentTeamsApi.DeleteIncidentTeam")
if err != nil {
Expand Down Expand Up @@ -208,11 +212,13 @@ func (a *IncidentTeamsApi) GetIncidentTeam(ctx _context.Context, teamId string,
}

operationId := "v2.GetIncidentTeam"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentTeamsApi.GetIncidentTeam")
if err != nil {
Expand Down Expand Up @@ -337,11 +343,13 @@ func (a *IncidentTeamsApi) ListIncidentTeams(ctx _context.Context, o ...ListInci
}

operationId := "v2.ListIncidentTeams"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentTeamsApi.ListIncidentTeams")
if err != nil {
Expand Down Expand Up @@ -428,11 +436,13 @@ func (a *IncidentTeamsApi) UpdateIncidentTeam(ctx _context.Context, teamId strin
)

operationId := "v2.UpdateIncidentTeam"
if a.Client.Cfg.IsUnstableOperationEnabled(operationId) {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
} else {
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentTeamsApi.UpdateIncidentTeam")
if err != nil {
Expand Down
Loading

0 comments on commit a4c3059

Please sign in to comment.