Skip to content

Commit

Permalink
🔧 fix: support bun build --minify-identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Aug 19, 2024
1 parent 2a31c88 commit 7fded7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.3 - 19 Aug 2024
Bug fix:
- Support bun build --minify-identifiers

# 1.1.2 - 4 Aug 2024
Bug fix:
- Check nullability of rootSpan
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elysiajs/opentelemetry",
"version": "1.1.2",
"version": "1.1.3",
"license": "MIT",
"scripts": {
"dev": "bun run --watch example/index.ts",
Expand Down
20 changes: 8 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
type SpanOptions,
type Span,
type Attributes,
TraceAPI
TraceAPI,
ProxyTracer
} from '@opentelemetry/api'

import { NodeSDK } from '@opentelemetry/sdk-node'
Expand Down Expand Up @@ -197,11 +198,7 @@ export const opentelemetry = ({
}: ElysiaOpenTelemetryOptions = {}) => {
let tracer = trace.getTracer(serviceName)

const isInitialized = !(
'_getTracer' in tracer &&
// @ts-expect-error
tracer._getTracer()?.constructor?.name === 'NoopTracer'
)
const isInitialized = tracer instanceof ProxyTracer

if (!isInitialized) {
if (!instrumentations)
Expand Down Expand Up @@ -285,7 +282,7 @@ export const opentelemetry = ({
}
}) => {
const rootSpan = trace.getActiveSpan()!
if(!rootSpan) return
if (!rootSpan) return

let parent = rootSpan

Expand Down Expand Up @@ -364,7 +361,7 @@ export const opentelemetry = ({
)
})

onStop(({ error }) => {
onStop(() => {
if (event.isRecording()) event.end()
// console.log(`[${name}]: end`)
})
Expand All @@ -377,8 +374,8 @@ export const opentelemetry = ({
context.trace = {
startSpan(
name: string,
options?: SpanOptions,
context?: Context
// options?: SpanOptions,
// context?: Context
) {
return tracer.startSpan(name, {}, createContext(parent))
},
Expand Down Expand Up @@ -493,8 +490,7 @@ export const opentelemetry = ({
response
} = context

if (context.route)
attributes['http.route'] = context.route
if (context.route) attributes['http.route'] = context.route

switch (typeof response) {
case 'object':
Expand Down

0 comments on commit 7fded7f

Please sign in to comment.