-
Notifications
You must be signed in to change notification settings - Fork 524
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
Add support for span links #7291
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axw
added
backport-skip
Skip notification from the automated backport with mergify
v8.2.0
labels
Feb 15, 2022
marclop
approved these changes
Feb 16, 2022
felixbarny
approved these changes
Feb 16, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and easy to expand with span link attributes/labels later on.
confirmed with 4575383
package main
import (
"context"
"log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/propagation"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
)
var tracer = otel.Tracer("tracer")
func main() {
tp := initTracer()
defer func() {
if err := tp.Shutdown(context.Background()); err != nil {
log.Printf("Error shutting down tracer provider: %v", err)
}
}()
ctx, span := tracer.Start(context.Background(), "span")
defer span.End()
link := trace.LinkFromContext(ctx, attribute.Int("attr", 1))
_, span2 := tracer.Start(ctx, "linkedSpan", trace.WithLinks(link))
defer span2.End()
}
func initTracer() *sdktrace.TracerProvider {
ctx := context.Background()
// Create the OTLP exporter that
// will receive the telemetry data
endpoint := "localhost:8200"
exporter, err := otlptracegrpc.New(ctx,
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint(endpoint),
)
if err != nil {
log.Fatal(err)
}
tp := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exporter),
)
otel.SetTracerProvider(tp)
otel.SetTextMapPropagator(
propagation.NewCompositeTextMapPropagator(
propagation.TraceContext{},
propagation.Baggage{},
),
)
return tp
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport-skip
Skip notification from the automated backport with mergify
test-plan
test-plan-ok
v8.2.0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation/summary
This PR adds support for span links to our data model, enabling a span/transaction to be associated with zero or more other spans/transactions. We use
span.links
andspan.links.span.id
regardless of whether the linked entities are spans or transactions.The PR also adds support for capturing OpenTelemetry span links.
Checklist
apmpackage
have been made)- [ ] Documentation has been updatedHow to test these changes
traces-apm*
and querying byspan.links.trace.id
Related issues
Closes #7171