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

[AT-40][Add] Preliminary Logging CorrelationID #95

Merged
merged 7 commits into from
Jul 13, 2020
Merged

Conversation

martinstibbe
Copy link
Contributor

No description provided.

edgegrid/log.go Outdated
log "github.com/sirupsen/logrus"
)

var logBuffer *bufio.Writer
var LogFile *os.File
var EdgegridLog *log.Logger

// LogCorrelationID ID for header and footer of log file outputs
var LogCorrelationID *string
Copy link
Contributor

Choose a reason for hiding this comment

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

Shared variable will have trouble with concurrent calls.

Choose a reason for hiding this comment

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

The same comments made in the provider AT-40 pull request apply here: I think the library should also be following a similar [level][api][guid] format. I would expect the common logging functions to be placed in the library itself and utilized in the provider.

}
b, err := httputil.DumpRequestOut(req, body)
if err == nil {
LogMultiline(EdgegridLog.Traceln, string(b))
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this logging the same request two different ways? One as a single line out and another per line of the output? I like logging the request as a single action but am unable to grok why we still need it the old way as well. Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I can remove these that was initial testing of wrapped logs I broke it out to separate function to allow incremental migration once correlation concept catches on

@edglynes
Copy link
Member

edglynes commented Jul 7, 2020

We don't need both. It won't hurt to always have a correlation ID. There is additional work to be done if the logic is simplified. All existing references will need to be tweaked including GTM and DNS. Since this is a library, we either need to require a correlation id, generate one if none provided or handle cases with and without.

@zstlaw
Copy link
Contributor

zstlaw commented Jul 13, 2020

Looks like some of my comments did not post from last week. I didn't see any more glaring issues but I wasn't sure why some of the service calls pass empty log correlation ids.

Copy link
Contributor

@zstlaw zstlaw left a comment

Choose a reason for hiding this comment

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

Looks like my comments were not "submitted" submitting comments with tentative approval.

}
b, err := httputil.DumpRequestOut(req, body)
if err == nil {
LogMultiline(EdgegridLog.Traceln, string(b))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above on PrintHtpRequest applies here. Also is the old endpoint for backwards compatibility and direct usage only? If so something like a deprecation warning should be added in the comments on the old function so users know to use the newer format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I can remove these that was initial testing of wrapped logs I broke it out to separate function to allow incremental migration once correlation concept catches on

@@ -15,7 +15,7 @@ var (
// GetGroups retrieves all groups
func GetGroups() (*Groups, error) {
groups := NewGroups()
if err := groups.GetGroups(); err != nil {
if err := groups.GetGroups(""); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these blank service calls, arent they problematic? Shouldn't they initialize a guid for sub-requests. I feel like i must be missing something here.

@martinstibbe martinstibbe merged commit 77bd4a2 into master Jul 13, 2020
@zstlaw zstlaw deleted the AT-40 branch October 15, 2020 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants