Skip to content

Commit e8911e9

Browse files
committed
add jobuuid label and bump to v6
1 parent f015c7b commit e8911e9

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

dist/index.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { DEFAULT_AGGREGATION_SELECTOR } from '@opentelemetry/sdk-metrics/build/s
3434
import { InstrumentType } from '@opentelemetry/sdk-metrics/build/src/export/MetricData.js'
3535

3636
import { AggregationType, ViewOptions } from '@opentelemetry/sdk-metrics'
37+
import { randomUUID } from 'crypto'
3738
class CapturingDiagLogger implements DiagLogger {
3839
private baseLogger: DiagConsoleLogger
3940
private capturedOutput: string = ''
@@ -99,7 +100,7 @@ export async function run(): Promise<void> {
99100

100101
const metricsNamespace = core.getInput('metrics-namespace') || 'cae'
101102

102-
const metricsVersion = core.getInput('metrics-version') || 'v5'
103+
const metricsVersion = core.getInput('metrics-version') || 'v6'
103104

104105
const config: TMetricsConfig = {
105106
serviceName,
@@ -109,7 +110,8 @@ export async function run(): Promise<void> {
109110
repository: `${github.context.repo.owner}/${github.context.repo.repo}`,
110111
branch: github.context.ref.replace('refs/heads/', ''),
111112
commitSha: github.context.sha,
112-
buildId: github.context.runId.toString()
113+
runId: github.context.runId.toString(),
114+
jobUUID: randomUUID()
113115
}
114116

115117
core.info(`🔧 Configuring OpenTelemetry CI Visibility`)

src/metrics-generator.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ describe('generateMetrics', () => {
99
repository: 'test/repo',
1010
branch: 'main',
1111
commitSha: 'abc123',
12-
buildId: 'build-456'
12+
runId: 'build-456',
13+
jobUUID: 'job-456'
1314
}
1415

1516
const createTest = (overrides: Partial<TTest> = {}): TTest => ({
@@ -254,7 +255,8 @@ describe('generateMetrics', () => {
254255
repository: undefined,
255256
branch: undefined,
256257
commitSha: undefined,
257-
buildId: undefined
258+
runId: undefined,
259+
jobUUID: undefined
258260
})
259261

260262
expect(metrics.length).toBeGreaterThan(0)

src/metrics-generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export interface TMetricsConfig {
88
readonly repository: string | undefined
99
readonly branch: string | undefined
1010
readonly commitSha: string | undefined
11-
readonly buildId: string | undefined
11+
readonly runId: string | undefined
12+
readonly jobUUID: string | undefined
1213
}
1314

1415
export interface TMetricDataPoint {
@@ -185,7 +186,7 @@ const getBaseAttributes = (
185186
if (config.branch) attributes['vcs.repository.ref.name'] = config.branch
186187
if (config.commitSha)
187188
attributes['vcs.repository.ref.revision'] = config.commitSha
188-
if (config.buildId) attributes['ci.build.id'] = config.buildId
189+
if (config.runId) attributes['ci.build.id'] = config.runId
189190

190191
return attributes
191192
}

src/metrics-submitter.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ describe('MetricsSubmitter', () => {
8282
repository: undefined,
8383
branch: undefined,
8484
commitSha: undefined,
85-
buildId: undefined
85+
runId: undefined,
86+
jobUUID: undefined
8687
}
8788

8889
const createDataPoint = (

0 commit comments

Comments
 (0)