Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fireflyframework-callbacks-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
</parent>

<artifactId>fireflyframework-callbacks-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2024-2026 Firefly Software Foundation
*
* 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.fireflyframework.callbacks.core.observability;

import io.micrometer.core.instrument.MeterRegistry;
import org.fireflyframework.observability.metrics.FireflyMetricsSupport;
import reactor.core.publisher.Mono;

/**
* Observability instrumentation for the callbacks dispatcher.
* <p>
* Records:
* <ul>
* <li>{@code firefly.callbacks.deliveries} — counter tagged by {@code target.id} and
* {@code status} (success/failure/retry/cancelled)</li>
* <li>{@code firefly.callbacks.delivery.duration} — timer of dispatch latency,
* tagged by {@code target.id}</li>
* <li>{@code firefly.callbacks.retries} — counter of retry attempts,
* tagged by {@code target.id}, {@code attempt}</li>
* <li>{@code firefly.callbacks.circuit.opened} — counter of circuit-breaker openings,
* tagged by {@code target.id}</li>
* <li>{@code firefly.callbacks.errors} — counter of delivery errors,
* tagged by {@code target.id}, {@code error.type}</li>
* </ul>
*/
public class CallbackMetrics extends FireflyMetricsSupport {

private static final String TAG_TARGET = "target.id";
private static final String TAG_ATTEMPT = "attempt";

public CallbackMetrics(MeterRegistry meterRegistry) {
super(meterRegistry, "callbacks");
}

public <T> Mono<T> timedDelivery(String targetId, Mono<T> delivery) {
return timed("delivery.duration", delivery, TAG_TARGET, targetId)
.doOnSuccess(v -> recordSuccess("deliveries", TAG_TARGET, targetId))
.doOnError(e -> {
recordFailure("deliveries", e, TAG_TARGET, targetId);
recordFailure("errors", e, TAG_TARGET, targetId);
});
}

public void recordRetry(String targetId, int attempt) {
counter("retries", TAG_TARGET, targetId, TAG_ATTEMPT, String.valueOf(attempt)).increment();
}

public void recordCircuitOpened(String targetId) {
counter("circuit.opened", TAG_TARGET, targetId).increment();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2024-2026 Firefly Software Foundation
*
* 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.fireflyframework.callbacks.core.observability;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

/**
* Auto-configures {@link CallbackMetrics}.
*/
@AutoConfiguration
@ConditionalOnClass(MeterRegistry.class)
@ConditionalOnProperty(prefix = "firefly.observability.metrics", name = "enabled",
havingValue = "true", matchIfMissing = true)
public class CallbackObservabilityAutoConfiguration {

@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(MeterRegistry.class)
CallbackMetrics callbackMetrics(MeterRegistry meterRegistry) {
return new CallbackMetrics(meterRegistry);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.fireflyframework.callbacks.core.observability.CallbackObservabilityAutoConfiguration
2 changes: 1 addition & 1 deletion fireflyframework-callbacks-interfaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
</parent>

<artifactId>fireflyframework-callbacks-interfaces</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion fireflyframework-callbacks-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
</parent>

<artifactId>fireflyframework-callbacks-models</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion fireflyframework-callbacks-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
</parent>

<artifactId>fireflyframework-callbacks-sdk</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion fireflyframework-callbacks-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
</parent>

<artifactId>fireflyframework-callbacks-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spring:

# Firefly Callbacks Configuration
firefly:
observability:
health:
enabled: false
callbacks:
# listener configuration removed - now using dynamic listeners from database

Expand Down Expand Up @@ -68,3 +71,9 @@ logging:
org.fireflyframework.common.eda: DEBUG
org.springframework.data.r2dbc: DEBUG
org.testcontainers: INFO

# Required so apps without a db autoconfig don't crash on the readiness health-group default.
management:
endpoint:
health:
validate-group-membership: false
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-parent</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
<relativePath/>
</parent>

<groupId>org.fireflyframework</groupId>
<artifactId>fireflyframework-callbacks</artifactId>
<version>26.04.01</version>
<version>26.05.06</version>
<packaging>pom</packaging>

<name>Firefly Framework - Callbacks Library</name>
Expand Down
Loading