-
Notifications
You must be signed in to change notification settings - Fork 106
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 #2559
Open
birschick-bq
wants to merge
108
commits into
apache:main
Choose a base branch
from
birschick-bq:dev/birschick-bq/tracing-alternative
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.
Open
Changes from all commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
27c808c
optel poc - wip #1
birschick-bq 2384ed4
Initial POC for using System.Diagnostics
birschick-bq 3824499
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq 351ced6
remove go code
birschick-bq 49f9a72
moved tracing to Connection. Removed from Database/Driver
birschick-bq 4af814a
moved tracing to Connection. Removed from Database/Driver
birschick-bq 9bf476c
add comments about listener lifetimes
birschick-bq 2be0142
remove go code
birschick-bq 4b7997e
remove updates to tests
birschick-bq 1b87b4f
update exception handling
birschick-bq 1264d78
remove go
birschick-bq 753038e
more instrumentation and exception handling
birschick-bq 5749d7a
improved modularization
birschick-bq b30524f
remove unnecessary updates
birschick-bq cfbebb3
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq b77490b
updates from review comments to move the tracing code to make easier …
birschick-bq c4837c4
some clean-up and documentation
birschick-bq ea7b873
fix trailing space
birschick-bq a379b23
small update and tracing instrumentation for SparkDatabricksReader
birschick-bq c018d39
refactored TracingConnection to use common implementation. Added supp…
birschick-bq d935264
refactored TraceException
birschick-bq 4d874bc
corrected implementation
birschick-bq 40a067d
refactor tracing base
birschick-bq acc0a1b
remove unnecessary changes
birschick-bq b2d9c90
remove unnecessary changes
birschick-bq 95658bf
improve listener behaviour. fix missing members
birschick-bq 2625e14
complete comment
birschick-bq fb74cf1
update version 1.1 connection/statement
birschick-bq ee11da1
started activity in SparkDatabricksReader
birschick-bq 6f0a759
fixed null handling in TracingBase
birschick-bq 6a6fc3d
add better support for cancellation and retry
birschick-bq dd78038
refactor to use OpenTelemetry Exporter
birschick-bq 381dce5
clean-up code, documentation, simplify locking
birschick-bq 30ad831
modify the default logging folder
birschick-bq dc19887
add file exporter tests. Updated driver/database/connection/statement…
birschick-bq f2d7499
correct validation and tests
birschick-bq e7bea68
test information
birschick-bq 9941b04
correct file size check and tests
birschick-bq 7d7c7ce
correct tests
birschick-bq 60646ff
correct tests
birschick-bq 879b41d
correct tests
birschick-bq 6c1d330
correct tests - larger size and range
birschick-bq 65cbc95
correct tests - invalid file characters
birschick-bq d072479
correct tests - max trace files
birschick-bq 1d68327
correct tests - single trace file
birschick-bq a3b9584
refactor where tracing options are handled. handle options for file s…
birschick-bq 40dad00
remove tracing of all properties/options - might include tokens and p…
birschick-bq a3d84c9
validate trace folder is writable
birschick-bq be09ea8
ensure folder before folder validation
birschick-bq 94ae794
update Spark driver documentation for file tracing options
birschick-bq fa2dca6
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq 04e19c1
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq 9c6a420
initial commit for setting the traceParent
birschick-bq 69d4345
small fixes for setting the traceParent
birschick-bq afd7ea6
small doc updates
birschick-bq 8bd877a
refactored how boiler place code is handled
birschick-bq 7b58323
some renameing and coumentation
birschick-bq 015bc90
fixed formatting
birschick-bq cb79fa7
add improved test for traceParent.
birschick-bq 4ac1789
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq cb3b6f2
update tests
birschick-bq 50e16e4
Improvement for output format and ingestion. Improvements for tracePa…
birschick-bq 1cd083f
Add extension methods to ease of creating Events and Links
birschick-bq 9f182b4
Documentation update
birschick-bq 12882ab
Add public property for ActivitySourceName
birschick-bq 600735d
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq fe60b80
Merge branch 'main' into dev/birschick-bq/open-telemetry-poc
birschick-bq 6d29577
remove instrumentation to isolate library change
birschick-bq 21548c1
remove more instrumentation code
birschick-bq 304a0c5
remove more instrumentation code #2
birschick-bq 2797b54
remove more instrumentation code #3
birschick-bq d7ec6f6
Merge branch 'main' into dev/birschick-bq/tracing-base-library
birschick-bq 41ed8e3
remove more instrumentation code #4
birschick-bq c3cfa50
remove more instrumentation code #5
birschick-bq 42076b9
remove more instrumentation code #6
birschick-bq d58e56d
add more test content
birschick-bq 7bca17c
Merge branch 'main' into dev/birschick-bq/tracing-base-library
birschick-bq 39f50bb
add performance test using BenchmarkDotNet
birschick-bq aa069f2
add header
birschick-bq f27b52f
correct async invocation
birschick-bq 7a17831
remove trailing white-space
birschick-bq 098f4c5
simplify activity handling
birschick-bq 96f7c95
correct performance tests and improve performance
birschick-bq 843c726
properly implement async queue to handle activity writing in FileExpo…
birschick-bq bf2a77e
Merge branch 'main' into dev/birschick-bq/tracing-base-library
birschick-bq 17f3d99
correct file size check
birschick-bq 723deed
Merge branch 'main' into dev/birschick-bq/tracing-base-library
birschick-bq 92a6c73
some clean-up
birschick-bq efe111c
fix trailing space
birschick-bq 5481238
refactor file exporter namespace
birschick-bq 07dba27
add clarifying comments
birschick-bq 2894673
Merge branch 'main' into dev/birschick-bq/tracing-base-library
birschick-bq 685534b
Initial tracing (alternative)
birschick-bq 10526b9
Remove tracing performance stub
birschick-bq 000267f
Cleanup #1
birschick-bq cd8176e
Merge branch 'main' into dev/birschick-bq/tracing-alternative
birschick-bq 99816e5
cleanup #2
birschick-bq cddd2e3
cleanup #3
birschick-bq ad29ae1
cleanup #4
birschick-bq 87f1783
cleanup #5
birschick-bq 26a3239
cleanup #6
birschick-bq f7951aa
cleanup #7
birschick-bq 35aaacd
add instrumentation of fetch next
birschick-bq bd9ef5f
correct errors
birschick-bq ea9d0eb
Merge branch 'main' into dev/birschick-bq/tracing-alternative
birschick-bq ab4784c
Merge branch 'main' into dev/birschick-bq/tracing-alternative
birschick-bq 582911c
Implement SetOption for HiveServer2Connection
birschick-bq f5ead8f
Use 'this' chaining
birschick-bq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
51 changes: 51 additions & 0 deletions
51
csharp/src/Apache.Arrow.Adbc/Tracing/ActivityExtensions.cs
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,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Apache.Arrow.Adbc.Tracing | ||
{ | ||
public static class ActivityExtensions | ||
{ | ||
/// <summary> | ||
/// Add a new <see cref="ActivityEvent"/> object to the <see cref="Activity.Events" /> list. | ||
/// </summary> | ||
/// <param name="activity">The activity to add the event to.</param> | ||
/// <param name="eventName">The name of the event.</param> | ||
/// <param name="tags">The optional list of tags to attach to the event.</param> | ||
/// <returns><see langword="this"/> for convenient chaining.</returns> | ||
public static Activity AddEvent(this Activity activity, string eventName, IReadOnlyList<KeyValuePair<string, object?>>? tags = default) | ||
{ | ||
ActivityTagsCollection? tagsCollection = tags == null ? null : new ActivityTagsCollection(tags); | ||
return activity.AddEvent(new ActivityEvent(eventName, tags: tagsCollection)); | ||
} | ||
|
||
/// <summary> | ||
/// Add a new <see cref="ActivityLink"/> to the <see cref="Activity.Links"/> list. | ||
/// </summary> | ||
/// <param name="activity">The activity to add the event to.</param> | ||
/// <param name="traceParent">The traceParent id for the associated <see cref="ActivityContext"/>.</param> | ||
/// <param name="tags">The optional list of tags to attach to the event.</param> | ||
/// <returns><see langword="this"/> for convenient chaining.</returns> | ||
public static Activity AddLink(this Activity activity, string traceParent, IReadOnlyList<KeyValuePair<string, object?>>? tags = default) | ||
{ | ||
ActivityTagsCollection? tagsCollection = tags == null ? null : new ActivityTagsCollection(tags); | ||
return activity.AddLink(new ActivityLink(ActivityContext.Parse(traceParent, null), tags: tagsCollection)); | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
192 changes: 192 additions & 0 deletions
192
csharp/src/Apache.Arrow.Adbc/Tracing/SerializableActivity.cs
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,192 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Apache.Arrow.Adbc.Tracing | ||
{ | ||
/// <summary> | ||
/// Simplified version of <see cref="Activity"/> that excludes some properties, etc. | ||
/// </summary> | ||
internal class SerializableActivity | ||
{ | ||
[JsonConstructor] | ||
public SerializableActivity() { } | ||
|
||
internal SerializableActivity( | ||
ActivityStatusCode status, | ||
string? statusDescription, | ||
bool hasRemoteParent, | ||
ActivityKind kind, | ||
string operationName, | ||
TimeSpan duration, | ||
DateTime startTimeUtc, | ||
string? id, | ||
string? parentId, | ||
string? rootId, | ||
string? traceStateString, | ||
ActivitySpanId spanId, | ||
ActivityTraceId traceId, | ||
bool recorded, | ||
bool isAllDataRequested, | ||
ActivityTraceFlags activityTraceFlags, | ||
ActivitySpanId parentSpanId, | ||
ActivityIdFormat idFormat, | ||
IReadOnlyList<KeyValuePair<string, object?>> tagObjects, | ||
IReadOnlyList<SerializableActivityEvent> events, | ||
IReadOnlyList<SerializableActivityLink> links, | ||
IReadOnlyList<KeyValuePair<string, string?>> baggage) | ||
{ | ||
Status = statusDescription ?? status.ToString(); | ||
HasRemoteParent = hasRemoteParent; | ||
Kind = kind.ToString(); | ||
OperationName = operationName; | ||
Duration = duration; | ||
StartTimeUtc = startTimeUtc; | ||
Id = id; | ||
ParentId = parentId; | ||
RootId = rootId; | ||
TraceStateString = traceStateString; | ||
SpanId = spanId.ToHexString(); | ||
TraceId = traceId.ToHexString(); | ||
Recorded = recorded; | ||
IsAllDataRequested = isAllDataRequested; | ||
ActivityTraceFlags = activityTraceFlags.ToString(); | ||
ParentSpanId = parentSpanId.ToHexString(); | ||
IdFormat = idFormat.ToString(); | ||
TagObjects = tagObjects; | ||
Events = events; | ||
Links = links; | ||
Baggage = baggage; | ||
} | ||
|
||
internal SerializableActivity(Activity activity) : this( | ||
activity.Status, | ||
activity.StatusDescription, | ||
activity.HasRemoteParent, | ||
activity.Kind, | ||
activity.OperationName, | ||
activity.Duration, | ||
activity.StartTimeUtc, | ||
activity.Id, | ||
activity.ParentId, | ||
activity.RootId, | ||
activity.TraceStateString, | ||
activity.SpanId, | ||
activity.TraceId, | ||
activity.Recorded, | ||
activity.IsAllDataRequested, | ||
activity.ActivityTraceFlags, | ||
activity.ParentSpanId, | ||
activity.IdFormat, | ||
activity.TagObjects.ToArray(), | ||
activity.Events.Select(e => (SerializableActivityEvent)e).ToArray(), | ||
activity.Links.Select(l => (SerializableActivityLink)l).ToArray(), | ||
activity.Baggage.ToArray()) | ||
{ } | ||
|
||
public string? Status { get; set; } | ||
public bool HasRemoteParent { get; set; } | ||
public string? Kind { get; set; } | ||
public string OperationName { get; set; } = ""; | ||
public TimeSpan Duration { get; set; } | ||
public DateTime StartTimeUtc { get; set; } | ||
public string? Id { get; set; } | ||
public string? ParentId { get; set; } | ||
public string? RootId { get; set; } | ||
|
||
public string? TraceStateString { get; set; } | ||
public string? SpanId { get; set; } | ||
public string? TraceId { get; set; } | ||
public bool Recorded { get; set; } | ||
public bool IsAllDataRequested { get; set; } | ||
public string? ActivityTraceFlags { get; set; } | ||
public string? ParentSpanId { get; set; } | ||
public string? IdFormat { get; set; } | ||
|
||
public IReadOnlyList<KeyValuePair<string, object?>> TagObjects { get; set; } = []; | ||
public IReadOnlyList<SerializableActivityEvent> Events { get; set; } = []; | ||
public IReadOnlyList<SerializableActivityLink> Links { get; set; } = []; | ||
public IReadOnlyList<KeyValuePair<string, string?>> Baggage { get; set; } = []; | ||
} | ||
|
||
internal class SerializableActivityEvent | ||
{ | ||
/// <summary> | ||
/// Gets the <see cref="SerializableActivityEvent"/> name. | ||
/// </summary> | ||
public string? Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="SerializableActivityEvent"/> timestamp. | ||
/// </summary> | ||
public DateTimeOffset Timestamp { get; set; } | ||
|
||
public IReadOnlyList<KeyValuePair<string, object?>> Tags { get; set; } = []; | ||
|
||
public static implicit operator SerializableActivityEvent(System.Diagnostics.ActivityEvent source) | ||
{ | ||
return new SerializableActivityEvent() | ||
{ | ||
Name = source.Name, | ||
Timestamp = source.Timestamp, | ||
Tags = source.Tags.ToArray(), | ||
}; | ||
} | ||
} | ||
|
||
internal class SerializableActivityLink | ||
{ | ||
public SerializableActivityContext? Context { get; set; } | ||
|
||
public IReadOnlyList<KeyValuePair<string, object?>>? Tags { get; set; } = []; | ||
|
||
public static implicit operator SerializableActivityLink(System.Diagnostics.ActivityLink source) | ||
{ | ||
return new SerializableActivityLink() | ||
{ | ||
Context = source.Context, | ||
Tags = source.Tags?.ToArray(), | ||
}; | ||
} | ||
} | ||
|
||
internal class SerializableActivityContext | ||
{ | ||
public string? SpanId { get; set; } | ||
public string? TraceId { get; set; } | ||
public string? TraceState { get; set; } | ||
public ActivityTraceFlags? TraceFlags { get; set; } | ||
public bool IsRemote { get; set; } | ||
|
||
public static implicit operator SerializableActivityContext(System.Diagnostics.ActivityContext source) | ||
{ | ||
return new SerializableActivityContext() | ||
{ | ||
SpanId = source.SpanId.ToHexString(), | ||
TraceId = source.TraceId.ToHexString(), | ||
TraceState = source.TraceState, | ||
TraceFlags = source.TraceFlags, | ||
IsRemote = source.IsRemote, | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This class is explicitly necessary, but helps with testing. It also "could" be useful a serialized version of
Activity