-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUM-1836 feat(otel-tracer): scaffold conformance to otel Tracer, Span…
…Builder and Span
- Loading branch information
Showing
7 changed files
with
259 additions
and
3 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
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 | ||
|
||
class OTelNoOpSpan: Span { | ||
var kind: OpenTelemetryApi.SpanKind = .internal | ||
|
||
var name: String = "" | ||
|
||
var context: SpanContext = SpanContext.create( | ||
traceId: TraceId.invalid, | ||
spanId: SpanId.invalid, | ||
traceFlags: TraceFlags(), | ||
traceState: TraceState() | ||
) | ||
|
||
var isRecording: Bool = false | ||
|
||
var status: Status = Status.unset | ||
|
||
var description: String = "NoOpSpan" | ||
|
||
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() | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
DatadogTrace/Sources/OpenTelemetry/OTelNoOpSpanBuilder.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,50 @@ | ||
/* | ||
* 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 | ||
|
||
class NoOpSpanBuilder: SpanBuilder { | ||
@discardableResult public func startSpan() -> Span { | ||
return OTelNoOpSpan() | ||
} | ||
|
||
@discardableResult public func setParent(_ parent: Span) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func setParent(_ parent: SpanContext) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func setNoParent() -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func addLink(spanContext: SpanContext) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func addLink(spanContext: SpanContext, attributes: [String: OpenTelemetryApi.AttributeValue]) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func setSpanKind(spanKind: SpanKind) -> Self { | ||
return self | ||
} | ||
|
||
@discardableResult public func setStartTime(time: Date) -> Self { | ||
return self | ||
} | ||
|
||
public func setAttribute(key: String, value: OpenTelemetryApi.AttributeValue) -> Self { | ||
return self | ||
} | ||
|
||
func setActive(_ active: Bool) -> Self { | ||
return self | ||
} | ||
} |
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,94 @@ | ||
/* | ||
* 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 | ||
|
||
class OTelSpan: OpenTelemetryApi.Span { | ||
private let tracer: DatadogTracer | ||
private let queue: DispatchQueue | ||
private var _status: OpenTelemetryApi.Status | ||
private var _name: String | ||
|
||
init( | ||
context: OpenTelemetryApi.SpanContext, | ||
kind: OpenTelemetryApi.SpanKind, | ||
name: String, | ||
tracer: DatadogTracer | ||
) { | ||
self._name = name | ||
self._status = .unset | ||
self.context = context | ||
self.isRecording = true | ||
self.kind = kind | ||
self.queue = tracer.queue | ||
self.tracer = tracer | ||
} | ||
|
||
var kind: OpenTelemetryApi.SpanKind | ||
|
||
var context: OpenTelemetryApi.SpanContext | ||
|
||
var isRecording: Bool | ||
|
||
var status: OpenTelemetryApi.Status { | ||
get { | ||
queue.sync { | ||
_status | ||
} | ||
} | ||
set { | ||
queue.sync { | ||
_status = newValue | ||
} | ||
} | ||
} | ||
|
||
var name: String { | ||
get { | ||
queue.sync { | ||
_name | ||
} | ||
} | ||
set { | ||
queue.sync { | ||
_name = newValue | ||
} | ||
} | ||
} | ||
|
||
func addEvent(name: String) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func addEvent(name: String, timestamp: Date) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func addEvent(name: String, attributes: [String : OpenTelemetryApi.AttributeValue]) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func addEvent(name: String, attributes: [String : OpenTelemetryApi.AttributeValue], timestamp: Date) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func end() { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func end(time: Date) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
var description: String { | ||
return "WrapperSpan" | ||
} | ||
|
||
func setAttribute(key: String, value: OpenTelemetryApi.AttributeValue?) { | ||
fatalError("Not implemented") | ||
} | ||
} |
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,50 @@ | ||
/* | ||
* 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 | ||
|
||
class OTelSpanBuilder: OpenTelemetryApi.SpanBuilder { | ||
func setParent(_ parent: OpenTelemetryApi.Span) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setParent(_ parent: OpenTelemetryApi.SpanContext) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setNoParent() -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func addLink(spanContext: OpenTelemetryApi.SpanContext) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func addLink(spanContext: OpenTelemetryApi.SpanContext, attributes: [String : OpenTelemetryApi.AttributeValue]) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setSpanKind(spanKind: OpenTelemetryApi.SpanKind) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setStartTime(time: Date) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setActive(_ active: Bool) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func startSpan() -> OpenTelemetryApi.Span { | ||
fatalError("Not implemented") | ||
} | ||
|
||
func setAttribute(key: String, value: OpenTelemetryApi.AttributeValue) -> Self { | ||
fatalError("Not implemented") | ||
} | ||
} |
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