-
Notifications
You must be signed in to change notification settings - Fork 774
/
SdkLoggerBuilder.java
51 lines (42 loc) · 1.48 KB
/
SdkLoggerBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.logs;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.logs.LoggerBuilder;
import io.opentelemetry.sdk.internal.ComponentRegistry;
import javax.annotation.Nullable;
final class SdkLoggerBuilder implements LoggerBuilder {
private final ComponentRegistry<SdkLogger> registry;
private final String instrumentationScopeName;
@Nullable private String instrumentationScopeVersion;
@Nullable private String schemaUrl;
@Nullable private String eventDomain;
SdkLoggerBuilder(ComponentRegistry<SdkLogger> registry, String instrumentationScopeName) {
this.registry = registry;
this.instrumentationScopeName = instrumentationScopeName;
}
@Override
public LoggerBuilder setEventDomain(String eventDomain) {
this.eventDomain = eventDomain;
return this;
}
@Override
public SdkLoggerBuilder setSchemaUrl(String schemaUrl) {
this.schemaUrl = schemaUrl;
return this;
}
@Override
public SdkLoggerBuilder setInstrumentationVersion(String instrumentationScopeVersion) {
this.instrumentationScopeVersion = instrumentationScopeVersion;
return this;
}
@Override
public SdkLogger build() {
SdkLogger logger =
registry.get(
instrumentationScopeName, instrumentationScopeVersion, schemaUrl, Attributes.empty());
return eventDomain == null ? logger : logger.withEventDomain(eventDomain);
}
}