1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-26 03:52:03 +02:00

Use standard HTTP attributes in httptrace.Extract()

This commit is contained in:
Anthony J Mirabella 2020-05-26 21:59:30 -04:00
parent a6f6d402a2
commit 31096d4ebc

View File

@ -22,6 +22,7 @@ import (
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/kv"
"go.opentelemetry.io/otel/api/propagation"
"go.opentelemetry.io/otel/api/standard"
"go.opentelemetry.io/otel/api/trace"
)
@ -34,10 +35,10 @@ var (
func Extract(ctx context.Context, req *http.Request) ([]kv.KeyValue, []kv.KeyValue, trace.SpanContext) {
ctx = propagation.ExtractHTTP(ctx, global.Propagators(), req.Header)
attrs := []kv.KeyValue{
URLKey.String(req.URL.String()),
// Etc.
}
attrs := append(
standard.HTTPServerAttributesFromHTTPRequest("", "", req),
standard.NetAttributesFromHTTPRequest("tcp", req)...,
)
var correlationCtxKVs []kv.KeyValue
correlation.MapFromContext(ctx).Foreach(func(kv kv.KeyValue) bool {