tyk
tyk copied to clipboard
master branch not up to date with tag 4.0.0
Why master is not the most actual version of service? Tag v4.0.0 is totally different. I made a fork to provide support for opentelemetry but I'm confusing which source is the right place.
Hi! It is the latest version, thats why you see such difference :)
While we released 4.0.0, we alredy working on 4.1 and 5.0, and our master is our latest code.
The PR should be raised on top of the master, and we will cherry-pick it to the needed releases when time will come.
Hope it makes sense!
PS. Can't wait to see your contribution, we wanted this feature for a long time.
@beng90 all clear so far? Do you need any help?
Yes, it's clear. I've done integration with opentelemetry but in private repository outside github. I plan to move it to fork in github but right now I don't know when.
Can you tell me one thing, how to build new docker image from code without building new tag and releasing it by goreleaser? I wanted to test my code in k8s but there was a problem to easily build new simple image.
hi @beng90 ! I have seen you have been working on OpenTelemetry support in the past, is this a topic that is still interesting to you? We are also starting to ramp up on OpenTelemetry, any thoughts or inputs you have would be very valuable for us.
I have created a post in our community to discuss: https://community.tyk.io/t/faq-opentelemetry-distributed-tracing/5682, feel free to join the conversation.
thanks! Sonja
It is still interesting but I had to implement it in my own by modifying core code. Apart from this I had to add custom authorization middleware because go plugin are very cumbersome.
But of course I would pull official solution from master and compare it with mine.
I can share with you part of my code to create spans.
` func (o *otelTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span { var otelOpts []trace.SpanStartOption var spanOptions []attribute.KeyValue var spContext spanContext var hasParent bool
var req *http.Request
var err error
if len(opts) > 0 {
var os opentracing.StartSpanOptions
for _, opt := range opts {
opt.Apply(&os)
}
if len(os.Tags) > 0 {
req, err = http.NewRequest(fmt.Sprint(os.Tags["method"]), fmt.Sprint(os.Tags["raw_url"]), nil)
if err != nil {
log.Error(err)
}
req.RequestURI = req.URL.String()
req.URL, err = url.Parse(fmt.Sprint(os.Tags["raw_url"]))
if err != nil {
log.Error(err)
}
req.Header.Add(headers.XForwardFor, fmt.Sprint(os.Tags["from_ip"]))
if reqHeaders, _ := os.Tags["headers"]; reqHeaders != nil {
for k, v := range reqHeaders.(http.Header) {
hVal := v[0]
// anonymize Authorization header
if k == headers.Authorization {
hVal = maskRight(hVal, 10)
}
spanOptions = append(spanOptions, attribute.String("http.request.headers."+k, hVal))
}
}
// extract span kind
kind := os.Tags[string(ext.SpanKind)]
if kind != nil {
o.mapKind(kind.(ext.SpanKindEnum), &otelOpts)
} else {
o.mapKind("", &otelOpts)
}
}
for _, ref := range os.References {
switch ref.Type {
case opentracing.ChildOfRef:
sp := ref.ReferencedContext.(spanContext)
spContext = sp
hasParent = true
}
}
}
ctx := trace.ContextWithSpanContext(context.Background(), spContext.SpanContext)
if hasParent {
spanOptions = append(spanOptions, semconv.HTTPClientAttributesFromHTTPRequest(req)...)
} else {
spanOptions = append(spanOptions, semconv.HTTPServerAttributesFromHTTPRequest("", req.RequestURI, req)...)
}
_, span := o.tracer.Start(ctx, operationName, otelOpts...)
span.SetAttributes(spanOptions...)
return Span{tr: o, span: span}
} `
thanks for the feedback and the update!
I'm curious, which observability tools are sending the traces to? Also what was the main driver for you to do it (for debugging, for monitoring, ...)?
Open telemetry. For monitoring purposes.