This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an extension to Tracer interface for custom go context creation (#…
…220) * Add an extension interface for Tracer implementations The new TracerContextWithSpanExtension interface provides a way to hook into the ContextWithSpan function, so the implementation can put some extra information to the context. The opentracing to opentelemetry bridge needs the context to set the current opentelemetry span, so the opentelemetry API in the layer below the one using opentracing can still get the right parent span. * Call the hook in the ContextWithSpan function if possible So the implementation can still affect the way the go context is set up. * Add a test for the TracerContextWithSpanExtension interface
- Loading branch information
1 parent
94e0bdd
commit 16ba2b6
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package opentracing | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// TracerContextWithSpanExtension is an extension interface that the | ||
// implementation of the Tracer interface may want to implement. It | ||
// allows to have some control over the go context when the | ||
// ContextWithSpan is invoked. | ||
// | ||
// The primary purpose of this extension are adapters from opentracing | ||
// API to some other tracing API. | ||
type TracerContextWithSpanExtension interface { | ||
// ContextWithSpanHook gets called by the ContextWithSpan | ||
// function, when the Tracer implementation also implements | ||
// this interface. It allows to put extra information into the | ||
// context and make it available to the callers of the | ||
// ContextWithSpan. | ||
// | ||
// This hook is invoked before the ContextWithSpan function | ||
// actually puts the span into the context. | ||
ContextWithSpanHook(ctx context.Context, span Span) context.Context | ||
} |
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
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