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(teler): add listen_addr & caller fields in the log #194

Merged

Conversation

dwisiswant0
Copy link
Collaborator

@dwisiswant0 dwisiswant0 commented Jun 6, 2024

IMPORTANT: Please do not create a PR without creating an issue first!

(Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request).

Summary

feat(teler): add listen_addr & caller fields in the log

Proposed of changes

This PR fixes/implements the following bugs/features:

  • Bug 1
  • Bug 2
  • Feature 1
  • Feature 2
  • Breaking changes

How has this been tested?

Proof:

go1.19 test -v -race -count=1 -run=^TestNewWithLogFile$ ./...
cat /tmp/teler-test.log | jq
{
  "level": "warn",
  "ts": 1717703738.552389,
  "msg": "bad crawler",
  "id": "0c1de9f7aff7f6be51c5",
  "category": "BadCrawler",
  "caller": "teler-waf",
  "listen_addr": "*********:36267",
  "request": {
    "method": "GET",
    "path": "/",
    "ip_addr": "*********",
    "headers": {
      "Accept-Encoding": [
        "gzip"
      ],
      "User-Agent": [
        "Go-http-client/1.1"
      ]
    },
    "body": ""
  }
}

Closing issues

Fixes #

Checklist:

  • My code follows the code style of this project.
  • My changes successfully ran and pass linters locally (run make lint).
  • I have written new tests for my changes.
    • My changes successfully ran and pass tests locally.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.

@github-actions github-actions bot force-pushed the dwisiswant0/feat/add-listen-addr-caller-fields-in-the-log branch from e63f546 to 7ef72b6 Compare June 6, 2024 14:15
@dwisiswant0
Copy link
Collaborator Author

dwisiswant0 commented Jun 6, 2024

decisions:

  1. why do I go with caching when calling getListenAddr? well after putting it through some benchmarking, I saw it was doing 3 allocs per op w/o any caching. fetching local addresses was turning out to be a bit of a performance hog, so i figured caching would smooth (cut down that overhead) things out and make everything run way more efficiently.
  2. since it (d34ca96) required by (1), refactoring to initialize (root) cache no matter what the Options.Development value does NOT really have any downsides. :shrug:

@dwisiswant0 dwisiswant0 force-pushed the dwisiswant0/feat/add-listen-addr-caller-fields-in-the-log branch from aa1c957 to 48c2ac9 Compare June 6, 2024 19:55
@dwisiswant0 dwisiswant0 force-pushed the dwisiswant0/feat/add-listen-addr-caller-fields-in-the-log branch from 48c2ac9 to 18f804e Compare June 6, 2024 19:59
@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.64%. Comparing base (20b5e7c) to head (18f804e).
Report is 5 commits behind head on master.

Files Patch % Lines
utils.go 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
+ Coverage   78.47%   78.64%   +0.16%     
==========================================
  Files          12       12              
  Lines         920      932      +12     
==========================================
+ Hits          722      733      +11     
- Misses        131      132       +1     
  Partials       67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dwisiswant0 dwisiswant0 merged commit 6fba6c1 into master Jun 6, 2024
10 checks passed
@dwisiswant0 dwisiswant0 deleted the dwisiswant0/feat/add-listen-addr-caller-fields-in-the-log branch June 6, 2024 20:23
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