Skip to content

Commit 2f47edf

Browse files
feat: enhance Web Vitals telemetry with semantic attributes (#316)
1 parent ada1707 commit 2f47edf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sdk/highlight-run/src/sdk/observe.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import randomUuidV4 from '../client/utils/randomUuidV4'
7878
import { recordException } from '../client/otel/recordException'
7979
import { ObserveOptions } from '../client/types/observe'
8080
import { isMetricSafeNumber } from '../client/utils/utils'
81+
import * as SemanticAttributes from '@opentelemetry/semantic-conventions'
8182

8283
export class ObserveSDK implements Observe {
8384
/** Verbose project ID that is exposed to users. Legacy users may still be using ints. */
@@ -583,12 +584,16 @@ export class ObserveSDK implements Observe {
583584
)
584585
WebVitalsListener((data) => {
585586
const { name, value } = data
587+
const { hostname, pathname, href } = window.location
586588
this.recordGauge({
587589
name,
588590
value,
589591
attributes: {
590-
group: window.location.href,
592+
group: window.location.pathname,
591593
category: MetricCategory.WebVital,
594+
[SemanticAttributes.ATTR_URL_FULL]: href,
595+
[SemanticAttributes.ATTR_URL_PATH]: pathname,
596+
[SemanticAttributes.ATTR_SERVER_ADDRESS]: hostname,
592597
},
593598
})
594599
})

0 commit comments

Comments
 (0)