File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Sources/Exporters/DatadogExporter/Spans Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import UIKit
1313
1414let apikeyOrClientToken = " "
1515
16+ let resourceKey = " resource.name "
17+ let resourceValue = " The resource "
18+
1619let sampleKey = " sampleKey "
1720let sampleValue = " sampleValue "
1821
@@ -60,7 +63,7 @@ func testTraces() {
6063
6164func simpleSpan( ) {
6265 let span = tracer. spanBuilder ( spanName: " SimpleSpan " ) . setSpanKind ( spanKind: . client) . startSpan ( )
63- span. setAttribute ( key: sampleKey , value: sampleValue )
66+ span. setAttribute ( key: resourceKey , value: resourceValue )
6467 span. addEvent ( name: " My event " , attributes: [ " message " : AttributeValue . string ( " test message " ) ,
6568 " newKey " : AttributeValue . string ( " New Value " ) ] )
6669 span. end ( )
Original file line number Diff line number Diff line change @@ -57,8 +57,8 @@ internal struct DDSpan: Encodable {
5757 /// Custom tags, received from user
5858 let tags : [ String : AttributeValue ]
5959
60- static let errorTagKeys : Set < String > = [
61- " error.message " , " error.type " , " error.stack " ,
60+ static let filteredTagKeys : Set < String > = [
61+ " error.message " , " error.type " , " error.stack " , " resource.name "
6262 ]
6363
6464 func encode( to encoder: Encoder ) throws {
@@ -77,7 +77,7 @@ internal struct DDSpan: Encodable {
7777 }
7878
7979 self . serviceName = configuration. serviceName
80- self . resource = spanData. name
80+ self . resource = spanData. attributes [ " resource.name " ] ? . description ?? spanData . name
8181 self . startTime = spanData. startTime. timeIntervalSince1970. toNanoseconds
8282 self . duration = spanData. endTime. timeIntervalSince ( spanData. startTime) . toNanoseconds
8383
@@ -99,7 +99,7 @@ internal struct DDSpan: Encodable {
9999
100100 self . applicationVersion = configuration. version
101101 self . tags = spanData. attributes. filter {
102- !DDSpan. errorTagKeys . contains ( $0. key)
102+ !DDSpan. filteredTagKeys . contains ( $0. key)
103103 } . mapValues { $0 }
104104 }
105105}
You can’t perform that action at this time.
0 commit comments