Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenTracing Bridge] Support setting span kind tag after span is created #3953

Open
ChenX1993 opened this issue Mar 31, 2023 · 2 comments · May be fixed by #3997
Open

[OpenTracing Bridge] Support setting span kind tag after span is created #3953

ChenX1993 opened this issue Mar 31, 2023 · 2 comments · May be fixed by #3997
Labels
enhancement New feature or request

Comments

@ChenX1993
Copy link
Contributor

ChenX1993 commented Mar 31, 2023

Problem Statement

Currently in OT Bridge, it does nothing when setting span kind tag.

func (s *bridgeSpan) SetTag(key string, value interface{}) ot.Span {
switch key {
case string(otext.SpanKind):
// TODO: Should we ignore it?
case string(otext.Error):
if b, ok := value.(bool); ok && b {
s.otelSpan.SetStatus(codes.Error, "")
}
default:
s.otelSpan.SetAttributes(otTagToOTelAttr(key, value))
}
return s
}

This cause some problem because the middle layers of some framework set span kind tag after a span is created, and we don't have control on those framework. Hence the spans are missing the span kind tag.
e.g. YAPRC: https://github.com/yarpc/yarpc-go/blob/600cb49cc6331d8d15f65c058615a7649447efa7/api/transport/propagation.go#L67

span := c.Tracer.StartSpan(
		req.Procedure,
		opentracing.StartTime(c.StartTime),
		opentracing.ChildOf(parent),
		tags,
)
ext.PeerService.Set(span, req.Service)
ext.SpanKindRPCClient.Set(span)

Is there any strong reason not to set span kind tags?

Proposed Solution

Support setting span kind tag.

@ChenX1993 ChenX1993 added the enhancement New feature or request label Mar 31, 2023
@ChenX1993
Copy link
Contributor Author

Hi, can I pick this up if this request makes sense?

@AlexanderYastrebov
Copy link

The workaround when sources can be changed is to specify span kind tag on creation which works for both Open Tracing and Open Telemetry bridge spans:

opts := []ot.StartSpanOption{ot.Tags{
  "span.kind":       "client",
  // etc
}}
if parentSpan := ot.SpanFromContext(req.Context()); parentSpan != nil {
  opts = append(opts, ot.ChildOf(parentSpan.Context()))
}
span := tracer.StartSpan(spanName, opts...)

AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 24, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 24, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 24, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 26, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 26, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit to zalando/skipper that referenced this issue Apr 26, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

Note that this change removes non-standard "shedder" kind from spans created by `admissionControl` filter.
Use operation name "admission_control" to query its spans instead if needed.

For #2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
JanardhanSharma pushed a commit to JanardhanSharma/skipper that referenced this issue Apr 26, 2024
OpenTelemetry-OpenTracing bridge span kind can not be changed after creation,
see open-telemetry/opentelemetry-go#3953

The workaround is to specify span kind on creation which works for
both Open Tracing and Open Telemetry bridge spans.

Note that this change removes non-standard "shedder" kind from spans created by `admissionControl` filter.
Use operation name "admission_control" to query its spans instead if needed.

For zalando#2104

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Signed-off-by: Janardhan Sharma <janardhan.sharma@zalando.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants