-
Notifications
You must be signed in to change notification settings - Fork 133
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
RUM-1836 feat(otel-tracer): conform to otel Tracer, SpanBuilder and Span #1611
Merged
ganeshnj
merged 13 commits into
ganeshnj/feat/otel-tracer
from
ganeshnj/feat/otel-tracer-conform
Jan 5, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4b61a0a
RUM-1836 feat(otel-tracer): scaffold conformance to otel Tracer, Span…
ganeshnj 27ecb2a
RUM-1836 feat(otel-tracer): implement core functionality of the otel …
ganeshnj c9143b0
RUM-1836 feat(otel-tracer): add test cases
ganeshnj bf55a6c
RUM-1836 feat(otel-tracer): fix linter
ganeshnj 156454d
RUM-1836 feat(otel-tracer): add tests
ganeshnj 3a8b2ca
RUM-1836 feat(otel-tracer): add source files to project
ganeshnj 84a7f78
RUM-1836 feat(otel-tracer): casing - now all OTel
ganeshnj f03cd63
RUM-1836 feat(otel-tracer): remove status API for now, will add later
ganeshnj dec5b26
RUM-1836 feat(otel-tracer): handle attribute cases one by one
ganeshnj c045052
RUM-1836 feat(otel-tracer): remove unused variables
ganeshnj a53814e
RUM-1836 feat(otel-tracer): PR feedback
ganeshnj 140c95b
RUM-1836 feat(otel-tracer): corresponding reference change of rename
ganeshnj 2eab9ac
RUM-1836 feat(otel-tracer): remove semaphore usage
ganeshnj 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
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
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,47 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-Present Datadog, Inc. | ||
*/ | ||
|
||
import Foundation | ||
import OpenTelemetryApi | ||
|
||
internal class NOPOTelSpan: Span { | ||
var kind: OpenTelemetryApi.SpanKind = .internal | ||
|
||
var name: String = "" | ||
|
||
var context = SpanContext.create( | ||
traceId: TraceId.invalid, | ||
spanId: SpanId.invalid, | ||
traceFlags: TraceFlags(), | ||
traceState: TraceState() | ||
) | ||
|
||
var isRecording = false | ||
|
||
var status = Status.unset | ||
|
||
var description: String = "OTelNoOpSpan" | ||
|
||
func updateName(name: String) {} | ||
|
||
func setAttribute(key: String, value: OpenTelemetryApi.AttributeValue?) {} | ||
|
||
func addEvent(name: String) {} | ||
|
||
func addEvent(name: String, timestamp: Date) {} | ||
|
||
func addEvent(name: String, attributes: [String: OpenTelemetryApi.AttributeValue]) {} | ||
|
||
func addEvent(name: String, attributes: [String: OpenTelemetryApi.AttributeValue], timestamp: Date) {} | ||
|
||
func end() { | ||
OpenTelemetry.instance.contextProvider.removeContextForSpan(self) | ||
} | ||
|
||
func end(time: Date) { | ||
end() | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
DatadogTrace/Sources/OpenTelemetry/NOPOTelSpanBuilder.swift
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,58 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-Present Datadog, Inc. | ||
*/ | ||
|
||
import Foundation | ||
import OpenTelemetryApi | ||
|
||
internal class NOPOTelSpanBuilder: SpanBuilder { | ||
@discardableResult | ||
func startSpan() -> Span { | ||
return NOPOTelSpan() | ||
} | ||
|
||
@discardableResult | ||
func setParent(_ parent: Span) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func setParent(_ parent: SpanContext) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func setNoParent() -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func addLink(spanContext: SpanContext) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func addLink(spanContext: SpanContext, attributes: [String: OpenTelemetryApi.AttributeValue]) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func setSpanKind(spanKind: SpanKind) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult | ||
func setStartTime(time: Date) -> Self { | ||
return self | ||
} | ||
|
||
func setAttribute(key: String, value: OpenTelemetryApi.AttributeValue) -> Self { | ||
return self | ||
} | ||
|
||
func setActive(_ active: Bool) -> Self { | ||
return self | ||
} | ||
} |
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.
OpenTelemetryApi.Tracer
is class only protocol.