mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(api): metrics for Spotify API http requests
This will help evaluate how much we are being rate limited, and on what routes it happens most.
This commit is contained in:
parent
85c31705ef
commit
41dfae3c50
7 changed files with 229 additions and 3 deletions
49
src/open-telemetry/url-value-parser.service.spec.ts
Normal file
49
src/open-telemetry/url-value-parser.service.spec.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { UrlValueParserService } from "./url-value-parser.service";
|
||||
|
||||
describe("UrlValueParserService", () => {
|
||||
let service: UrlValueParserService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UrlValueParserService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UrlValueParserService>(UrlValueParserService);
|
||||
});
|
||||
|
||||
it("should be defined", () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
describe("replacePathValues", () => {
|
||||
it("works with default replacement", () => {
|
||||
const replaced = service.replacePathValues(
|
||||
"/in/world/14/userId/abca12d231"
|
||||
);
|
||||
expect(replaced).toBe("/in/world/#val/userId/#val");
|
||||
});
|
||||
|
||||
it("works with custom replacement", () => {
|
||||
const replaced = service.replacePathValues(
|
||||
"/in/world/14/userId/abca12d231",
|
||||
"<id>"
|
||||
);
|
||||
expect(replaced).toBe("/in/world/<id>/userId/<id>");
|
||||
});
|
||||
|
||||
it("works with negative decimal numbers", () => {
|
||||
const replaced = service.replacePathValues(
|
||||
"/some/path/-154/userId/-ABC363AFE2"
|
||||
);
|
||||
expect(replaced).toBe("/some/path/#val/userId/-ABC363AFE2");
|
||||
});
|
||||
|
||||
it("works with spotify ids", () => {
|
||||
const replaced = service.replacePathValues(
|
||||
"/v1/albums/2PzfMWIpq6JKucGhkS1X5M"
|
||||
);
|
||||
expect(replaced).toBe("/v1/albums/#val");
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue