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

Be more clear what dynamic ADA does #2586

Merged
merged 5 commits into from Oct 11, 2021
Merged

Be more clear what dynamic ADA does #2586

merged 5 commits into from Oct 11, 2021

Conversation

nakabonne
Copy link
Member

What this PR does / why we need it:
This PR improves the ADA stage log so that we can see how dynamic ADA works.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.76%. This pull request decreases coverage by -0.12%.

File Function Base Head Diff
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryBaseline 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryPrimary 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go compare 73.68% 78.95% +5.26%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithPrevious 0.00% 0.00% +0.00%

@@ -21,6 +21,8 @@ import (
"time"
)

const timeFormat = "2006-01-02 15:04:05 MST"
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why should we use MST instead of UTC?

Copy link
Member Author

Choose a reason for hiding this comment

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

well, this is just a format, so it actually shows it like:
image

Copy link
Member

Choose a reason for hiding this comment

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

Ok. So if we don't have any special reason, we should use UTC to be unified with other places such as the timestamp of the stage log message.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't even know that other timestamps in the stage log are in UTC. Let me do that.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.76%. This pull request decreases coverage by -0.12%.

File Function Base Head Diff
pkg/app/piped/executor/analysis/metrics_analyzer.go compare 73.68% 78.95% +5.26%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithPrevious 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryBaseline 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryPrimary 0.00% 0.00% +0.00%

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.76%. This pull request decreases coverage by -0.12%.

File Function Base Head Diff
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithPrevious 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryBaseline 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryPrimary 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go compare 73.68% 78.95% +5.26%

@nakabonne
Copy link
Member Author

PTAL when you guys have time 😄

@@ -39,7 +41,8 @@ type DataPoint struct {
}

func (d *DataPoint) String() string {
return fmt.Sprintf("timestamp: %q, value: %g", time.Unix(d.Timestamp, 0), d.Value)
// Timestamp is shown in UTC.
return fmt.Sprintf("timestamp: %q, value: %g", time.Unix(d.Timestamp, 0).In(time.UTC).Format(timeFormat), d.Value)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("timestamp: %q, value: %g", time.Unix(d.Timestamp, 0).In(time.UTC).Format(timeFormat), d.Value)
return fmt.Sprintf("timestamp: %q, value: %g", time.Unix(d.Timestamp, 0).UTC(), d.Value)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you. Actuallly without the format, it gets a bit difficult to read.

package main

import (
	"fmt"
	"time"
)

func main() {
	timeFormat := "2006-01-02 15:04:05 MST"
	var timestamp int64 = 1600000000
	fmt.Println(time.Unix(timestamp, 0).In(time.UTC).Format(timeFormat))
	// 2020-09-13 12:26:40 UTC
	fmt.Println(time.Unix(timestamp, 0).UTC())
	// 2020-09-13 12:26:40 +0000 UTC
	fmt.Println(time.Unix(timestamp, 0).UTC().Format(timeFormat))
	// 2020-09-13 12:26:40 UTC
}

But it's better to use .UTC(), instead of In(time.UTC), so let me apply it!

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -50,6 +53,11 @@ type QueryRange struct {
To time.Time
}

func (q *QueryRange) String() string {
// Timestamps are shown in UTC.
return fmt.Sprintf("from: %q, to: %q", q.From.In(time.UTC).Format(timeFormat), q.To.In(time.UTC).Format(timeFormat))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("from: %q, to: %q", q.From.In(time.UTC).Format(timeFormat), q.To.In(time.UTC).Format(timeFormat))
return fmt.Sprintf("from: %q, to: %q", q.From.UTC(), q.To.UTC())

@nakabonne
Copy link
Member Author

Fixed! PTAL

@nghialv
Copy link
Member

nghialv commented Oct 11, 2021

/lgtm

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 31.76%. This pull request decreases coverage by -0.12%.

File Function Base Head Diff
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithPrevious 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryBaseline 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go metricsAnalyzer.analyzeWithCanaryPrimary 0.00% 0.00% +0.00%
pkg/app/piped/executor/analysis/metrics_analyzer.go compare 73.68% 78.95% +5.26%

@nakabonne
Copy link
Member Author

@khanhtc1202 PTAL :-)

@khanhtc1202
Copy link
Member

🚀
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit 7220b41 into master Oct 11, 2021
@pipecd-bot pipecd-bot deleted the improve-ada-log branch October 11, 2021 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants