File tree Expand file tree Collapse file tree
apps/supervisor/src/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { SimpleStructuredLogger } from "@trigger.dev/core/v3/utils/structuredLogger" ;
2+ import { buildOtlpTracePayload , type OtlpTraceOptions } from "../otlpPayload.js" ;
3+
4+ export type OtlpTraceServiceOptions = {
5+ endpointUrl : string ;
6+ timeoutMs ?: number ;
7+ } ;
8+
9+ export class OtlpTraceService {
10+ private readonly logger = new SimpleStructuredLogger ( "otlp-trace" ) ;
11+
12+ constructor ( private opts : OtlpTraceServiceOptions ) { }
13+
14+ /** Fire-and-forget: build payload and send to the configured OTLP endpoint */
15+ emit ( opts : OtlpTraceOptions ) : void {
16+ const payload = buildOtlpTracePayload ( opts ) ;
17+
18+ fetch ( `${ this . opts . endpointUrl } /v1/traces` , {
19+ method : "POST" ,
20+ headers : { "Content-Type" : "application/json" } ,
21+ body : JSON . stringify ( payload ) ,
22+ signal : AbortSignal . timeout ( this . opts . timeoutMs ?? 5_000 ) ,
23+ } ) . catch ( ( err ) => {
24+ this . logger . warn ( "failed to send compute trace span" , {
25+ error : err instanceof Error ? err . message : String ( err ) ,
26+ } ) ;
27+ } ) ;
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments