Skip to content
Open
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ ext.libraries = [
ext['snakeyaml.version'] = '2.0'

dependencies {
implementation 'com.microsoft.azure:applicationinsights-core:3.7.1'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.gov.hmcts.reform.preapi.controllers;

import com.azure.resourcemanager.mediaservices.models.JobState;
import com.microsoft.applicationinsights.TelemetryClient;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -42,7 +43,9 @@
import uk.gov.hmcts.reform.preapi.services.CaptureSessionService;
import uk.gov.hmcts.reform.preapi.services.RecordingService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Logger;

Expand All @@ -57,6 +60,8 @@ public class MediaServiceController extends PreApiController {
private final AzureIngestStorageService azureIngestStorageService;
private final RecordingService recordingService;

private final TelemetryClient telemetry = new TelemetryClient();

@Autowired
public MediaServiceController(MediaServiceBroker mediaServiceBroker,
CaptureSessionService captureSessionService,
Expand Down Expand Up @@ -243,6 +248,11 @@ public ResponseEntity<CaptureSessionDTO> createLiveEventStreamingLocator(@PathVa
// update captureSession
captureSession.setLiveOutputUrl(liveOutputUrl);
captureSession.setStatus(RecordingStatus.RECORDING);
Map<String, String> properties = new HashMap<String, String>();
properties.put("captureSession_ID", captureSession.getId().toString());
properties.put("captureSession_STATUS", captureSession.getStatus().name());
telemetry.trackEvent(properties.toString());

captureSessionService.upsert(captureSession);

return ResponseEntity.ok(captureSession);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.reform.preapi.services;

import com.microsoft.applicationinsights.TelemetryClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
Expand Down Expand Up @@ -30,6 +31,8 @@
import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

Expand All @@ -43,6 +46,8 @@ public class CaptureSessionService {
private final UserRepository userRepository;
private final BookingService bookingService;

private final TelemetryClient telemetry = new TelemetryClient();

@Autowired
public CaptureSessionService(RecordingService recordingService,
CaptureSessionRepository captureSessionRepository,
Expand Down Expand Up @@ -204,6 +209,10 @@ public UpsertResult upsert(CreateCaptureSessionDTO createCaptureSessionDTO) {
captureSession.setFinishedAt(createCaptureSessionDTO.getFinishedAt());
captureSession.setFinishedByUser(finishedByUser);
captureSession.setStatus(createCaptureSessionDTO.getStatus());
Map<String, String> properties = new HashMap<String, String>();
properties.put("captureSession_ID", captureSession.getId().toString());
properties.put("captureSession_STATUS", captureSession.getStatus().name());
telemetry.trackEvent(properties.toString());

captureSessionRepository.save(captureSession);

Expand Down Expand Up @@ -237,6 +246,11 @@ public CaptureSessionDTO startCaptureSession(UUID id, RecordingStatus status, St
captureSession.setStartedAt(Timestamp.from(Instant.now()));

captureSession.setStatus(status);
Map<String, String> properties = new HashMap<String, String>();
properties.put("captureSession_ID", captureSession.getId().toString());
properties.put("captureSession_STATUS", captureSession.getStatus().name());
telemetry.trackEvent(properties.toString());

captureSession.setIngestAddress(ingestAddress);

captureSessionRepository.save(captureSession);
Expand All @@ -253,6 +267,10 @@ public CaptureSessionDTO stopCaptureSession(UUID captureSessionId,

log.info("Stopping capture session {} with status {}", captureSessionId, status);
captureSession.setStatus(status);
Map<String, String> properties = new HashMap<String, String>();
properties.put("captureSession_ID", captureSession.getId().toString());
properties.put("captureSession_STATUS", captureSession.getStatus().name());
telemetry.trackEvent(properties.toString());

switch (status) {
case PROCESSING -> {
Expand Down Expand Up @@ -283,6 +301,11 @@ public CaptureSessionDTO setCaptureSessionStatus(UUID captureSessionId, Recordin
.findByIdAndDeletedAtIsNull(captureSessionId)
.orElseThrow(() -> new NotFoundException("Capture Session: " + captureSessionId));
captureSession.setStatus(status);
Map<String, String> properties = new HashMap<String, String>();
properties.put("captureSession_ID", captureSession.getId().toString());
properties.put("captureSession_STATUS", captureSession.getStatus().name());
telemetry.trackEvent(properties.toString());

captureSessionRepository.save(captureSession);
return new CaptureSessionDTO(captureSession);
}
Expand Down