Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update cabonapi to c2229eabd094 #1074

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Tetrergeru
Copy link
Member

@Tetrergeru Tetrergeru commented Aug 22, 2024

Обновил карбонапи, важные изменения:

  • Добавлена структура evaluator, которая реализует интерфейс эвалюатора из карбонапи
  • Удалены самостоятельные попытки предвариетнльно зарерайтить экспрешен внутри Мойры и вся логика вычислений передана в fetchAndEval из карбонапи
    • Получили поддержку некоторых функций, которые не поддерживались раньше (и ломали Мойру)
    • Будут возникать дополниетльные запросы в базу при использовании мувинг функций с указанием количества точек, а не временного диапазона

@Tetrergeru
Copy link
Member Author

/build

@Tetrergeru Tetrergeru marked this pull request as ready for review September 10, 2024 14:57
@Tetrergeru Tetrergeru requested a review from a team as a code owner September 10, 2024 14:57
@Tetrergeru
Copy link
Member Author

/build

Copy link

Build and push Docker images with tag: feature-update-cabonapi-to-c2229eabd094.2024-09-10.2e1a3e6

2 similar comments
Copy link

Build and push Docker images with tag: feature-update-cabonapi-to-c2229eabd094.2024-09-10.2e1a3e6

Copy link

Build and push Docker images with tag: feature-update-cabonapi-to-c2229eabd094.2024-09-10.2e1a3e6

Copy link
Member

@AleksandrMatsko AleksandrMatsko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надушниль

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправь пж godoc для IsAvailable

if err != nil {
return err
return merry.Unwrap(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эта штука deprecated. Заменим на что-нибудь другое?

}

// It returns a map of only the data requested in the current invocation, scaled to a common step.
func (eval *evaluator) Fetch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправишь godoc?


metrics := make([]string, 0)
metricsMap := make(map[parser.MetricRequest][]*types.MetricData)
func NewFetchCtx(from, until int64) *fetchCtx {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб сделать её приватной?

@@ -93,12 +155,24 @@ func (ctx *evalCtx) parse(target string) (parser.Expr, error) {
return parsedExpr, nil
}

func (ctx *evalCtx) getMetricsData(database moira.Database, parsedExpr parser.Expr) (*fetchedMetrics, error) {
metricRequests := parsedExpr.Metrics()
type fetchCtx struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб эту структуру и её методы в отдельный файл унесём?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправь, пожалуйста, godoc-и в этом файле.

@@ -9,7 +9,21 @@ type Timer struct {

// Rounds start and stop time in a specific manner requered by carbonapi.
func RoundTimestamps(startTime, stopTime, retention int64) (roundedStart, roundedStop int64) {
return ceilToMultiplier(startTime, retention), floorToMultiplier(stopTime, retention) + retention
// var until int64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не забудь убрать комменты)

until int64
type evaluator struct {
database moira.Database
metrics []string
Copy link
Member

@almostinf almostinf Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему решил добавить метрики внутрь этой структуры, а не возвращать из Fetch? Можно было бы использовать структуру fetchedMetrics, там как раз оба нужных поля есть

}

for _, metricData := range metricsData {
md := newMetricDataFromGraphit(metricData, len(result.Metrics) != len(result.Patterns))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newMetricDataFromGraphit -> newMetricDataFromGraphite

@@ -12,7 +12,8 @@ type MetricData struct {
StopTime int64
StepTime int64
Values []float64
Wildcard bool
// TODO(Tetrergeru) Wtf is a wildcard in this context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Судя по коду параметр определяет были ли вайлдкард в запросе, проверка на то равно ли количество паттерном количеству метрик

database.EXPECT().GetMetricsValues(metrics, int64(0), retentionUntil-1).Return(metricList, nil)
database.EXPECT().GetMetricsTTLSeconds().Return(metricsTTL)

result, err := localSource.Fetch("alias(movingMin(apps.*.process.cpu.usage, '20s'), 'min')", from, until, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень много тестов на функции, которые были изменены в ходе релиза. Как будто бы точно стоит покрыть тестами moving* функции с числовым и не числовым параметрами, hitcount, smartSummarize, keepLastValue и тд. Это точно будет не лишним, тк лучше будем понимать и видеть в тестах, какие функции изменились и как это может сказаться на уже существующих триггерах

@@ -15,7 +15,7 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-chi/render v1.0.1
github.com/go-graphite/carbonapi v0.16.0
github.com/go-graphite/carbonapi v0.16.2-0.20240530091606-c2229eabd094
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему на коммит еще?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я прост может забыла, давай просто где-нибудь напишем, чего мы так решили сделать)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants