File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ final class ConfigProvider {
3333
3434 private static volatile ReportingConfig reportingConfig ;
3535
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 );
3838 Iterator <ReportingConfig > iterator = configs .iterator ();
3939 if (!iterator .hasNext ()) {
4040 logger .error ("Failed to load reporting config" );
@@ -43,11 +43,22 @@ private static ReportingConfig load() {
4343 return iterator .next ();
4444 }
4545
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+
4657 public static ReportingConfig get () {
4758 if (reportingConfig == null ) {
4859 synchronized (ConfigProvider .class ) {
4960 if (reportingConfig == null ) {
50- reportingConfig = load ();
61+ reportingConfig = load (Thread . currentThread (). getContextClassLoader () );
5162 }
5263 }
5364 }
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