-
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.
Merge pull request #1611 from DataDog/ganeshnj/feat/otel-tracer-conform
RUM-1836 feat(otel-tracer): conform to otel Tracer, SpanBuilder and Span
- Loading branch information
Showing
13 changed files
with
812 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
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.