GithubHelp home page GithubHelp logo

Comments (10)

mmatczuk avatar mmatczuk commented on May 29, 2024

Goproxy uses session ctx.Session & 0xFF as identifier we should probably adapt it

func (ctx *ProxyCtx) printf(msg string, argv ...interface{}) {
	ctx.Proxy.Logger.Printf("[%03d] "+msg+"\n", append([]interface{}{ctx.Session & 0xFF}, argv...)...)
}

example output

2022/09/26 14:01:10 [local] DEBUG: [001] INFO: Copying response to client 200 OK [200]
2022/09/26 14:01:10 [local] DEBUG: [001] INFO: Copied 4 bytes to client error=<nil>

If X-Request-ID is present it should be logged to associate the ID with Session ID.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

There are exported logging functions

// Logf prints a message to the proxy's log. Should be used in a ProxyHttpServer's filter
// This message will be printed only if the Verbose field of the ProxyHttpServer is set to true
//
//	proxy.OnRequest().DoFunc(func(r *http.Request,ctx *goproxy.ProxyCtx) (*http.Request, *http.Response){
//		nr := atomic.AddInt32(&counter,1)
//		ctx.Printf("So far %d requests",nr)
//		return r, nil
//	})
func (ctx *ProxyCtx) Logf(msg string, argv ...interface{}) {
	if ctx.Proxy.Verbose {
		ctx.printf("INFO: "+msg, argv...)
	}
}

// Warnf prints a message to the proxy's log. Should be used in a ProxyHttpServer's filter
// This message will always be printed.
//
//	proxy.OnRequest().DoFunc(func(r *http.Request,ctx *goproxy.ProxyCtx) (*http.Request, *http.Response){
//		f,err := os.OpenFile(cachedContent)
//		if err != nil {
//			ctx.Warnf("error open file %v: %v",cachedContent,err)
//			return r, nil
//		}
//		return r, nil
//	})
func (ctx *ProxyCtx) Warnf(msg string, argv ...interface{}) {
	ctx.printf("WARN: "+msg, argv...)
}

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

I think its not needed since we log request with response.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

Reopening the issue.
This mainly requires changes in Marian logging, when sth goes wrong, we want to know which issue caused the error.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

Once we have the context the in the logs the implementation should be in Proxy::readRequest (and a parallel implementation in handler).

To request context.Context add requestID value

  • if X-Request-ID header is set use its value
  • otherwise use Martian context ID

from forwarder.

Choraden avatar Choraden commented on May 29, 2024

As long as CONNECT request does not forward X-Forwarded-Headers we are not able to support reusing request id.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

@Choraden we have RequestIDHeader in martian and as far as I can tell it's never used.

from forwarder.

Choraden avatar Choraden commented on May 29, 2024

It looks like this functionality was removed in 56352ab.

We need to decide whether we want to fix it or completely remove it.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

I'll fix it.

from forwarder.

mmatczuk avatar mmatczuk commented on May 29, 2024

It can be added to out connect implementation.

from forwarder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.