Skip to content
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
merged 13 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,30 @@
3C41693C29FBF4D50042B9D2 /* DatadogWebViewTracking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CE119FE29F7BE0100202522 /* DatadogWebViewTracking.framework */; };
3C6C7FDB2B45738C006F5CBC /* OpenTelemetryApi in Frameworks */ = {isa = PBXBuildFile; productRef = 3C6C7FDA2B45738C006F5CBC /* OpenTelemetryApi */; };
3C6C7FDD2B457392006F5CBC /* OpenTelemetryApi in Frameworks */ = {isa = PBXBuildFile; productRef = 3C6C7FDC2B457392006F5CBC /* OpenTelemetryApi */; };
3C6C7FE72B459AAA006F5CBC /* OTelSpan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE02B459AAA006F5CBC /* OTelSpan.swift */; };
3C6C7FE82B459AAA006F5CBC /* OTelSpan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE02B459AAA006F5CBC /* OTelSpan.swift */; };
3C6C7FE92B459AAA006F5CBC /* OTelSpanBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE12B459AAA006F5CBC /* OTelSpanBuilder.swift */; };
3C6C7FEA2B459AAA006F5CBC /* OTelSpanBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE12B459AAA006F5CBC /* OTelSpanBuilder.swift */; };
3C6C7FEB2B459AAA006F5CBC /* OTelTraceId+Datadog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE22B459AAA006F5CBC /* OTelTraceId+Datadog.swift */; };
3C6C7FEC2B459AAA006F5CBC /* OTelTraceId+Datadog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE22B459AAA006F5CBC /* OTelTraceId+Datadog.swift */; };
3C6C7FEF2B459AAA006F5CBC /* OTelSpanId+Datadog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE42B459AAA006F5CBC /* OTelSpanId+Datadog.swift */; };
3C6C7FF02B459AAA006F5CBC /* OTelSpanId+Datadog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FE42B459AAA006F5CBC /* OTelSpanId+Datadog.swift */; };
3C6C7FFB2B459AF6006F5CBC /* OTelSpanId+DatadogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF22B459AB3006F5CBC /* OTelSpanId+DatadogTests.swift */; };
3C6C7FFC2B459AF6006F5CBC /* OTelTraceId+DatadogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF32B459AB3006F5CBC /* OTelTraceId+DatadogTests.swift */; };
3C6C7FFD2B459AF6006F5CBC /* OTelSpanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF42B459AB3006F5CBC /* OTelSpanTests.swift */; };
3C6C7FFE2B459AF6006F5CBC /* OTelSpanId+DatadogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF22B459AB3006F5CBC /* OTelSpanId+DatadogTests.swift */; };
3C6C7FFF2B459AF6006F5CBC /* OTelTraceId+DatadogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF32B459AB3006F5CBC /* OTelTraceId+DatadogTests.swift */; };
3C6C80002B459AF6006F5CBC /* OTelSpanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6C7FF42B459AB3006F5CBC /* OTelSpanTests.swift */; };
3C74305C29FBC0480053B80F /* DatadogInternal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2DA2385298D57AA00C6C7E6 /* DatadogInternal.framework */; };
3C85D42129F7C5C900AFF894 /* WebViewTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C85D41429F7C59C00AFF894 /* WebViewTracking.swift */; };
3C85D42A29F7C70300AFF894 /* TestUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D257953E298ABA65008A1BE5 /* TestUtilities.framework */; };
3C85D42C29F7C87D00AFF894 /* HostsSanitizerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C85D42B29F7C87D00AFF894 /* HostsSanitizerMock.swift */; };
3C85D42D29F7C87D00AFF894 /* HostsSanitizerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C85D42B29F7C87D00AFF894 /* HostsSanitizerMock.swift */; };
3C9C6BB429F7C0C000581C43 /* DatadogInternal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D23039A5298D513C001A1FA3 /* DatadogInternal.framework */; };
3CB012DD2B482E0400557951 /* NOPOTelSpan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB012DB2B482E0400557951 /* NOPOTelSpan.swift */; };
3CB012DE2B482E0400557951 /* NOPOTelSpan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB012DB2B482E0400557951 /* NOPOTelSpan.swift */; };
3CB012DF2B482E0400557951 /* NOPOTelSpanBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB012DC2B482E0400557951 /* NOPOTelSpanBuilder.swift */; };
3CB012E02B482E0400557951 /* NOPOTelSpanBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB012DC2B482E0400557951 /* NOPOTelSpanBuilder.swift */; };
3CB32AD42ACB733000D602ED /* URLSessionSwizzler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB32AD32ACB733000D602ED /* URLSessionSwizzler.swift */; };
3CB32AD52ACB733000D602ED /* URLSessionSwizzler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB32AD32ACB733000D602ED /* URLSessionSwizzler.swift */; };
3CB32AD72ACB735600D602ED /* URLSessionSwizzlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CB32AD62ACB735600D602ED /* URLSessionSwizzlerTests.swift */; };
Expand Down Expand Up @@ -1882,8 +1900,17 @@
3C2206F22AB9CE9300DE780C /* MetaTypeExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaTypeExtensions.swift; sourceTree = "<group>"; };
3C394EF62AA5F49F008F48BA /* URLSessionDataDelegateSwizzler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionDataDelegateSwizzler.swift; sourceTree = "<group>"; };
3C394EF92AA5F4C8008F48BA /* URLSessionDataDelegateSwizzlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionDataDelegateSwizzlerTests.swift; sourceTree = "<group>"; };
3C6C7FE02B459AAA006F5CBC /* OTelSpan.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTelSpan.swift; sourceTree = "<group>"; };
3C6C7FE12B459AAA006F5CBC /* OTelSpanBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTelSpanBuilder.swift; sourceTree = "<group>"; };
3C6C7FE22B459AAA006F5CBC /* OTelTraceId+Datadog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "OTelTraceId+Datadog.swift"; sourceTree = "<group>"; };
3C6C7FE42B459AAA006F5CBC /* OTelSpanId+Datadog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "OTelSpanId+Datadog.swift"; sourceTree = "<group>"; };
3C6C7FF22B459AB3006F5CBC /* OTelSpanId+DatadogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "OTelSpanId+DatadogTests.swift"; sourceTree = "<group>"; };
3C6C7FF32B459AB3006F5CBC /* OTelTraceId+DatadogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "OTelTraceId+DatadogTests.swift"; sourceTree = "<group>"; };
3C6C7FF42B459AB3006F5CBC /* OTelSpanTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTelSpanTests.swift; sourceTree = "<group>"; };
3C85D41429F7C59C00AFF894 /* WebViewTracking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewTracking.swift; sourceTree = "<group>"; };
3C85D42B29F7C87D00AFF894 /* HostsSanitizerMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HostsSanitizerMock.swift; sourceTree = "<group>"; };
3CB012DB2B482E0400557951 /* NOPOTelSpan.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NOPOTelSpan.swift; sourceTree = "<group>"; };
3CB012DC2B482E0400557951 /* NOPOTelSpanBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NOPOTelSpanBuilder.swift; sourceTree = "<group>"; };
3CB32AD32ACB733000D602ED /* URLSessionSwizzler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionSwizzler.swift; sourceTree = "<group>"; };
3CB32AD62ACB735600D602ED /* URLSessionSwizzlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionSwizzlerTests.swift; sourceTree = "<group>"; };
3CBDE66D2AA08BF600F6A7B6 /* URLSessionTaskDelegateSwizzler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskDelegateSwizzler.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3084,6 +3111,29 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
3C6C7FDE2B459AAA006F5CBC /* OpenTelemetry */ = {
isa = PBXGroup;
children = (
3CB012DB2B482E0400557951 /* NOPOTelSpan.swift */,
3CB012DC2B482E0400557951 /* NOPOTelSpanBuilder.swift */,
3C6C7FE02B459AAA006F5CBC /* OTelSpan.swift */,
3C6C7FE12B459AAA006F5CBC /* OTelSpanBuilder.swift */,
3C6C7FE22B459AAA006F5CBC /* OTelTraceId+Datadog.swift */,
3C6C7FE42B459AAA006F5CBC /* OTelSpanId+Datadog.swift */,
);
path = OpenTelemetry;
sourceTree = "<group>";
};
3C6C7FF12B459AB3006F5CBC /* OpenTelemetry */ = {
isa = PBXGroup;
children = (
3C6C7FF22B459AB3006F5CBC /* OTelSpanId+DatadogTests.swift */,
3C6C7FF32B459AB3006F5CBC /* OTelTraceId+DatadogTests.swift */,
3C6C7FF42B459AB3006F5CBC /* OTelSpanTests.swift */,
);
path = OpenTelemetry;
sourceTree = "<group>";
};
3CE11A3B29F7BEE700202522 /* DatadogWebViewTracking */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5486,6 +5536,7 @@
D25EE93529C4C3C300CE3839 /* DatadogTrace */ = {
isa = PBXGroup;
children = (
3C6C7FDE2B459AAA006F5CBC /* OpenTelemetry */,
61A2CC382A44B0EA0000FF25 /* Trace.swift */,
61A2CC352A44B0A20000FF25 /* TraceConfiguration.swift */,
61A2CC3B2A44BED30000FF25 /* Tracer.swift */,
Expand All @@ -5508,6 +5559,7 @@
D25EE93F29C4C3C400CE3839 /* DatadogTraceTests */ = {
isa = PBXGroup;
children = (
3C6C7FF12B459AB3006F5CBC /* OpenTelemetry */,
619CE75D2A458CE1005588CB /* TraceConfigurationTests.swift */,
61AD4E172451C7FF006E34EA /* TracingFeatureMocks.swift */,
61C5A89824509C1100DA608C /* DDSpanTests.swift */,
Expand Down Expand Up @@ -8275,15 +8327,21 @@
D2C1A50C29C4C4CB00946C31 /* DDNoOps.swift in Sources */,
D2C1A4FC29C4C4CB00946C31 /* RequestBuilder.swift in Sources */,
D2C1A50D29C4C4CB00946C31 /* SpanTagsReducer.swift in Sources */,
3CB012DD2B482E0400557951 /* NOPOTelSpan.swift in Sources */,
D2C1A51A29C4C5DD00946C31 /* JSONEncoder.swift in Sources */,
D2C1A51829C4C53F00946C31 /* OTSpan.swift in Sources */,
D2C1A51429C4C53F00946C31 /* OTSpanContext.swift in Sources */,
3C6C7FEB2B459AAA006F5CBC /* OTelTraceId+Datadog.swift in Sources */,
3C6C7FE92B459AAA006F5CBC /* OTelSpanBuilder.swift in Sources */,
D2C1A51329C4C53F00946C31 /* OTReference.swift in Sources */,
3C6C7FEF2B459AAA006F5CBC /* OTelSpanId+Datadog.swift in Sources */,
D2C1A4FB29C4C4CB00946C31 /* MessageReceivers.swift in Sources */,
61A2CC362A44B0A20000FF25 /* TraceConfiguration.swift in Sources */,
61A2CC392A44B0EA0000FF25 /* Trace.swift in Sources */,
D2C1A50029C4C4CB00946C31 /* ActiveSpansPool.swift in Sources */,
3CB012DF2B482E0400557951 /* NOPOTelSpanBuilder.swift in Sources */,
D2C1A50929C4C4CB00946C31 /* SpanEventEncoder.swift in Sources */,
3C6C7FE72B459AAA006F5CBC /* OTelSpan.swift in Sources */,
D2C1A4FE29C4C4CB00946C31 /* SpanEventMapper.swift in Sources */,
D2C1A50329C4C4CB00946C31 /* DDFormat.swift in Sources */,
D2C1A51629C4C53F00946C31 /* OTConstants.swift in Sources */,
Expand Down Expand Up @@ -8314,10 +8372,13 @@
D2C1A51D29C4C75700946C31 /* SpanEventBuilderTests.swift in Sources */,
D2C1A52229C4C75700946C31 /* DDNoopTracerTests.swift in Sources */,
D2C1A51C29C4C75700946C31 /* ContextMessageReceiverTests.swift in Sources */,
3C6C7FFD2B459AF6006F5CBC /* OTelSpanTests.swift in Sources */,
619CE7612A458D66005588CB /* TraceTests.swift in Sources */,
D2C1A52029C4C75700946C31 /* DDSpanTests.swift in Sources */,
3C6C7FFC2B459AF6006F5CBC /* OTelTraceId+DatadogTests.swift in Sources */,
D2C1A51B29C4C75700946C31 /* DDSpanContextTests.swift in Sources */,
D2C1A52729C4C7D000946C31 /* TracingFeatureMocks.swift in Sources */,
3C6C7FFB2B459AF6006F5CBC /* OTelSpanId+DatadogTests.swift in Sources */,
D2C1A51F29C4C75700946C31 /* ActiveSpansPoolTests.swift in Sources */,
D2C1A52529C4C75700946C31 /* SpanSanitizerTests.swift in Sources */,
);
Expand Down Expand Up @@ -8464,15 +8525,21 @@
D2C1A53929C4F2DF00946C31 /* DDNoOps.swift in Sources */,
D2C1A53A29C4F2DF00946C31 /* RequestBuilder.swift in Sources */,
D2C1A53B29C4F2DF00946C31 /* SpanTagsReducer.swift in Sources */,
3CB012DE2B482E0400557951 /* NOPOTelSpan.swift in Sources */,
D2C1A53C29C4F2DF00946C31 /* JSONEncoder.swift in Sources */,
D2C1A53D29C4F2DF00946C31 /* OTSpan.swift in Sources */,
D2C1A53E29C4F2DF00946C31 /* OTSpanContext.swift in Sources */,
3C6C7FEC2B459AAA006F5CBC /* OTelTraceId+Datadog.swift in Sources */,
3C6C7FEA2B459AAA006F5CBC /* OTelSpanBuilder.swift in Sources */,
D2C1A53F29C4F2DF00946C31 /* OTReference.swift in Sources */,
3C6C7FF02B459AAA006F5CBC /* OTelSpanId+Datadog.swift in Sources */,
D2C1A54129C4F2DF00946C31 /* MessageReceivers.swift in Sources */,
61A2CC372A44B0A20000FF25 /* TraceConfiguration.swift in Sources */,
61A2CC3A2A44B0EA0000FF25 /* Trace.swift in Sources */,
D2C1A54229C4F2DF00946C31 /* ActiveSpansPool.swift in Sources */,
3CB012E02B482E0400557951 /* NOPOTelSpanBuilder.swift in Sources */,
D2C1A54329C4F2DF00946C31 /* SpanEventEncoder.swift in Sources */,
3C6C7FE82B459AAA006F5CBC /* OTelSpan.swift in Sources */,
D2C1A54429C4F2DF00946C31 /* SpanEventMapper.swift in Sources */,
D2C1A54529C4F2DF00946C31 /* DDFormat.swift in Sources */,
D2C1A54629C4F2DF00946C31 /* OTConstants.swift in Sources */,
Expand Down Expand Up @@ -8503,10 +8570,13 @@
D2C1A56229C4F2E800946C31 /* SpanEventBuilderTests.swift in Sources */,
D2C1A56329C4F2E800946C31 /* DDNoopTracerTests.swift in Sources */,
D2C1A56529C4F2E800946C31 /* ContextMessageReceiverTests.swift in Sources */,
3C6C80002B459AF6006F5CBC /* OTelSpanTests.swift in Sources */,
619CE7622A458D66005588CB /* TraceTests.swift in Sources */,
D2C1A56629C4F2E800946C31 /* DDSpanTests.swift in Sources */,
3C6C7FFF2B459AF6006F5CBC /* OTelTraceId+DatadogTests.swift in Sources */,
D2C1A56729C4F2E800946C31 /* DDSpanContextTests.swift in Sources */,
D2C1A56829C4F2E800946C31 /* TracingFeatureMocks.swift in Sources */,
3C6C7FFE2B459AF6006F5CBC /* OTelSpanId+DatadogTests.swift in Sources */,
D2C1A56929C4F2E800946C31 /* ActiveSpansPoolTests.swift in Sources */,
D2C1A56A29C4F2E800946C31 /* SpanSanitizerTests.swift in Sources */,
);
Expand Down
10 changes: 9 additions & 1 deletion DatadogTrace/Sources/DDNoOps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import Foundation
import DatadogInternal
import OpenTelemetryApi

internal struct DDNoopGlobals {
static let tracer = DDNoopTracer()
static let span = DDNoopSpan()
static let context = DDNoopSpanContext()
}

internal struct DDNoopTracer: OTTracer {
internal class DDNoopTracer: OTTracer, OpenTelemetryApi.Tracer {
Copy link
Contributor Author

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.

var activeSpan: OTSpan? = nil

private func warn() {
Expand Down Expand Up @@ -44,6 +45,13 @@ internal struct DDNoopTracer: OTTracer {
warn()
return DDNoopGlobals.span
}

// MARK: - Open Telemetry

func spanBuilder(spanName: String) -> OpenTelemetryApi.SpanBuilder {
warn()
return NOPOTelSpanBuilder()
}
}

internal struct DDNoopSpan: OTSpan {
Expand Down
17 changes: 16 additions & 1 deletion DatadogTrace/Sources/DatadogTracer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import Foundation
import DatadogInternal
import OpenTelemetryApi

internal class DatadogTracer: OTTracer {
internal final class DatadogTracer: OTTracer, OpenTelemetryApi.Tracer {
internal weak var core: DatadogCoreProtocol?

/// Global tags configured for Trace feature.
Expand Down Expand Up @@ -156,4 +157,18 @@ internal class DatadogTracer: OTTracer {
forKey: SpanCoreContext.key
)
}

// MARK: - OpenTelemetry

func spanBuilder(spanName: String) -> OpenTelemetryApi.SpanBuilder {
OTelSpanBuilder(
active: false,
attributes: [:],
parent: .currentSpan,
spanKind: .client,
spanName: spanName,
startTime: nil,
tracer: self
)
}
}
47 changes: 47 additions & 0 deletions DatadogTrace/Sources/OpenTelemetry/NOPOTelSpan.swift
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 DatadogTrace/Sources/OpenTelemetry/NOPOTelSpanBuilder.swift
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
}
}
Loading