diff options
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | server/lib/opentelemetry/tracing.ts | 4 | ||||
-rw-r--r-- | server/models/video/formatter/video-format-utils.ts | 9 | ||||
-rw-r--r-- | server/models/video/video.ts | 5 | ||||
-rw-r--r-- | yarn.lock | 11 |
5 files changed, 28 insertions, 2 deletions
diff --git a/package.json b/package.json index 16c9c4c0f..db433bfc2 100644 --- a/package.json +++ b/package.json | |||
@@ -149,6 +149,7 @@ | |||
149 | "multer": "^1.4.5-lts.1", | 149 | "multer": "^1.4.5-lts.1", |
150 | "node-media-server": "^2.1.4", | 150 | "node-media-server": "^2.1.4", |
151 | "nodemailer": "^6.0.0", | 151 | "nodemailer": "^6.0.0", |
152 | "opentelemetry-instrumentation-sequelize": "^0.29.0", | ||
152 | "parse-torrent": "^9.1.0", | 153 | "parse-torrent": "^9.1.0", |
153 | "password-generator": "^2.0.2", | 154 | "password-generator": "^2.0.2", |
154 | "pg": "^8.2.1", | 155 | "pg": "^8.2.1", |
diff --git a/server/lib/opentelemetry/tracing.ts b/server/lib/opentelemetry/tracing.ts index 23764e9e4..252a3b664 100644 --- a/server/lib/opentelemetry/tracing.ts +++ b/server/lib/opentelemetry/tracing.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { SequelizeInstrumentation } from 'opentelemetry-instrumentation-sequelize' | ||
1 | import { diag, DiagLogLevel, trace } from '@opentelemetry/api' | 2 | import { diag, DiagLogLevel, trace } from '@opentelemetry/api' |
2 | import { JaegerExporter } from '@opentelemetry/exporter-jaeger' | 3 | import { JaegerExporter } from '@opentelemetry/exporter-jaeger' |
3 | import { registerInstrumentations } from '@opentelemetry/instrumentation' | 4 | import { registerInstrumentations } from '@opentelemetry/instrumentation' |
@@ -60,7 +61,8 @@ function registerOpentelemetryTracing () { | |||
60 | return [ cmdName, ...cmdArgs ].join(' ') | 61 | return [ cmdName, ...cmdArgs ].join(' ') |
61 | } | 62 | } |
62 | }), | 63 | }), |
63 | new FsInstrumentation() | 64 | new FsInstrumentation(), |
65 | new SequelizeInstrumentation() | ||
64 | ] | 66 | ] |
65 | }) | 67 | }) |
66 | 68 | ||
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 @@ | |||
1 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 1 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
2 | import { getActivityStreamDuration } from '@server/lib/activitypub/activity' | 2 | import { getActivityStreamDuration } from '@server/lib/activitypub/activity' |
3 | import { tracer } from '@server/lib/opentelemetry/tracing' | ||
3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' | 4 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' |
4 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' | 5 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' |
5 | import { uuidToShort } from '@shared/extra-utils' | 6 | import { uuidToShort } from '@shared/extra-utils' |
@@ -71,6 +72,8 @@ function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSaniti | |||
71 | } | 72 | } |
72 | 73 | ||
73 | function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoFormattingJSONOptions = {}): Video { | 74 | function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoFormattingJSONOptions = {}): Video { |
75 | const span = tracer.startSpan('peertube.VideoModel.toFormattedJSON') | ||
76 | |||
74 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined | 77 | const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined |
75 | 78 | ||
76 | const videoObject: Video = { | 79 | const videoObject: Video = { |
@@ -168,10 +171,14 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm | |||
168 | videoObject.files = videoFilesModelToFormattedJSON(video, video.VideoFiles) | 171 | videoObject.files = videoFilesModelToFormattedJSON(video, video.VideoFiles) |
169 | } | 172 | } |
170 | 173 | ||
174 | span.end() | ||
175 | |||
171 | return videoObject | 176 | return videoObject |
172 | } | 177 | } |
173 | 178 | ||
174 | function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails { | 179 | function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails { |
180 | const span = tracer.startSpan('peertube.VideoModel.toFormattedDetailsJSON') | ||
181 | |||
175 | const videoJSON = video.toFormattedJSON({ | 182 | const videoJSON = video.toFormattedJSON({ |
176 | additionalAttributes: { | 183 | additionalAttributes: { |
177 | scheduledUpdate: true, | 184 | scheduledUpdate: true, |
@@ -199,6 +206,8 @@ function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): Vid | |||
199 | trackerUrls: video.getTrackerUrls() | 206 | trackerUrls: video.getTrackerUrls() |
200 | } | 207 | } |
201 | 208 | ||
209 | span.end() | ||
210 | |||
202 | return Object.assign(videoJSON, detailsJSON) | 211 | return Object.assign(videoJSON, detailsJSON) |
203 | } | 212 | } |
204 | 213 | ||
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 { | |||
27 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' | 27 | import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' |
28 | import { LiveManager } from '@server/lib/live/live-manager' | 28 | import { LiveManager } from '@server/lib/live/live-manager' |
29 | import { removeHLSFileObjectStorage, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' | 29 | import { removeHLSFileObjectStorage, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' |
30 | import { tracer } from '@server/lib/opentelemetry/tracing' | ||
30 | import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' | 31 | import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' |
31 | import { VideoPathManager } from '@server/lib/video-path-manager' | 32 | import { VideoPathManager } from '@server/lib/video-path-manager' |
32 | import { getServerActor } from '@server/models/application/application' | 33 | import { getServerActor } from '@server/models/application/application' |
@@ -1535,6 +1536,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1535 | options: BuildVideosListQueryOptions, | 1536 | options: BuildVideosListQueryOptions, |
1536 | countVideos = true | 1537 | countVideos = true |
1537 | ): Promise<ResultList<VideoModel>> { | 1538 | ): Promise<ResultList<VideoModel>> { |
1539 | const span = tracer.startSpan('peertube.VideoModel.getAvailableForApi') | ||
1540 | |||
1538 | function getCount () { | 1541 | function getCount () { |
1539 | if (countVideos !== true) return Promise.resolve(undefined) | 1542 | if (countVideos !== true) return Promise.resolve(undefined) |
1540 | 1543 | ||
@@ -1554,6 +1557,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1554 | 1557 | ||
1555 | const [ count, rows ] = await Promise.all([ getCount(), getModels() ]) | 1558 | const [ count, rows ] = await Promise.all([ getCount(), getModels() ]) |
1556 | 1559 | ||
1560 | span.end() | ||
1561 | |||
1557 | return { | 1562 | return { |
1558 | data: rows, | 1563 | data: rows, |
1559 | total: count | 1564 | total: count |
@@ -1732,7 +1732,7 @@ | |||
1732 | semver "^7.3.2" | 1732 | semver "^7.3.2" |
1733 | shimmer "^1.2.1" | 1733 | shimmer "^1.2.1" |
1734 | 1734 | ||
1735 | "@opentelemetry/instrumentation@^0.29.2": | 1735 | "@opentelemetry/instrumentation@^0.29.0", "@opentelemetry/instrumentation@^0.29.2": |
1736 | version "0.29.2" | 1736 | version "0.29.2" |
1737 | resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.29.2.tgz#70e6d4e1a84508f5e9d8c7c426adcd7b0dba6c95" | 1737 | resolved "https://registry.yarnpkg.com/@opentelemetry/instrumentation/-/instrumentation-0.29.2.tgz#70e6d4e1a84508f5e9d8c7c426adcd7b0dba6c95" |
1738 | integrity sha512-LXx5V0ONNATQFCE8C5uqnxWSm4rcXLssdLHdXjtGdxRmURqj/JO8jYefqXCD0LzsqEQ6yxOx2GZ0dgXvhBVdTw== | 1738 | integrity sha512-LXx5V0ONNATQFCE8C5uqnxWSm4rcXLssdLHdXjtGdxRmURqj/JO8jYefqXCD0LzsqEQ6yxOx2GZ0dgXvhBVdTw== |
@@ -7027,6 +7027,15 @@ open@7: | |||
7027 | is-docker "^2.0.0" | 7027 | is-docker "^2.0.0" |
7028 | is-wsl "^2.1.1" | 7028 | is-wsl "^2.1.1" |
7029 | 7029 | ||
7030 | opentelemetry-instrumentation-sequelize@^0.29.0: | ||
7031 | version "0.29.0" | ||
7032 | resolved "https://registry.yarnpkg.com/opentelemetry-instrumentation-sequelize/-/opentelemetry-instrumentation-sequelize-0.29.0.tgz#d8355b7c845473b3d66978b80620dba6f686e257" | ||
7033 | integrity sha512-nBhWMhpOtFxR0+W9WwTC+g49UMPqDMusbceGycDJOaq9l7B/IGo8a15UHKm4N4uU/Cr1NTrvyJ0cFXUtSh7i3g== | ||
7034 | dependencies: | ||
7035 | "@opentelemetry/core" "^1.0.0" | ||
7036 | "@opentelemetry/instrumentation" "^0.29.0" | ||
7037 | "@opentelemetry/semantic-conventions" "^1.0.0" | ||
7038 | |||
7030 | opentracing@^0.14.4: | 7039 | opentracing@^0.14.4: |
7031 | version "0.14.7" | 7040 | version "0.14.7" |
7032 | resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.7.tgz#25d472bd0296dc0b64d7b94cbc995219031428f5" | 7041 | resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.7.tgz#25d472bd0296dc0b64d7b94cbc995219031428f5" |