-
Notifications
You must be signed in to change notification settings - Fork 129
feat(csharp/src/Apache.Arrow.Adbc): OpenTelemetry tracing baseline #2847
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
base: main
Are you sure you want to change the base?
feat(csharp/src/Apache.Arrow.Adbc): OpenTelemetry tracing baseline #2847
Conversation
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.
Thanks! I'm not done reviewing this yet but I've done about three hours of code reviews so far today and need a break... .
switch (key.ToLowerInvariant()) | ||
{ | ||
case AdbcOptions.Telemetry.TraceParent: | ||
TraceParent = string.IsNullOrEmpty(value) ? null : value; |
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.
Hmm... so I guess this is where the parent is set? And the scenario is that the caller opens a connection once but can set a new parent every time the execute a statement?
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.
It seems strange to allow the parent to be set independently for the connection and statement, and for these to have no relationship to each other. But maybe my mental model for the parent isn't right?
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.
So now, only allow the trace parent to be set on the Connection - either at construction or anytime after. Disallowing setting the trace parent on Statement.
@CurtHagenlocher - Removed the exporter components. I will create another PR to have exporter(s) as separate project/package. |
This PR adds OpenTelemetry-compatible tracing support on the CSharp library.
Under the hood it uses
Activity
andActivitySource
from the netSystem.Diagnostics.DiagnosticSource
package.Inherit from
TracingConnection
By default, the
activitySourceName
will be created from the driver assembly name.Then to instrument tracing, use one of the following overrides of
TraceActivity
TraceActivityAsync
Example:
Each of these overrides starts a new
Activity
which will be non-null only if there is an activeActivityListener
orOpenTelemetry
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. 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:
Identifiers used for events and tags should follow the OpenTelemetry semantic guidance ..
https://opentelemetry.io/docs/specs/semconv/database/database-spans/
https://opentelemetry.io/docs/specs/semconv/database/database-metrics/