-
Notifications
You must be signed in to change notification settings - Fork 0
set TargetProcessingTime to -1 #62
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"strings" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestLogFileReader_Read(t *testing.T) { | ||
var pathRules []PathTransformingRule | ||
targetPaths := []string{"/"} | ||
logFileReader := NewLogFileReader(pathRules, targetPaths) | ||
|
||
logTimeString := "2022-06-13T00:26:00.071316Z" | ||
logTime, err := time.Parse(time.RFC3339, "2022-06-13T00:26:00.071316Z") | ||
if err != nil { | ||
fmt.Printf("failed to parse %s: %s", logTimeString, err.Error()) | ||
} | ||
|
||
cases := []struct { | ||
log string | ||
wantTargetProcessingTimesMap map[Timestamp]TargetProcessingTimes | ||
wantTargetRequestCountMap map[Timestamp]RequestCount | ||
}{ | ||
{ | ||
log: fmt.Sprintf(`https %s app/my-loadbalancer/50dc6c495c0c9188 192.168.131.39:2817 10.0.0.1:80 0.086 0.048 0.037 200 200 0 57 "GET https://www.example.com:443/ HTTP/1.1" "curl/7.46.0" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067 "Root=1-58337281-1d84f3d73c47ec4e58577259" "www.example.com" "arn:aws:acm:us-east-2:123456789012:certificate/12345678-1234-1234-1234-123456789012" 1 2018-07-02T22:22:48.364000Z "authenticate,forward" "-" "-" "10.0.0.1:80" "200" "-" "-"`, logTimeString), | ||
wantTargetProcessingTimesMap: map[Timestamp]TargetProcessingTimes{ | ||
Timestamp(logTime.Unix()): {0.048}, | ||
}, | ||
wantTargetRequestCountMap: map[Timestamp]RequestCount{ | ||
Timestamp(logTime.Unix()): 1, | ||
}, | ||
}, | ||
{ | ||
log: fmt.Sprintf(`https %s app/my-loadbalancer/50dc6c495c0c9188 192.168.131.39:2817 - -1 -1 -1 400 - 235 772 "GET https://www.example.com:443/ HTTP/1.1" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36" - - - "-" "-" "-" - 2022-06-13T00:25:59.856000Z "-" "-" "-" "-" "-" "-" "-"`, logTimeString), | ||
wantTargetProcessingTimesMap: map[Timestamp]TargetProcessingTimes{ | ||
Timestamp(logTime.Unix()): {-1}, | ||
}, | ||
wantTargetRequestCountMap: map[Timestamp]RequestCount{ | ||
Timestamp(logTime.Unix()): 1, | ||
}, | ||
}, | ||
} | ||
for _, tt := range cases { | ||
metricMap, err := logFileReader.Read( | ||
strings.NewReader(tt.log), | ||
) | ||
if err != nil { | ||
t.Fatalf("failed to read the log: %v\n%s", err, tt.log) | ||
} | ||
if len(metricMap) != 1 { | ||
t.Errorf("expected 1 metric, got %d", len(metricMap)) | ||
} | ||
|
||
for _, metric := range metricMap { | ||
if reflect.DeepEqual(metric.TargetProcessingTimesMap, tt.wantTargetProcessingTimesMap) == false { | ||
t.Errorf("unexpected got %v, want, %v", metric.TargetProcessingTimesMap, tt.wantTargetProcessingTimesMap) | ||
} | ||
if reflect.DeepEqual(metric.RequestCountMap, tt.wantTargetRequestCountMap) == false { | ||
t.Errorf("unexpected got %v, want, %v", metric.RequestCountMap, tt.wantTargetRequestCountMap) | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding or updating a comment here to clarify that a TargetProcessingTime of -1 is intentional and valid, indicating that the target did not respond.
Copilot uses AI. Check for mistakes.