# Request Tracker

Request Tracker is a small library for managing context between services. For example, setting and retrieving important metadata shared between services, such as user ID's, request ID's, and other important information.

The request tracker wraps around a logger instance, so that you don't have to keep setting the request ID/user ID etc everywhere they're needed. Set it once and forget about it!

## Usage

```go
package main

import requestTracker "github.com/pingponglabs/mediamagic-platform/libs/request-tracker"

func main() {
	rt := requestTracker.NewLogger()
	logger := rt.WithUserID("abc123").WithRequestID("xyz789").GetLogger()
}

```

Example from context

```go
package main

import (
	"context"
	"log"
	
	requestTracker "github.com/pingponglabs/mediamagic-platform/libs/request-tracker"
)

type service struct {}

func (s *service) handler(ctx context.Context, _ *pb.Request) (*pb.Response, error) {
	rt := requestTracker.NewLogger()
	logger := rt.WithRequestIDFromContext(ctx).WithUserIDFromContext(ctx).GetLogger()
	logger.Info("Hello world!")
	return nil, nil
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mediamagic.dev/product-docs/libs/request-tracker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
