Skip to content

Commit 775e7a0

Browse files
author
Ignacio Bonafonte
authored
Merge pull request #262 from danielqsj/zipkin_sn
zipkin use configured serviceName at first span ByDefault, TracerProviderSdk use EnvVarResource to generate serviceName from environment variables. If we don't set the serviceName via environment variables, the default value will be unknown_service+processName. In this scenario, for Zipkin exporter, the current implement will always clone the default serviceName to overwrite the configured serviceName via zipkin configuration. That's not what we want. And, we have not use the localEndpointCache to replace the defaultLocalEndpoint yet. This PR aims to fixes these two issues.
2 parents 8370a26 + 0afcb01 commit 775e7a0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/Exporters/Zipkin/Implementation/ZipkinConversionExtension.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ struct ZipkinConversionExtension {
2121
static var localEndpointCache = [String: ZipkinEndpoint]()
2222
static var remoteEndpointCache = [String: ZipkinEndpoint]()
2323

24+
static let defaultServiceName = "unknown_service:" + ProcessInfo.processInfo.processName
25+
2426
struct AttributeEnumerationState {
2527
var tags = [String: String]()
2628
var RemoteEndpointServiceName: String?
@@ -44,11 +46,11 @@ struct ZipkinConversionExtension {
4446

4547
var localEndpoint = defaultLocalEndpoint
4648

47-
if let serviceName = attributeEnumerationState.serviceName, !serviceName.isEmpty {
49+
if let serviceName = attributeEnumerationState.serviceName, !serviceName.isEmpty, defaultServiceName != serviceName {
4850
if localEndpointCache[serviceName] == nil {
49-
localEndpoint = defaultLocalEndpoint.clone(serviceName: serviceName)
50-
localEndpointCache[serviceName] = localEndpoint
51+
localEndpointCache[serviceName] = defaultLocalEndpoint.clone(serviceName: serviceName)
5152
}
53+
localEndpoint = localEndpointCache[serviceName] ?? localEndpoint
5254
}
5355

5456
if let serviceNamespace = attributeEnumerationState.serviceNamespace, !serviceNamespace.isEmpty {

0 commit comments

Comments
 (0)