File tree 7 files changed +98
-4
lines changed
7 files changed +98
-4
lines changed Original file line number Diff line number Diff line change
1
+ name : CI
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ tags :
8
+ - ' **'
9
+ pull_request : {}
10
+
11
+ env :
12
+ COLUMNS : 150
13
+
14
+ jobs :
15
+ lint :
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - uses : actions/checkout@v4
19
+ with :
20
+ submodules : ' true'
21
+
22
+ - uses : actions/setup-node@v4
23
+
24
+ - run : npm install
25
+ - run : ./gen_proto.sh
26
+
27
+ - uses : pre-commit/action@v3.0.1
28
+ with :
29
+ extra_args : --all-files
30
+
31
+ - uses : cloudflare/wrangler-action@v3
32
+ with :
33
+ command : deploy --dry-run --var GITHUB_SHA:${{ github.sha }}
34
+
35
+ deploy :
36
+ if : " success() && github.ref == 'refs/heads/main'"
37
+ runs-on : ubuntu-latest
38
+ needs : [lint]
39
+ environment : cloudflare-workers-deploy
40
+
41
+ steps :
42
+ - uses : actions/checkout@v4
43
+
44
+ - uses : actions/setup-node@v4
45
+
46
+ - run : npm install
47
+ - run : ./gen_proto.sh
48
+
49
+ - uses : cloudflare/wrangler-action@v3
50
+ with :
51
+ apiToken : ${{ secrets.cloudflare_api_token }}
52
+ command : deploy --var GITHUB_SHA:${{ github.sha }}
Original file line number Diff line number Diff line change
1
+ repos :
2
+ - repo : https://github.com/pre-commit/pre-commit-hooks
3
+ rev : v4.3.0
4
+ hooks :
5
+ - id : check-yaml
6
+ - id : check-toml
7
+ - id : end-of-file-fixer
8
+ - id : trailing-whitespace
9
+ - id : check-added-large-files
10
+
11
+ - repo : local
12
+ hooks :
13
+ - id : format
14
+ name : Format
15
+ entry : npm run format
16
+ types : [ts]
17
+ language : system
18
+ pass_filenames : false
19
+ - id : lint
20
+ name : Lint
21
+ entry : npm run lint
22
+ types : [ts]
23
+ language : system
24
+ pass_filenames : false
25
+ - id : typecheck
26
+ name : Typecheck
27
+ entry : npm run typecheck
28
+ types : [ts]
29
+ language : system
30
+ pass_filenames : false
File renamed without changes.
Original file line number Diff line number Diff line change 5
5
"scripts" : {
6
6
"format" : " prettier --write -- ." ,
7
7
"lint" : " prettier --check -- ." ,
8
- "gen_proto" : " ./gen_proto.sh" ,
9
- "typecheck" : " npm run --workspaces typecheck" ,
8
+ "typecheck" : " tsc --noEmit" ,
10
9
"dev" : " wrangler dev" ,
11
10
"cf-typegen" : " wrangler types"
12
11
},
Original file line number Diff line number Diff line change 1
1
import { convert , encodeTraces , decodeLogs } from './otel'
2
2
3
+ export interface Env {
4
+ GITHUB_SHA : string
5
+ }
6
+
3
7
export default {
4
8
async fetch ( request , env , ctx ) : Promise < Response > {
5
9
// console.log(Object.fromEntries(request.headers))
10
+ const { pathname } = new URL ( request . url )
11
+ if ( request . method === 'GET' && pathname === '/' ) {
12
+ return new Response ( `See https://github.com/pydantic/logfire-logs-proxy for details (commit ${ env . GITHUB_SHA } .` )
13
+ } else if ( pathname !== '/v1/logs' || request . method !== 'POST' ) {
14
+ return new Response ( 'Only POST requests to `/v1/logs` are supported' , { status : 404 } )
15
+ }
6
16
7
17
const auth = request . headers . get ( 'Authorization' )
8
18
if ( ! auth ) {
@@ -36,7 +46,7 @@ export default {
36
46
method : 'POST' ,
37
47
headers : {
38
48
'Content-Type' : 'application/x-protobuf' ,
39
- ' Authorization' : auth ,
49
+ Authorization : auth ,
40
50
'User-Agent' : `logfire-logs-proxy ${ request . headers . get ( 'User-Agent' ) } ` ,
41
51
} ,
42
52
body : encodeTraces ( traceRequest ) ,
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ function mapLogRecord(logRecord: ILogRecord): ISpan {
85
85
attributes . push ( { key : 'log_body' , value : logRecord . body } )
86
86
}
87
87
}
88
- let { traceId, spanId} = logRecord
88
+ let { traceId, spanId } = logRecord
89
89
if ( ! traceId || traceId . length === 0 ) {
90
90
traceId = generateRand ( 16 )
91
91
}
Original file line number Diff line number Diff line change @@ -2,3 +2,6 @@ name = "logfire-logs-proxy"
2
2
main = " src/index.ts"
3
3
compatibility_date = " 2024-12-24"
4
4
compatibility_flags = [" nodejs_compat" ]
5
+
6
+ [vars ]
7
+ GITHUB_SHA = " unknown"
You can’t perform that action at this time.
0 commit comments