English 中文(简体)
• 如何在使用戈兰的分布式追踪系统中创造长 tree树
原标题:How to create span tree in distributed tracing system using Golang

I already have a microservice and I want to apply distributed tracing for it. I have written the following code to create a tracing span using jaeger and opentracing , but my problem is that it does not create parrent id and I am not able to see the span graph. It seems it only shows the default operations in UI dashboard. I used docker-compose for config jaeger.

 jaeger:
  container_name: jaeger
  image: jaegertracing/all-in-one:1.39
  restart: always
  ports:
    - 5775:5775/udp
    - 6831:6831/udp
    - 6832:6832/udp
    - 5778:5778
    - 16686:16686
    - 14268:14268
    - 9411:9411
    
  environment:
    - COLLECTOR_OTLP_ENABLED=true
    - OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:16686"
    - COLLECTOR_ZIPKIN_HTTP_PORT=9411
    - JAEGER_SERVICE_NAME=baran-endpoint
    - JAEGER_AGENT_HOST=jaeger
    - JAEGER_REPORTER_LOG_SPANS=true
    - JAEGER_SAMPLER_TYPE=const
    - JAEGER_SAMPLER_PARAM=1
    - JAEGER_SAMPLER_SERVER_URL=
  networks:
    - network-jaeger

I tried to implement a basic architecture in jaeger component,but it seems that i m missing somthing in between. enter image description here

var (
  TracingAnalysisEndpoint      = "http://localhost:26855/SaleService.svc"
)
const AgentSwitch = false

func NewJaegerTracer(service string) opentracing.Tracer {
    if AgentSwitch == true {
        return NewJaegerTracerAgent(service)
    }
    return NewJaegerTracerDirect(service)
}

func NewJaegerTracerDirect(service string) opentracing.Tracer {
    sender := transport.NewHTTPTransport(
        TracingAnalysisEndpoint,
    )
    tracer, _ := jaeger.NewTracer(service,
        jaeger.NewConstSampler(true),
        jaeger.NewRemoteReporter(sender, jaeger.ReporterOptions.Logger(jaeger.StdLogger)),
    )
    return tracer
}

func NewJaegerTracerAgent(service string) opentracing.Tracer {
    sender, _ := jaeger.NewUDPTransport("",0)
    tracer, _ := jaeger.NewTracer(service,
        jaeger.NewConstSampler(true),
        jaeger.NewRemoteReporter(sender, jaeger.ReporterOptions.Logger(jaeger.StdLogger)),
    )
    return tracer
}

func StartSpanFromRequest(tracer opentracing.Tracer, r *http.Request, funcDesc string) opentracing.Span {
 spanCtx, _ := Extract(tracer, r)
 return tracer.StartSpan(funcDesc, ext.RPCServerOption(spanCtx))
}

func Inject(span opentracing.Span, request *http.Request) error {
 return span.Tracer().Inject(
  span.Context(),
  opentracing.HTTPHeaders,
  opentracing.HTTPHeadersCarrier(request.Header))
}

func Extract(tracer opentracing.Tracer, r *http.Request) (opentracing.SpanContext, error) {
 return tracer.Extract(
  opentracing.HTTPHeaders,
  opentracing.HTTPHeadersCarrier(r.Header))
}

I created first span on one of my services.

  span:= config.StartSpanFromRequest(config.Tracer,ctx.Request(), "customer method")
  defer span.Finish()   
  span.LogKV(fmt.Sprintf("Customer not found: %s", request.Mobile))

It only shows the default operations in UI dashboard. enter image description here

我无法准确地确定父母和子女之间的界限。

“在座的影像描述”/</a

我想按等级划分。

问题回答




相关问题
minimum work size of a goroutine [closed]

Does anyone know approximately what the minimum work size is needed in order for a goroutine to be beneficial (assuming that there are free cores for the work to be offloaded to)?

How do you get the terminal size in Go?

How do I get the terminal size in Go. In C it would look like this: struct ttysize ts; ioctl(0, TIOCGWINSZ, &ts); But how to i access TIOCGWINSZ in Go

What do you use to write Go [closed]

I know its a bit too early, but I ve been trying out Go (Google s Programming Language) and its kindof annoying to write code in gedit. So, my question: What do you use to experiment with Go?

Shared memory vs. Go channel communication

One of Go s slogans is Do not communicate by sharing memory; instead, share memory by communicating. I am wondering whether Go allows two different Go-compiled binaries running on the same machine to ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

热门标签