From ce6b3765a2d31b9b90b7a1435e7180b91cba57b3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Jul 2022 10:56:05 +0200 Subject: Add more tracing --- server/models/video/formatter/video-format-utils.ts | 9 +++++++++ server/models/video/video.ts | 5 +++++ 2 files changed, 14 insertions(+) (limited to 'server/models/video') diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index 6222107d7..fd02f8c64 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts @@ -1,5 +1,6 @@ import { generateMagnetUri } from '@server/helpers/webtorrent' import { getActivityStreamDuration } from '@server/lib/activitypub/activity' +import { tracer } from '@server/lib/opentelemetry/tracing' import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' import { VideoViewsManager } from '@server/lib/views/video-views-manager' import { uuidToShort } from '@shared/extra-utils' @@ -71,6 +72,8 @@ function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSaniti } function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoFormattingJSONOptions = {}): Video { + const span = tracer.startSpan('peertube.VideoModel.toFormattedJSON') + const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined const videoObject: Video = { @@ -168,10 +171,14 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm videoObject.files = videoFilesModelToFormattedJSON(video, video.VideoFiles) } + span.end() + return videoObject } function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails { + const span = tracer.startSpan('peertube.VideoModel.toFormattedDetailsJSON') + const videoJSON = video.toFormattedJSON({ additionalAttributes: { scheduledUpdate: true, @@ -199,6 +206,8 @@ function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): Vid trackerUrls: video.getTrackerUrls() } + span.end() + return Object.assign(videoJSON, detailsJSON) } diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 924f12a5e..7e9bb4db4 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -27,6 +27,7 @@ import { import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' import { LiveManager } from '@server/lib/live/live-manager' import { removeHLSFileObjectStorage, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' +import { tracer } from '@server/lib/opentelemetry/tracing' import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' import { VideoPathManager } from '@server/lib/video-path-manager' import { getServerActor } from '@server/models/application/application' @@ -1535,6 +1536,8 @@ export class VideoModel extends Model>> { options: BuildVideosListQueryOptions, countVideos = true ): Promise> { + const span = tracer.startSpan('peertube.VideoModel.getAvailableForApi') + function getCount () { if (countVideos !== true) return Promise.resolve(undefined) @@ -1554,6 +1557,8 @@ export class VideoModel extends Model>> { const [ count, rows ] = await Promise.all([ getCount(), getModels() ]) + span.end() + return { data: rows, total: count -- cgit v1.2.3