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

chore: convert msg properties to string #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mihir20
Copy link
Contributor

@mihir20 mihir20 commented Dec 13, 2024

Description

function to convert msg properties to string

Linear Ticket

https://linear.app/rudderstack/issue/PIPE-1797/better-error-logging-for-ingestion-requests

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@@ -56,6 +56,11 @@ type MessageProperties struct {
EncryptionKeyID string `json:"encryptionKeyID,omitempty"` // optional
}

func (m MessageProperties) String() string {
return fmt.Sprintf("RequestType: %s, RoutingKey: %s, WorkspaceID: %s, SourceID: %s, ReceivedAt: %s, RequestIP: %s, DestinationID: %s, UserID: %s, SourceJobRunID: %s, SourceTaskRunID: %s, TraceID: %s, SourceType: %s, WebhookFailureReason: %s, Stage: %s, Compression: %s, Encryption: %s, EncryptionKeyID: %s",
Copy link
Collaborator

Choose a reason for hiding this comment

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

fmt.Sprintf uses reflection of course so we're just moving it from one place to another 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not have a method that returns a []logger.Field?

func (m MessageProperties) LoggerFields() []logger.Field {
    n := 0 // use exact number here
    fields := make([]logger.Field, 0, n)
    fields = append(fields, logger.NewStringField(m.RequestType))
    // ...
    return fields
}

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.

2 participants