From 1b67872402582e3378af38afed6659f6510ceaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Sun, 17 Sep 2023 01:53:56 +0200 Subject: [PATCH] feat(spotify): add userId to crawling traces --- src/sources/spotify/spotify.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sources/spotify/spotify.service.ts b/src/sources/spotify/spotify.service.ts index dbb309b..66fee99 100644 --- a/src/sources/spotify/spotify.service.ts +++ b/src/sources/spotify/spotify.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from "@nestjs/common"; import { chunk, uniq } from "lodash"; -import { Span } from "nestjs-otel"; +import { Span, TraceService } from "nestjs-otel"; import type { Job } from "pg-boss"; import { ListensService } from "../../listens/listens.service"; import { Album } from "../../music-library/album.entity"; @@ -40,6 +40,7 @@ export class SpotifyService { private readonly musicLibraryService: MusicLibraryService, private readonly spotifyApi: SpotifyApiService, private readonly spotifyAuth: SpotifyAuthService, + private readonly traceService: TraceService, ) {} @Span() @@ -89,6 +90,7 @@ export class SpotifyService { retryOnExpiredToken: boolean = true, ): Promise { this.logger.debug({ userId: user.id }, `Crawling recently played tracks`); + this.traceService.getSpan().setAttribute("userId", user.id); let playHistory: PlayHistoryObject[]; try {