File tree 2 files changed +45
-3
lines changed
javaagent-core/src/main/java/org/hypertrace/agent/core/config
otel-extensions/src/main/java/org/hypertrace/agent/otel/extensions/config
2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ final class ConfigProvider {
33
33
34
34
private static volatile ReportingConfig reportingConfig ;
35
35
36
- private static ReportingConfig load () {
37
- ServiceLoader <ReportingConfig > configs = ServiceLoader .load (ReportingConfig .class );
36
+ private static ReportingConfig load (ClassLoader cl ) {
37
+ ServiceLoader <ReportingConfig > configs = ServiceLoader .load (ReportingConfig .class , cl );
38
38
Iterator <ReportingConfig > iterator = configs .iterator ();
39
39
if (!iterator .hasNext ()) {
40
40
logger .error ("Failed to load reporting config" );
@@ -43,11 +43,22 @@ private static ReportingConfig load() {
43
43
return iterator .next ();
44
44
}
45
45
46
+ public static ReportingConfig get (ClassLoader cl ) {
47
+ if (reportingConfig == null ) {
48
+ synchronized (ConfigProvider .class ) {
49
+ if (reportingConfig == null ) {
50
+ reportingConfig = load (cl );
51
+ }
52
+ }
53
+ }
54
+ return reportingConfig ;
55
+ }
56
+
46
57
public static ReportingConfig get () {
47
58
if (reportingConfig == null ) {
48
59
synchronized (ConfigProvider .class ) {
49
60
if (reportingConfig == null ) {
50
- reportingConfig = load ();
61
+ reportingConfig = load (Thread . currentThread (). getContextClassLoader () );
51
62
}
52
63
}
53
64
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright The Hypertrace Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org .hypertrace .agent .otel .extensions .config ;
18
+
19
+ import com .google .auto .service .AutoService ;
20
+ import io .opentelemetry .javaagent .tooling .BeforeAgentListener ;
21
+ import io .opentelemetry .sdk .autoconfigure .AutoConfiguredOpenTelemetrySdk ;
22
+ import org .hypertrace .agent .core .config .ReportingConfig .ConfigProvider ;
23
+
24
+ @ AutoService (BeforeAgentListener .class )
25
+ public class ReportingConfigInstaller implements BeforeAgentListener {
26
+
27
+ @ Override
28
+ public void beforeAgent (AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk ) {
29
+ ConfigProvider .get (getClass ().getClassLoader ());
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments