generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5cfeac
commit f5b09b3
Showing
6 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...n/java/org/finos/legend/depot/core/services/api/tracing/configuration/TracerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2021 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package org.finos.legend.depot.core.services.api.tracing.configuration; | ||
|
||
import io.opentracing.Tracer; | ||
import zipkin2.reporter.Sender; | ||
|
||
public interface TracerProvider | ||
{ | ||
Tracer create(Sender sender, String serviceName); | ||
} |
39 changes: 39 additions & 0 deletions
39
...nos/legend/depot/core/services/api/tracing/configuration/TracerProviderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package org.finos.legend.depot.core.services.api.tracing.configuration; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.finos.legend.opentracing.AuthenticationProvider; | ||
|
||
public abstract class TracerProviderConfiguration | ||
{ | ||
private TracerProviderConfiguration() | ||
{ | ||
} | ||
|
||
public static ObjectMapper configureObjectMapper(ObjectMapper objectMapper) | ||
{ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
abstract class WrapperMixin | ||
{ | ||
} | ||
|
||
return objectMapper | ||
.addMixIn(TracerProvider.class, WrapperMixin.class); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ing/src/main/java/org/finos/legend/depot/core/services/tracing/DefaultTracerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2021 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
package org.finos.legend.depot.core.services.tracing; | ||
|
||
import io.opentracing.Tracer; | ||
import io.prometheus.client.CollectorRegistry; | ||
import org.finos.legend.depot.core.services.api.tracing.configuration.TracerProvider; | ||
import org.finos.legend.engine.shared.core.operational.prometheus.TracingExports; | ||
import org.finos.legend.opentracing.OpenTracing; | ||
import zipkin2.reporter.InMemoryReporterMetrics; | ||
import zipkin2.reporter.Sender; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.LogManager; | ||
|
||
public class DefaultTracerProvider implements TracerProvider | ||
{ | ||
@Override | ||
public Tracer create(Sender sender,String serviceName) | ||
{ | ||
Tracer tracer = OpenTracing.create(sender, serviceName, null, getMemoryMetricsReporter()); | ||
LogManager.getLogManager().getLogger("").setLevel(Level.FINE); | ||
return tracer; | ||
} | ||
|
||
private InMemoryReporterMetrics getMemoryMetricsReporter() | ||
{ | ||
CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry; | ||
InMemoryReporterMetrics tracingMetrics = new InMemoryReporterMetrics(); | ||
collectorRegistry.register(new TracingExports(tracingMetrics)); | ||
return tracingMetrics; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters