From d0f4e1db59ed9f04d820b72162ccad0ddaea2a82 Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Thu, 19 Oct 2023 07:12:07 +0800 Subject: [PATCH] docs: Fix Go distributed tracing example (#11854) * docs: Fix Go distributed tracing example * Link to go agent v2 docs --------- Co-authored-by: Brandon Morelli (cherry picked from commit 7e4babf9b4ed09f3d7a10333343bfec9ca8c0828) # Conflicts: # docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc Signed-off-by: Carson Ip --- .../distributed-trace-receive.asciidoc | 8 +++++++- .../distributed-trace-send.asciidoc | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc b/docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc index 6487d9379ce..776ffacbefb 100644 --- a/docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc +++ b/docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc @@ -2,9 +2,15 @@ // Need help with this example +<<<<<<< HEAD:docs/shared/distributed-trace-receive/distributed-trace-receive.asciidoc 1. Parse the incoming TraceContext with https://godoc.org/go.elastic.co/apm/module/apmhttp#ParseTraceparentHeader[`ParseTraceparentHeader`] or https://godoc.org/go.elastic.co/apm/module/apmhttp#ParseTracestateHeader[`ParseTracestateHeader`]. +======= +1. Parse the incoming `TraceContext` with +https://pkg.go.dev/go.elastic.co/apm/module/apmhttp/v2#ParseTraceparentHeader[`ParseTraceparentHeader`] or +https://pkg.go.dev/go.elastic.co/apm/module/apmhttp/v2#ParseTracestateHeader[`ParseTracestateHeader`]. +>>>>>>> 7e4babf9b (docs: Fix Go distributed tracing example (#11854)):docs/tab-widgets/distributed-trace-receive.asciidoc 2. Start a new transaction or span as a child of the incoming transaction with {apm-go-ref}/api.html#tracer-api-start-transaction-options[`StartTransactionOptions`] or @@ -21,7 +27,7 @@ traceContext.State, _ = apmhttp.ParseTracestateHeader(r.Header["Tracestate"]...) opts := apm.TransactionOptions{ TraceContext: traceContext, <3> } -transaction := apm.DefaultTracer.StartTransactionOptions("GET /", "request", opts) <4> +transaction := apm.DefaultTracer().StartTransactionOptions("GET /", "request", opts) <4> ---- <1> Parse the TraceParent header <2> Parse the tracestate header diff --git a/docs/shared/distributed-trace-send/distributed-trace-send.asciidoc b/docs/shared/distributed-trace-send/distributed-trace-send.asciidoc index 5d6c5580d8b..9534ed791cf 100644 --- a/docs/shared/distributed-trace-send/distributed-trace-send.asciidoc +++ b/docs/shared/distributed-trace-send/distributed-trace-send.asciidoc @@ -12,11 +12,11 @@ Example: [source,go] ---- -transaction := apm.DefaultTracer.StartTransaction("GET /", "request") <1> +transaction := apm.DefaultTracer().StartTransaction("GET /", "request") <1> traceContext := transaction.TraceContext() <2> // Send TraceContext to receiving service -traceparent := apmhttp.FormatTraceparentHeader(traceContext)) <3> +traceparent := apmhttp.FormatTraceparentHeader(traceContext) <3> tracestate := traceContext.State.String() ---- <1> Start a transaction