Skip to content

Commit

Permalink
fix: custom trace spans (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenos authored Sep 16, 2024
1 parent 1abf34e commit 53cbaa7
Show file tree
Hide file tree
Showing 30 changed files with 2,173 additions and 1,963 deletions.
2,490 changes: 1,171 additions & 1,319 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "supa-storage",
"version": "0.9.5",
"description": "Supabase storage middleend",
"version": "1.11.2",
"description": "Supabase Storage Service",
"main": "index.js",
"scripts": {
"dev": "tsx watch src/start/server.ts | pino-pretty",
Expand Down Expand Up @@ -32,16 +32,15 @@
"@fastify/multipart": "^8.3.0",
"@fastify/rate-limit": "^7.6.0",
"@fastify/swagger": "^8.3.1",
"@fastify/swagger-ui": "^1.7.0",
"@fastify/swagger-ui": "^4.1.0",
"@isaacs/ttlcache": "^1.4.1",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/auto-instrumentations-node": "^0.46.1",
"@opentelemetry/instrumentation-aws-sdk": "^0.41.0",
"@opentelemetry/instrumentation-fastify": "^0.36.1",
"@opentelemetry/instrumentation-http": "^0.51.1",
"@opentelemetry/instrumentation-knex": "^0.36.1",
"@opentelemetry/instrumentation-pg": "^0.41.0",
"@opentelemetry/instrumentation-pino": "^0.39.0",
"@opentelemetry/auto-instrumentations-node": "^0.50.0",
"@opentelemetry/instrumentation-aws-sdk": "^0.44.0",
"@opentelemetry/instrumentation-fastify": "^0.39.0",
"@opentelemetry/instrumentation-http": "^0.53.0",
"@opentelemetry/instrumentation-knex": "^0.40.0",
"@opentelemetry/instrumentation-pg": "^0.44.0",
"@shopify/semaphore": "^3.0.2",
"@smithy/node-http-handler": "^2.3.1",
"@tus/file-store": "1.4.0",
Expand Down
1 change: 0 additions & 1 deletion src/admin-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Registry } from 'prom-client'
const build = (opts: FastifyServerOptions = {}, appInstance?: FastifyInstance): FastifyInstance => {
const app = fastify(opts)
app.register(plugins.adminTenantId)
app.register(plugins.logTenantId)
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health'] }))
app.register(routes.tenants, { prefix: 'tenants' })
app.register(routes.migrations, { prefix: 'migrations' })
Expand Down
2 changes: 0 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const build = (opts: buildOpts = {}): FastifyInstance => {
{ name: 's3', description: 'S3 end-points' },
{ name: 'transformation', description: 'Image transformation' },
{ name: 'resumable', description: 'Resumable Upload end-points' },
{ name: 'deprecated', description: 'Deprecated end-points' },
],
},
})
Expand All @@ -52,7 +51,6 @@ const build = (opts: buildOpts = {}): FastifyInstance => {
app.addSchema(schemas.errorSchema)

app.register(plugins.tenantId)
app.register(plugins.logTenantId)
app.register(plugins.metrics({ enabledEndpoint: !isMultitenant }))
app.register(plugins.tracing)
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health'] }))
Expand Down
21 changes: 12 additions & 9 deletions src/http/plugins/apikey.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import fastifyPlugin from 'fastify-plugin'
import { getConfig } from '../../config'

export default fastifyPlugin(async (fastify) => {
const { adminApiKeys } = getConfig()
const apiKeys = new Set(adminApiKeys.split(','))
fastify.addHook('onRequest', async (request, reply) => {
if (typeof request.headers.apikey !== 'string' || !apiKeys.has(request.headers.apikey)) {
reply.status(401).send()
}
})
})
export default fastifyPlugin(
async (fastify) => {
const { adminApiKeys } = getConfig()
const apiKeys = new Set(adminApiKeys.split(','))
fastify.addHook('onRequest', async (request, reply) => {
if (typeof request.headers.apikey !== 'string' || !apiKeys.has(request.headers.apikey)) {
reply.status(401).send()
}
})
},
{ name: 'auth-admin-api-key' }
)
Loading

0 comments on commit 53cbaa7

Please sign in to comment.