Skip to content

Commit

Permalink
Remove accessing metrics logs provider
Browse files Browse the repository at this point in the history
  • Loading branch information
NipunaMadhushan committed Nov 28, 2024
1 parent 0a2ad8d commit 3fedf01
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public BallerinaMetricsLogsObserver(Environment environment) {

@Override
public void startServerObservation(ObserverContext observerContext) {
startObservation(observerContext);
}

@Override
public void startClientObservation(ObserverContext observerContext) {
startObservation(observerContext);
}

@Override
Expand All @@ -76,6 +78,12 @@ public void stopClientObservation(ObserverContext observerContext) {
stopObservation(observerContext);
}

private void startObservation(ObserverContext observerContext) {
if (observerContext.getProperty(PROPERTY_START_TIME) == null) {
observerContext.addProperty(PROPERTY_START_TIME, System.nanoTime());
}
}

private void stopObservation(ObserverContext observerContext) {
Set<Tag> tags = new HashSet<>();
Map<String, Tag> customTags = observerContext.customMetricTags;
Expand Down Expand Up @@ -117,7 +125,7 @@ private void stopObservation(ObserverContext observerContext) {

private void handleError(String metricName, Set<Tag> tags, RuntimeException e) {
// Metric Provider may throw exceptions if there is a mismatch in tags.
consoleError.println("error: error collecting metrics for " + metricName + " with tags " + tags +
consoleError.println("error: error collecting metric logs for " + metricName + " with tags " + tags +
": " + e.getMessage());
}

Expand Down

0 comments on commit 3fedf01

Please sign in to comment.