Skip to content

Commit

Permalink
PMM-13416 fix log level value on API.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Oct 24, 2024
1 parent e4f8742 commit 614c85d
Show file tree
Hide file tree
Showing 13 changed files with 465 additions and 269 deletions.
12 changes: 3 additions & 9 deletions admin/pkg/flags/loglevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
package flags

import (
"fmt"
"strings"

"github.com/AlekSi/pointer"

"github.com/percona/pmm/utils/enums"
)

// LogLevelFatalFlags contains log level flag with "fatal" option.
Expand All @@ -37,10 +36,5 @@ type LogLevel string

// EnumValue returns pointer to string representation of LogLevel.
func (l LogLevel) EnumValue() *string {
return pointer.To(convertEnum("LOG_LEVEL", string(l)))
}

// convertEnum converts flag value to value supported by API.
func convertEnum(prefix string, value string) string {
return fmt.Sprintf("%s_%s", prefix, strings.ToUpper(value))
return pointer.To(enums.ConvertEnum("LOG_LEVEL", string(l)))
}
8 changes: 6 additions & 2 deletions admin/pkg/flags/metrics_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package flags

import "github.com/AlekSi/pointer"
import (
"github.com/AlekSi/pointer"

"github.com/percona/pmm/utils/enums"
)

// MetricsModeFlags contains flags for metrics mode.
type MetricsModeFlags struct {
Expand All @@ -26,5 +30,5 @@ type MetricsMode string

// EnumValue returns pointer to string representation of LogLevel.
func (l MetricsMode) EnumValue() *string {
return pointer.To(convertEnum("METRICS_MODE", string(l)))
return pointer.To(enums.ConvertEnum("METRICS_MODE", string(l)))
}
Binary file modified api/descriptor.bin
Binary file not shown.
27 changes: 27 additions & 0 deletions api/inventory/v1/types/log_levels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2023 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package types

import (
"github.com/AlekSi/pointer"

inventoryv1 "github.com/percona/pmm/api/inventory/v1"
"github.com/percona/pmm/utils/enums"
)

func LogLevelAPIValue(l *string) inventoryv1.LogLevel {
return inventoryv1.LogLevel(inventoryv1.LogLevel_value[enums.ConvertEnum("LOG_LEVEL", pointer.Get(l))])
}
484 changes: 246 additions & 238 deletions api/management/v1/agent.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions api/management/v1/agent.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/management/v1/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package management.v1;

import "google/protobuf/timestamp.proto";
import "inventory/v1/log_level.proto";

message UniversalAgent {
message MySQLOptions {
Expand Down Expand Up @@ -72,7 +73,7 @@ message UniversalAgent {
// Listen port for scraping metrics.
uint32 listen_port = 11;
// Log level for exporter.
string log_level = 12;
inventory.v1.LogLevel log_level = 12;
// Limit query length in QAN.
int32 max_query_length = 13;
// Limit query log size in QAN.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions api/management/v1/json/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,18 @@
"x-order": 10
},
"log_level": {
"description": "Log level for exporter.",
"description": "- LOG_LEVEL_UNSPECIFIED: Auto",
"type": "string",
"title": "Log level for exporters",
"default": "LOG_LEVEL_UNSPECIFIED",
"enum": [
"LOG_LEVEL_UNSPECIFIED",
"LOG_LEVEL_FATAL",
"LOG_LEVEL_ERROR",
"LOG_LEVEL_WARN",
"LOG_LEVEL_INFO",
"LOG_LEVEL_DEBUG"
],
"x-order": 11
},
"max_query_length": {
Expand Down Expand Up @@ -1623,8 +1633,18 @@
"x-order": 10
},
"log_level": {
"description": "Log level for exporter.",
"description": "- LOG_LEVEL_UNSPECIFIED: Auto",
"type": "string",
"title": "Log level for exporters",
"default": "LOG_LEVEL_UNSPECIFIED",
"enum": [
"LOG_LEVEL_UNSPECIFIED",
"LOG_LEVEL_FATAL",
"LOG_LEVEL_ERROR",
"LOG_LEVEL_WARN",
"LOG_LEVEL_INFO",
"LOG_LEVEL_DEBUG"
],
"x-order": 11
},
"max_query_length": {
Expand Down
Loading

0 comments on commit 614c85d

Please sign in to comment.