diff options
author | 2023-02-17 12:02:29 +0100 | |
---|---|---|
committer | 2023-02-17 12:02:29 +0100 | |
commit | 68e6d08c768b789987a753d42f66caf73ce10ee1 (patch) | |
tree | 1c9eb6da6c326266d653de80684c3aec58922638 /internal/timeline/index.go | |
parent | [bugfix] Set 'discoverable' properly on API accounts (#1511) (diff) | |
download | gotosocial-68e6d08c768b789987a753d42f66caf73ce10ee1.tar.xz |
[feature] Add a request ID and include it in logs (#1476)
This adds a lightweight form of tracing to GTS. Each incoming request is
assigned a Request ID which we then pass on and log in all our log
lines. Any function that gets called downstream from an HTTP handler
should now emit a requestID=value pair whenever it logs something.
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/timeline/index.go')
-rw-r--r-- | internal/timeline/index.go | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/internal/timeline/index.go b/internal/timeline/index.go index a85863f21..e7e0e17fe 100644 --- a/internal/timeline/index.go +++ b/internal/timeline/index.go @@ -35,58 +35,9 @@ func (t *timeline) ItemIndexLength(ctx context.Context) int { return t.indexedItems.data.Len() } -// func (t *timeline) indexBefore(ctx context.Context, itemID string, amount int) error { -// l := log.WithFields(kv.Fields{{"amount", amount}}...) - -// // lazily initialize index if it hasn't been done already -// if t.indexedItems.data == nil { -// t.indexedItems.data = &list.List{} -// t.indexedItems.data.Init() -// } - -// toIndex := []Timelineable{} -// offsetID := itemID - -// l.Trace("entering grabloop") -// grabloop: -// for i := 0; len(toIndex) < amount && i < 5; i++ { // try the grabloop 5 times only -// // first grab items using the caller-provided grab function -// l.Trace("grabbing...") -// items, stop, err := t.grabFunction(ctx, t.accountID, "", "", offsetID, amount) -// if err != nil { -// return err -// } -// if stop { -// break grabloop -// } - -// l.Trace("filtering...") -// // now filter each item using the caller-provided filter function -// for _, item := range items { -// shouldIndex, err := t.filterFunction(ctx, t.accountID, item) -// if err != nil { -// return err -// } -// if shouldIndex { -// toIndex = append(toIndex, item) -// } -// offsetID = item.GetID() -// } -// } -// l.Trace("left grabloop") - -// // index the items we got -// for _, s := range toIndex { -// if _, err := t.IndexOne(ctx, s.GetID(), s.GetBoostOfID(), s.GetAccountID(), s.GetBoostOfAccountID()); err != nil { -// return fmt.Errorf("indexBefore: error indexing item with id %s: %s", s.GetID(), err) -// } -// } - -// return nil -// } - func (t *timeline) indexBehind(ctx context.Context, itemID string, amount int) error { - l := log.WithFields(kv.Fields{{"amount", amount}}...) + l := log.WithContext(ctx). + WithFields(kv.Fields{{"amount", amount}}...) // lazily initialize index if it hasn't been done already if t.indexedItems.data == nil { |