envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.97k stars 4.81k forks source link

Can add router info in the tracing ingress span name? #27871

Open JaredTan95 opened 1 year ago

JaredTan95 commented 1 year ago

Title: **

Description: for now, we have peer host info in the egress span, but the entry span name always ingress:

Resource SchemaURL:
Resource attributes:
     -> service.name: Str(front-envoy)
ScopeSpans #0
ScopeSpans SchemaURL:
InstrumentationScope
Span #0
    Trace ID       : 6d663d6fa9db17d015f70b8bfa17a16c
    Parent ID      :
    ID             : 347e1bda01c0f7d3
    Name           : egress localhost:10000 👈 👈 👈 👈
    Kind           : Client
    Start time     : 2023-06-08 08:55:49.751258 +0000 UTC
    End time       : 2023-06-08 08:55:49.760793 +0000 UTC
    Status code    : Unset
    Status message :
Attributes:
     -> node_id: Str()
     -> zone: Str()
     -> guid:x-request-id: Str(69c16189-92ed-9998-ab63-83e05c85c311)
     -> http.url: Str(http://localhost:10000/trace/1)
     -> http.method: Str(GET)
     -> downstream_cluster: Str(-)
     -> user_agent: Str(curl/7.79.1)
     -> http.protocol: Str(HTTP/1.1)
     -> peer.address: Str(172.19.0.1)
     -> request_size: Str(0)
     -> response_size: Str(37)
     -> component: Str(proxy)
     -> upstream_cluster: Str(envoy_cluster1)
     -> upstream_cluster.name: Str(envoy_cluster1)
     -> http.status_code: Str(200)
     -> response_flags: Str(-)
    {"kind": "exporter", "data_type": "traces", "name": "logging"}
2023-06-08T08:55:54.485Z    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "logging", "resource spans": 1, "spans": 1}
2023-06-08T08:55:54.485Z    info    ResourceSpans #0
Resource SchemaURL:
Resource attributes:
     -> service.name: Str(envoy-1)
ScopeSpans #0
ScopeSpans SchemaURL:
InstrumentationScope
Span #0
    Trace ID       : 6d663d6fa9db17d015f70b8bfa17a16c
    Parent ID      : 347e1bda01c0f7d3
    ID             : 09900acb5756692b
    Name           : ingress  👈 👈 👈 👈
    Kind           : Server
    Start time     : 2023-06-08 08:55:49.754524 +0000 UTC
    End time       : 2023-06-08 08:55:49.760467 +0000 UTC
    Status code    : Unset
    Status message :
ravenblackx commented 1 year ago

cc @wbpcode @Shikugawa (selected based on ownership in several tracer extensions)

wbpcode commented 1 year ago

yeah, I think this is a reasonable requirement.

Yuanguo-notebook commented 2 months ago

It seems we can use decorator in route to override default span name: https://github.com/envoyproxy/envoy/blob/1e8bacf69879165b9d67fe4f1d127950e0257d5a/source/common/http/conn_manager_impl.cc#L1446-L1452

operation (string, REQUIRED) The operation name associated with the request matched to this route. If tracing is enabled, this information will be used as the span name reported for this request.