1+ import { type IOPacket } from "@trigger.dev/core/v3" ;
12import { env } from "~/env.server" ;
2- import { AuthenticatedEnvironment } from "~/services/apiAuth.server" ;
3+ import { type AuthenticatedEnvironment } from "~/services/apiAuth.server" ;
34import { logger } from "~/services/logger.server" ;
45import { singleton } from "~/utils/singleton" ;
5- import { tracer } from "~/v3/tracer.server" ;
6- import { startSpan } from "~/v3/tracing.server" ;
7- import { IOPacket } from "@trigger.dev/core/v3" ;
86import { ObjectStoreClient , type ObjectStoreClientConfig } from "./objectStoreClient.server" ;
97
108/**
@@ -129,30 +127,21 @@ export async function uploadPacketToObjectStore(
129127 environment : AuthenticatedEnvironment ,
130128 storageProtocol ?: string
131129) : Promise < string > {
132- return await startSpan ( tracer , "uploadPacketToObjectStore()" , async ( span ) => {
133- const protocol = storageProtocol || env . OBJECT_STORE_DEFAULT_PROTOCOL ;
134- const client = getObjectStoreClient ( protocol ) ;
130+ const protocol = storageProtocol || env . OBJECT_STORE_DEFAULT_PROTOCOL ;
131+ const client = getObjectStoreClient ( protocol ) ;
135132
136- if ( ! client ) {
137- throw new Error ( `Object store is not configured for protocol: ${ protocol || "default" } ` ) ;
138- }
139-
140- span . setAttributes ( {
141- projectRef : environment . project . externalRef ,
142- environmentSlug : environment . slug ,
143- filename,
144- protocol : protocol || "default" ,
145- } ) ;
133+ if ( ! client ) {
134+ throw new Error ( `Object store is not configured for protocol: ${ protocol || "default" } ` ) ;
135+ }
146136
147- const key = `packets/${ environment . project . externalRef } /${ environment . slug } /${ filename } ` ;
137+ const key = `packets/${ environment . project . externalRef } /${ environment . slug } /${ filename } ` ;
148138
149- logger . debug ( "Uploading to object store" , { key, protocol : protocol || "default" } ) ;
139+ logger . debug ( "Uploading to object store" , { key, protocol : protocol || "default" } ) ;
150140
151- await client . putObject ( key , data , contentType ) ;
141+ await client . putObject ( key , data , contentType ) ;
152142
153- // Return filename with protocol prefix if specified
154- return formatStorageUri ( filename , protocol ) ;
155- } ) ;
143+ // Return filename with protocol prefix if specified
144+ return formatStorageUri ( filename , protocol ) ;
156145}
157146
158147export async function downloadPacketFromObjectStore (
@@ -163,38 +152,29 @@ export async function downloadPacketFromObjectStore(
163152 return packet ;
164153 }
165154
166- return await startSpan ( tracer , "downloadPacketFromObjectStore()" , async ( span ) => {
167- // There shouldn't be an offloaded packet with undefined data…
168- if ( ! packet . data ) {
169- logger . error ( "Object store packet has undefined data" , { packet, environment } ) ;
170- return {
171- dataType : "application/json" ,
172- data : undefined ,
173- } ;
174- }
175-
176- const { protocol, path } = parseStorageUri ( packet . data ) ;
177- const client = getObjectStoreClient ( protocol ) ;
155+ // There shouldn't be an offloaded packet with undefined data…
156+ if ( ! packet . data ) {
157+ logger . error ( "Object store packet has undefined data" , { packet, environment } ) ;
158+ return {
159+ dataType : "application/json" ,
160+ data : undefined ,
161+ } ;
162+ }
178163
179- if ( ! client ) {
180- throw new Error ( `Object store is not configured for protocol: ${ protocol || "default" } ` ) ;
181- }
164+ const { protocol, path } = parseStorageUri ( packet . data ) ;
165+ const client = getObjectStoreClient ( protocol ) ;
182166
183- span . setAttributes ( {
184- projectRef : environment . project . externalRef ,
185- environmentSlug : environment . slug ,
186- filename : packet . data ,
187- protocol : protocol || "default" ,
188- } ) ;
167+ if ( ! client ) {
168+ throw new Error ( `Object store is not configured for protocol: ${ protocol || "default" } ` ) ;
169+ }
189170
190- const key = `packets/${ environment . project . externalRef } /${ environment . slug } /${ path } ` ;
171+ const key = `packets/${ environment . project . externalRef } /${ environment . slug } /${ path } ` ;
191172
192- logger . debug ( "Downloading from object store" , { key, protocol : protocol || "default" } ) ;
173+ logger . debug ( "Downloading from object store" , { key, protocol : protocol || "default" } ) ;
193174
194- const data = await client . getObject ( key ) ;
175+ const data = await client . getObject ( key ) ;
195176
196- return { data, dataType : "application/json" } ;
197- } ) ;
177+ return { data, dataType : "application/json" } ;
198178}
199179
200180export type GeneratePacketPresignOptions = {
0 commit comments