Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom trace spans #547

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 All @@ -17,8 +16,8 @@
app.get('/metrics', async (req, reply) => {
if (registriesToMerge.length === 0) {
const globalRegistry = appInstance.metrics.client.register
const defaultRegistries = (appInstance.metrics as any).getCustomDefaultMetricsRegistries()

Check warning on line 19 in src/admin-app.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type
const routeRegistries = (appInstance.metrics as any).getCustomRouteMetricsRegistries()

Check warning on line 20 in src/admin-app.ts

View workflow job for this annotation

GitHub Actions / Test / OS ubuntu-20.04 / Node 20

Unexpected any. Specify a different type

registriesToMerge = Array.from(
new Set([globalRegistry, ...defaultRegistries, ...routeRegistries])
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
Loading