-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat(csharp/src/Apache.Arrow.Adbc): add OpenTelemetry compatible tracing support #2388
Draft
birschick-bq
wants to merge
86
commits into
apache:main
Choose a base branch
from
birschick-bq:dev/birschick-bq/tracing-base-library
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat(csharp/src/Apache.Arrow.Adbc): add OpenTelemetry compatible tracing support #2388
birschick-bq
wants to merge
86
commits into
apache:main
from
birschick-bq:dev/birschick-bq/tracing-base-library
+2,188
−74
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
…ort for AdbcConnection11 and AdbcStatement11
birschick-bq
requested review from
lidavidm and
CurtHagenlocher
as code owners
December 20, 2024 20:03
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds OpenTelemetry-compatible tracing support on the CSharp library.
Under the hood it uses
Activity
andActivitySource
from the netSystem.Diagnostics.DiagnosticSource
package.All the pertinent Adbc* classes now inherit from the
TracingBase
class.To instrument tracing, use one of the following overrides of
TraceActivity
TraceActivityAsync
Example:
Each of these overrides creates a new
Activity
which will be non-null only if there is an activeActivityListener
or OpenTelemetry exporter. TheActivity
is passed to the delegate Func/Action in case it need to addActivityEvent
,ActivityLink
orTags
(KeyValuePair
). When instrumenting tracing, you should always use the null-conditional operator (?.
) when accessing members on the passed delegate parameter,activity
.Example:
The default behavior is to invoke the delegate and if successful (i.e., no exception thrown), the
Activity.SetStatus
is set toOk
. If an exception is observed, then theActivity.SetStatus
is set toError
and the exception is traced (Activity.AddException
) as an event in the currentActivity
.Callers can pass a
traceparent
string to any of the TraceActivity[Async] methods using the optionaltraceParent
parameter, or to the inherited classes using theTraceParent
property. The parameter takes precedence over the property. ThetraceId
from thetraceParent
parameter orTraceParent
property will be adopted as therootId
for all trace Activity on that call or object. IfTraceParent
is null (initial or set later), then theActivity
creates a newrootId
for the beginning of the initialActivity
in the stack.Example:
The PR also includes a
FileExporter
that inherits from the OpenTelemetry classBaseExporter<Activity>
.To enable the exporter, use the OpenTelemetry SDK as follows:
Ensure to
Dispose
theTracerProvider
when you no longer need to listen forActivity
messages.