Debian Codegraph @

semconv/v1.34.0/vcsconv/metric.go

raw
1 // Code generated from semantic convention specification. DO NOT EDIT.
2
3 // Copyright The OpenTelemetry Authors
4 // SPDX-License-Identifier: Apache-2.0
5
6 // Package vcsconv provides types and functionality for OpenTelemetry semantic
7 // conventions in the "vcs" namespace.
8 package vcsconv
9
10 import (
11 "context"
12 "sync"
13
14 "go.opentelemetry.io/otel/attribute"
15 "go.opentelemetry.io/otel/metric"
16 "go.opentelemetry.io/otel/metric/noop"
17 )
18
19 var (
20 addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
21 recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
22 )
23
24 // ChangeStateAttr is an attribute conforming to the vcs.change.state semantic
25 // conventions. It represents the state of the change (pull request/merge
26 // request/changelist).
27 type ChangeStateAttr string
28
29 var (
30 // ChangeStateOpen is the open means the change is currently active and under
31 // review. It hasn't been merged into the target branch yet, and it's still
32 // possible to make changes or add comments.
33 ChangeStateOpen ChangeStateAttr = "open"
34 // ChangeStateWip is the WIP (work-in-progress, draft) means the change is still
35 // in progress and not yet ready for a full review. It might still undergo
36 // significant changes.
37 ChangeStateWip ChangeStateAttr = "wip"
38 // ChangeStateClosed is the closed means the merge request has been closed
39 // without merging. This can happen for various reasons, such as the changes
40 // being deemed unnecessary, the issue being resolved in another way, or the
41 // author deciding to withdraw the request.
42 ChangeStateClosed ChangeStateAttr = "closed"
43 // ChangeStateMerged is the merged indicates that the change has been
44 // successfully integrated into the target codebase.
45 ChangeStateMerged ChangeStateAttr = "merged"
46 )
47
48 // LineChangeTypeAttr is an attribute conforming to the vcs.line_change.type
49 // semantic conventions. It represents the type of line change being measured on
50 // a branch or change.
51 type LineChangeTypeAttr string
52
53 var (
54 // LineChangeTypeAdded is the how many lines were added.
55 LineChangeTypeAdded LineChangeTypeAttr = "added"
56 // LineChangeTypeRemoved is the how many lines were removed.
57 LineChangeTypeRemoved LineChangeTypeAttr = "removed"
58 )
59
60 // ProviderNameAttr is an attribute conforming to the vcs.provider.name semantic
61 // conventions. It represents the name of the version control system provider.
62 type ProviderNameAttr string
63
64 var (
65 // ProviderNameGithub is the [GitHub].
66 //
67 // [GitHub]: https://github.com
68 ProviderNameGithub ProviderNameAttr = "github"
69 // ProviderNameGitlab is the [GitLab].
70 //
71 // [GitLab]: https://gitlab.com
72 ProviderNameGitlab ProviderNameAttr = "gitlab"
73 // ProviderNameGitea is the [Gitea].
74 //
75 // [Gitea]: https://gitea.io
76 ProviderNameGitea ProviderNameAttr = "gitea"
77 // ProviderNameBitbucket is the [Bitbucket].
78 //
79 // [Bitbucket]: https://bitbucket.org
80 ProviderNameBitbucket ProviderNameAttr = "bitbucket"
81 )
82
83 // RefBaseTypeAttr is an attribute conforming to the vcs.ref.base.type semantic
84 // conventions. It represents the type of the [reference] in the repository.
85 //
86 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
87 type RefBaseTypeAttr string
88
89 var (
90 // RefBaseTypeBranch is the [branch].
91 //
92 // [branch]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbranchabranch
93 RefBaseTypeBranch RefBaseTypeAttr = "branch"
94 // RefBaseTypeTag is the [tag].
95 //
96 // [tag]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftagatag
97 RefBaseTypeTag RefBaseTypeAttr = "tag"
98 )
99
100 // RefHeadTypeAttr is an attribute conforming to the vcs.ref.head.type semantic
101 // conventions. It represents the type of the [reference] in the repository.
102 //
103 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
104 type RefHeadTypeAttr string
105
106 var (
107 // RefHeadTypeBranch is the [branch].
108 //
109 // [branch]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbranchabranch
110 RefHeadTypeBranch RefHeadTypeAttr = "branch"
111 // RefHeadTypeTag is the [tag].
112 //
113 // [tag]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftagatag
114 RefHeadTypeTag RefHeadTypeAttr = "tag"
115 )
116
117 // RefTypeAttr is an attribute conforming to the vcs.ref.type semantic
118 // conventions. It represents the type of the [reference] in the repository.
119 //
120 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
121 type RefTypeAttr string
122
123 var (
124 // RefTypeBranch is the [branch].
125 //
126 // [branch]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefbranchabranch
127 RefTypeBranch RefTypeAttr = "branch"
128 // RefTypeTag is the [tag].
129 //
130 // [tag]: https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftagatag
131 RefTypeTag RefTypeAttr = "tag"
132 )
133
134 // RevisionDeltaDirectionAttr is an attribute conforming to the
135 // vcs.revision_delta.direction semantic conventions. It represents the type of
136 // revision comparison.
137 type RevisionDeltaDirectionAttr string
138
139 var (
140 // RevisionDeltaDirectionBehind is the how many revisions the change is behind
141 // the target ref.
142 RevisionDeltaDirectionBehind RevisionDeltaDirectionAttr = "behind"
143 // RevisionDeltaDirectionAhead is the how many revisions the change is ahead of
144 // the target ref.
145 RevisionDeltaDirectionAhead RevisionDeltaDirectionAttr = "ahead"
146 )
147
148 // ChangeCount is an instrument used to record metric values conforming to the
149 // "vcs.change.count" semantic conventions. It represents the number of changes
150 // (pull requests/merge requests/changelists) in a repository, categorized by
151 // their state (e.g. open or merged).
152 type ChangeCount struct {
153 metric.Int64UpDownCounter
154 }
155
156 // NewChangeCount returns a new ChangeCount instrument.
157 func NewChangeCount(
158 m metric.Meter,
159 opt ...metric.Int64UpDownCounterOption,
160 ) (ChangeCount, error) {
161 // Check if the meter is nil.
162 if m == nil {
163 return ChangeCount{noop.Int64UpDownCounter{}}, nil
164 }
165
166 i, err := m.Int64UpDownCounter(
167 "vcs.change.count",
168 append([]metric.Int64UpDownCounterOption{
169 metric.WithDescription("The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged)"),
170 metric.WithUnit("{change}"),
171 }, opt...)...,
172 )
173 if err != nil {
174 return ChangeCount{noop.Int64UpDownCounter{}}, err
175 }
176 return ChangeCount{i}, nil
177 }
178
179 // Inst returns the underlying metric instrument.
180 func (m ChangeCount) Inst() metric.Int64UpDownCounter {
181 return m.Int64UpDownCounter
182 }
183
184 // Name returns the semantic convention name of the instrument.
185 func (ChangeCount) Name() string {
186 return "vcs.change.count"
187 }
188
189 // Unit returns the semantic convention unit of the instrument
190 func (ChangeCount) Unit() string {
191 return "{change}"
192 }
193
194 // Description returns the semantic convention description of the instrument
195 func (ChangeCount) Description() string {
196 return "The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged)"
197 }
198
199 // Add adds incr to the existing count.
200 //
201 // The changeState is the the state of the change (pull request/merge
202 // request/changelist).
203 //
204 // The repositoryUrlFull is the the [canonical URL] of the repository providing
205 // the complete HTTP(S) address in order to locate and identify the repository
206 // through a browser.
207 //
208 // All additional attrs passed are included in the recorded value.
209 //
210 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
211 func (m ChangeCount) Add(
212 ctx context.Context,
213 incr int64,
214 changeState ChangeStateAttr,
215 repositoryUrlFull string,
216 attrs ...attribute.KeyValue,
217 ) {
218 o := addOptPool.Get().(*[]metric.AddOption)
219 defer func() {
220 *o = (*o)[:0]
221 addOptPool.Put(o)
222 }()
223
224 *o = append(
225 *o,
226 metric.WithAttributes(
227 append(
228 attrs,
229 attribute.String("vcs.change.state", string(changeState)),
230 attribute.String("vcs.repository.url.full", repositoryUrlFull),
231 )...,
232 ),
233 )
234
235 m.Int64UpDownCounter.Add(ctx, incr, *o...)
236 }
237
238 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
239 // convention. It represents the group owner within the version control system.
240 func (ChangeCount) AttrOwnerName(val string) attribute.KeyValue {
241 return attribute.String("vcs.owner.name", val)
242 }
243
244 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
245 // semantic convention. It represents the human readable name of the repository.
246 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
247 // or organization in GitHub.
248 func (ChangeCount) AttrRepositoryName(val string) attribute.KeyValue {
249 return attribute.String("vcs.repository.name", val)
250 }
251
252 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
253 // semantic convention. It represents the name of the version control system
254 // provider.
255 func (ChangeCount) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
256 return attribute.String("vcs.provider.name", string(val))
257 }
258
259 // ChangeDuration is an instrument used to record metric values conforming to the
260 // "vcs.change.duration" semantic conventions. It represents the time duration a
261 // change (pull request/merge request/changelist) has been in a given state.
262 type ChangeDuration struct {
263 metric.Float64Gauge
264 }
265
266 // NewChangeDuration returns a new ChangeDuration instrument.
267 func NewChangeDuration(
268 m metric.Meter,
269 opt ...metric.Float64GaugeOption,
270 ) (ChangeDuration, error) {
271 // Check if the meter is nil.
272 if m == nil {
273 return ChangeDuration{noop.Float64Gauge{}}, nil
274 }
275
276 i, err := m.Float64Gauge(
277 "vcs.change.duration",
278 append([]metric.Float64GaugeOption{
279 metric.WithDescription("The time duration a change (pull request/merge request/changelist) has been in a given state."),
280 metric.WithUnit("s"),
281 }, opt...)...,
282 )
283 if err != nil {
284 return ChangeDuration{noop.Float64Gauge{}}, err
285 }
286 return ChangeDuration{i}, nil
287 }
288
289 // Inst returns the underlying metric instrument.
290 func (m ChangeDuration) Inst() metric.Float64Gauge {
291 return m.Float64Gauge
292 }
293
294 // Name returns the semantic convention name of the instrument.
295 func (ChangeDuration) Name() string {
296 return "vcs.change.duration"
297 }
298
299 // Unit returns the semantic convention unit of the instrument
300 func (ChangeDuration) Unit() string {
301 return "s"
302 }
303
304 // Description returns the semantic convention description of the instrument
305 func (ChangeDuration) Description() string {
306 return "The time duration a change (pull request/merge request/changelist) has been in a given state."
307 }
308
309 // Record records val to the current distribution.
310 //
311 // The changeState is the the state of the change (pull request/merge
312 // request/changelist).
313 //
314 // The refHeadName is the the name of the [reference] such as **branch** or
315 // **tag** in the repository.
316 //
317 // The repositoryUrlFull is the the [canonical URL] of the repository providing
318 // the complete HTTP(S) address in order to locate and identify the repository
319 // through a browser.
320 //
321 // All additional attrs passed are included in the recorded value.
322 //
323 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
324 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
325 func (m ChangeDuration) Record(
326 ctx context.Context,
327 val float64,
328 changeState ChangeStateAttr,
329 refHeadName string,
330 repositoryUrlFull string,
331 attrs ...attribute.KeyValue,
332 ) {
333 o := recOptPool.Get().(*[]metric.RecordOption)
334 defer func() {
335 *o = (*o)[:0]
336 recOptPool.Put(o)
337 }()
338
339 *o = append(
340 *o,
341 metric.WithAttributes(
342 append(
343 attrs,
344 attribute.String("vcs.change.state", string(changeState)),
345 attribute.String("vcs.ref.head.name", refHeadName),
346 attribute.String("vcs.repository.url.full", repositoryUrlFull),
347 )...,
348 ),
349 )
350
351 m.Float64Gauge.Record(ctx, val, *o...)
352 }
353
354 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
355 // convention. It represents the group owner within the version control system.
356 func (ChangeDuration) AttrOwnerName(val string) attribute.KeyValue {
357 return attribute.String("vcs.owner.name", val)
358 }
359
360 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
361 // semantic convention. It represents the human readable name of the repository.
362 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
363 // or organization in GitHub.
364 func (ChangeDuration) AttrRepositoryName(val string) attribute.KeyValue {
365 return attribute.String("vcs.repository.name", val)
366 }
367
368 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
369 // semantic convention. It represents the name of the version control system
370 // provider.
371 func (ChangeDuration) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
372 return attribute.String("vcs.provider.name", string(val))
373 }
374
375 // ChangeTimeToApproval is an instrument used to record metric values conforming
376 // to the "vcs.change.time_to_approval" semantic conventions. It represents the
377 // amount of time since its creation it took a change (pull request/merge
378 // request/changelist) to get the first approval.
379 type ChangeTimeToApproval struct {
380 metric.Float64Gauge
381 }
382
383 // NewChangeTimeToApproval returns a new ChangeTimeToApproval instrument.
384 func NewChangeTimeToApproval(
385 m metric.Meter,
386 opt ...metric.Float64GaugeOption,
387 ) (ChangeTimeToApproval, error) {
388 // Check if the meter is nil.
389 if m == nil {
390 return ChangeTimeToApproval{noop.Float64Gauge{}}, nil
391 }
392
393 i, err := m.Float64Gauge(
394 "vcs.change.time_to_approval",
395 append([]metric.Float64GaugeOption{
396 metric.WithDescription("The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval."),
397 metric.WithUnit("s"),
398 }, opt...)...,
399 )
400 if err != nil {
401 return ChangeTimeToApproval{noop.Float64Gauge{}}, err
402 }
403 return ChangeTimeToApproval{i}, nil
404 }
405
406 // Inst returns the underlying metric instrument.
407 func (m ChangeTimeToApproval) Inst() metric.Float64Gauge {
408 return m.Float64Gauge
409 }
410
411 // Name returns the semantic convention name of the instrument.
412 func (ChangeTimeToApproval) Name() string {
413 return "vcs.change.time_to_approval"
414 }
415
416 // Unit returns the semantic convention unit of the instrument
417 func (ChangeTimeToApproval) Unit() string {
418 return "s"
419 }
420
421 // Description returns the semantic convention description of the instrument
422 func (ChangeTimeToApproval) Description() string {
423 return "The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval."
424 }
425
426 // Record records val to the current distribution.
427 //
428 // The refHeadName is the the name of the [reference] such as **branch** or
429 // **tag** in the repository.
430 //
431 // The repositoryUrlFull is the the [canonical URL] of the repository providing
432 // the complete HTTP(S) address in order to locate and identify the repository
433 // through a browser.
434 //
435 // All additional attrs passed are included in the recorded value.
436 //
437 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
438 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
439 func (m ChangeTimeToApproval) Record(
440 ctx context.Context,
441 val float64,
442 refHeadName string,
443 repositoryUrlFull string,
444 attrs ...attribute.KeyValue,
445 ) {
446 o := recOptPool.Get().(*[]metric.RecordOption)
447 defer func() {
448 *o = (*o)[:0]
449 recOptPool.Put(o)
450 }()
451
452 *o = append(
453 *o,
454 metric.WithAttributes(
455 append(
456 attrs,
457 attribute.String("vcs.ref.head.name", refHeadName),
458 attribute.String("vcs.repository.url.full", repositoryUrlFull),
459 )...,
460 ),
461 )
462
463 m.Float64Gauge.Record(ctx, val, *o...)
464 }
465
466 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
467 // convention. It represents the group owner within the version control system.
468 func (ChangeTimeToApproval) AttrOwnerName(val string) attribute.KeyValue {
469 return attribute.String("vcs.owner.name", val)
470 }
471
472 // AttrRefBaseName returns an optional attribute for the "vcs.ref.base.name"
473 // semantic convention. It represents the name of the [reference] such as
474 // **branch** or **tag** in the repository.
475 //
476 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
477 func (ChangeTimeToApproval) AttrRefBaseName(val string) attribute.KeyValue {
478 return attribute.String("vcs.ref.base.name", val)
479 }
480
481 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
482 // semantic convention. It represents the human readable name of the repository.
483 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
484 // or organization in GitHub.
485 func (ChangeTimeToApproval) AttrRepositoryName(val string) attribute.KeyValue {
486 return attribute.String("vcs.repository.name", val)
487 }
488
489 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
490 // semantic convention. It represents the name of the version control system
491 // provider.
492 func (ChangeTimeToApproval) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
493 return attribute.String("vcs.provider.name", string(val))
494 }
495
496 // AttrRefBaseRevision returns an optional attribute for the
497 // "vcs.ref.base.revision" semantic convention. It represents the revision,
498 // literally [revised version], The revision most often refers to a commit object
499 // in Git, or a revision number in SVN.
500 //
501 // [revised version]: https://www.merriam-webster.com/dictionary/revision
502 func (ChangeTimeToApproval) AttrRefBaseRevision(val string) attribute.KeyValue {
503 return attribute.String("vcs.ref.base.revision", val)
504 }
505
506 // AttrRefHeadRevision returns an optional attribute for the
507 // "vcs.ref.head.revision" semantic convention. It represents the revision,
508 // literally [revised version], The revision most often refers to a commit object
509 // in Git, or a revision number in SVN.
510 //
511 // [revised version]: https://www.merriam-webster.com/dictionary/revision
512 func (ChangeTimeToApproval) AttrRefHeadRevision(val string) attribute.KeyValue {
513 return attribute.String("vcs.ref.head.revision", val)
514 }
515
516 // ChangeTimeToMerge is an instrument used to record metric values conforming to
517 // the "vcs.change.time_to_merge" semantic conventions. It represents the amount
518 // of time since its creation it took a change (pull request/merge
519 // request/changelist) to get merged into the target(base) ref.
520 type ChangeTimeToMerge struct {
521 metric.Float64Gauge
522 }
523
524 // NewChangeTimeToMerge returns a new ChangeTimeToMerge instrument.
525 func NewChangeTimeToMerge(
526 m metric.Meter,
527 opt ...metric.Float64GaugeOption,
528 ) (ChangeTimeToMerge, error) {
529 // Check if the meter is nil.
530 if m == nil {
531 return ChangeTimeToMerge{noop.Float64Gauge{}}, nil
532 }
533
534 i, err := m.Float64Gauge(
535 "vcs.change.time_to_merge",
536 append([]metric.Float64GaugeOption{
537 metric.WithDescription("The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref."),
538 metric.WithUnit("s"),
539 }, opt...)...,
540 )
541 if err != nil {
542 return ChangeTimeToMerge{noop.Float64Gauge{}}, err
543 }
544 return ChangeTimeToMerge{i}, nil
545 }
546
547 // Inst returns the underlying metric instrument.
548 func (m ChangeTimeToMerge) Inst() metric.Float64Gauge {
549 return m.Float64Gauge
550 }
551
552 // Name returns the semantic convention name of the instrument.
553 func (ChangeTimeToMerge) Name() string {
554 return "vcs.change.time_to_merge"
555 }
556
557 // Unit returns the semantic convention unit of the instrument
558 func (ChangeTimeToMerge) Unit() string {
559 return "s"
560 }
561
562 // Description returns the semantic convention description of the instrument
563 func (ChangeTimeToMerge) Description() string {
564 return "The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref."
565 }
566
567 // Record records val to the current distribution.
568 //
569 // The refHeadName is the the name of the [reference] such as **branch** or
570 // **tag** in the repository.
571 //
572 // The repositoryUrlFull is the the [canonical URL] of the repository providing
573 // the complete HTTP(S) address in order to locate and identify the repository
574 // through a browser.
575 //
576 // All additional attrs passed are included in the recorded value.
577 //
578 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
579 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
580 func (m ChangeTimeToMerge) Record(
581 ctx context.Context,
582 val float64,
583 refHeadName string,
584 repositoryUrlFull string,
585 attrs ...attribute.KeyValue,
586 ) {
587 o := recOptPool.Get().(*[]metric.RecordOption)
588 defer func() {
589 *o = (*o)[:0]
590 recOptPool.Put(o)
591 }()
592
593 *o = append(
594 *o,
595 metric.WithAttributes(
596 append(
597 attrs,
598 attribute.String("vcs.ref.head.name", refHeadName),
599 attribute.String("vcs.repository.url.full", repositoryUrlFull),
600 )...,
601 ),
602 )
603
604 m.Float64Gauge.Record(ctx, val, *o...)
605 }
606
607 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
608 // convention. It represents the group owner within the version control system.
609 func (ChangeTimeToMerge) AttrOwnerName(val string) attribute.KeyValue {
610 return attribute.String("vcs.owner.name", val)
611 }
612
613 // AttrRefBaseName returns an optional attribute for the "vcs.ref.base.name"
614 // semantic convention. It represents the name of the [reference] such as
615 // **branch** or **tag** in the repository.
616 //
617 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
618 func (ChangeTimeToMerge) AttrRefBaseName(val string) attribute.KeyValue {
619 return attribute.String("vcs.ref.base.name", val)
620 }
621
622 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
623 // semantic convention. It represents the human readable name of the repository.
624 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
625 // or organization in GitHub.
626 func (ChangeTimeToMerge) AttrRepositoryName(val string) attribute.KeyValue {
627 return attribute.String("vcs.repository.name", val)
628 }
629
630 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
631 // semantic convention. It represents the name of the version control system
632 // provider.
633 func (ChangeTimeToMerge) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
634 return attribute.String("vcs.provider.name", string(val))
635 }
636
637 // AttrRefBaseRevision returns an optional attribute for the
638 // "vcs.ref.base.revision" semantic convention. It represents the revision,
639 // literally [revised version], The revision most often refers to a commit object
640 // in Git, or a revision number in SVN.
641 //
642 // [revised version]: https://www.merriam-webster.com/dictionary/revision
643 func (ChangeTimeToMerge) AttrRefBaseRevision(val string) attribute.KeyValue {
644 return attribute.String("vcs.ref.base.revision", val)
645 }
646
647 // AttrRefHeadRevision returns an optional attribute for the
648 // "vcs.ref.head.revision" semantic convention. It represents the revision,
649 // literally [revised version], The revision most often refers to a commit object
650 // in Git, or a revision number in SVN.
651 //
652 // [revised version]: https://www.merriam-webster.com/dictionary/revision
653 func (ChangeTimeToMerge) AttrRefHeadRevision(val string) attribute.KeyValue {
654 return attribute.String("vcs.ref.head.revision", val)
655 }
656
657 // ContributorCount is an instrument used to record metric values conforming to
658 // the "vcs.contributor.count" semantic conventions. It represents the number of
659 // unique contributors to a repository.
660 type ContributorCount struct {
661 metric.Int64Gauge
662 }
663
664 // NewContributorCount returns a new ContributorCount instrument.
665 func NewContributorCount(
666 m metric.Meter,
667 opt ...metric.Int64GaugeOption,
668 ) (ContributorCount, error) {
669 // Check if the meter is nil.
670 if m == nil {
671 return ContributorCount{noop.Int64Gauge{}}, nil
672 }
673
674 i, err := m.Int64Gauge(
675 "vcs.contributor.count",
676 append([]metric.Int64GaugeOption{
677 metric.WithDescription("The number of unique contributors to a repository"),
678 metric.WithUnit("{contributor}"),
679 }, opt...)...,
680 )
681 if err != nil {
682 return ContributorCount{noop.Int64Gauge{}}, err
683 }
684 return ContributorCount{i}, nil
685 }
686
687 // Inst returns the underlying metric instrument.
688 func (m ContributorCount) Inst() metric.Int64Gauge {
689 return m.Int64Gauge
690 }
691
692 // Name returns the semantic convention name of the instrument.
693 func (ContributorCount) Name() string {
694 return "vcs.contributor.count"
695 }
696
697 // Unit returns the semantic convention unit of the instrument
698 func (ContributorCount) Unit() string {
699 return "{contributor}"
700 }
701
702 // Description returns the semantic convention description of the instrument
703 func (ContributorCount) Description() string {
704 return "The number of unique contributors to a repository"
705 }
706
707 // Record records val to the current distribution.
708 //
709 // The repositoryUrlFull is the the [canonical URL] of the repository providing
710 // the complete HTTP(S) address in order to locate and identify the repository
711 // through a browser.
712 //
713 // All additional attrs passed are included in the recorded value.
714 //
715 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
716 func (m ContributorCount) Record(
717 ctx context.Context,
718 val int64,
719 repositoryUrlFull string,
720 attrs ...attribute.KeyValue,
721 ) {
722 o := recOptPool.Get().(*[]metric.RecordOption)
723 defer func() {
724 *o = (*o)[:0]
725 recOptPool.Put(o)
726 }()
727
728 *o = append(
729 *o,
730 metric.WithAttributes(
731 append(
732 attrs,
733 attribute.String("vcs.repository.url.full", repositoryUrlFull),
734 )...,
735 ),
736 )
737
738 m.Int64Gauge.Record(ctx, val, *o...)
739 }
740
741 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
742 // convention. It represents the group owner within the version control system.
743 func (ContributorCount) AttrOwnerName(val string) attribute.KeyValue {
744 return attribute.String("vcs.owner.name", val)
745 }
746
747 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
748 // semantic convention. It represents the human readable name of the repository.
749 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
750 // or organization in GitHub.
751 func (ContributorCount) AttrRepositoryName(val string) attribute.KeyValue {
752 return attribute.String("vcs.repository.name", val)
753 }
754
755 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
756 // semantic convention. It represents the name of the version control system
757 // provider.
758 func (ContributorCount) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
759 return attribute.String("vcs.provider.name", string(val))
760 }
761
762 // RefCount is an instrument used to record metric values conforming to the
763 // "vcs.ref.count" semantic conventions. It represents the number of refs of type
764 // branch or tag in a repository.
765 type RefCount struct {
766 metric.Int64UpDownCounter
767 }
768
769 // NewRefCount returns a new RefCount instrument.
770 func NewRefCount(
771 m metric.Meter,
772 opt ...metric.Int64UpDownCounterOption,
773 ) (RefCount, error) {
774 // Check if the meter is nil.
775 if m == nil {
776 return RefCount{noop.Int64UpDownCounter{}}, nil
777 }
778
779 i, err := m.Int64UpDownCounter(
780 "vcs.ref.count",
781 append([]metric.Int64UpDownCounterOption{
782 metric.WithDescription("The number of refs of type branch or tag in a repository."),
783 metric.WithUnit("{ref}"),
784 }, opt...)...,
785 )
786 if err != nil {
787 return RefCount{noop.Int64UpDownCounter{}}, err
788 }
789 return RefCount{i}, nil
790 }
791
792 // Inst returns the underlying metric instrument.
793 func (m RefCount) Inst() metric.Int64UpDownCounter {
794 return m.Int64UpDownCounter
795 }
796
797 // Name returns the semantic convention name of the instrument.
798 func (RefCount) Name() string {
799 return "vcs.ref.count"
800 }
801
802 // Unit returns the semantic convention unit of the instrument
803 func (RefCount) Unit() string {
804 return "{ref}"
805 }
806
807 // Description returns the semantic convention description of the instrument
808 func (RefCount) Description() string {
809 return "The number of refs of type branch or tag in a repository."
810 }
811
812 // Add adds incr to the existing count.
813 //
814 // The refType is the the type of the [reference] in the repository.
815 //
816 // The repositoryUrlFull is the the [canonical URL] of the repository providing
817 // the complete HTTP(S) address in order to locate and identify the repository
818 // through a browser.
819 //
820 // All additional attrs passed are included in the recorded value.
821 //
822 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
823 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
824 func (m RefCount) Add(
825 ctx context.Context,
826 incr int64,
827 refType RefTypeAttr,
828 repositoryUrlFull string,
829 attrs ...attribute.KeyValue,
830 ) {
831 o := addOptPool.Get().(*[]metric.AddOption)
832 defer func() {
833 *o = (*o)[:0]
834 addOptPool.Put(o)
835 }()
836
837 *o = append(
838 *o,
839 metric.WithAttributes(
840 append(
841 attrs,
842 attribute.String("vcs.ref.type", string(refType)),
843 attribute.String("vcs.repository.url.full", repositoryUrlFull),
844 )...,
845 ),
846 )
847
848 m.Int64UpDownCounter.Add(ctx, incr, *o...)
849 }
850
851 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
852 // convention. It represents the group owner within the version control system.
853 func (RefCount) AttrOwnerName(val string) attribute.KeyValue {
854 return attribute.String("vcs.owner.name", val)
855 }
856
857 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
858 // semantic convention. It represents the human readable name of the repository.
859 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
860 // or organization in GitHub.
861 func (RefCount) AttrRepositoryName(val string) attribute.KeyValue {
862 return attribute.String("vcs.repository.name", val)
863 }
864
865 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
866 // semantic convention. It represents the name of the version control system
867 // provider.
868 func (RefCount) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
869 return attribute.String("vcs.provider.name", string(val))
870 }
871
872 // RefLinesDelta is an instrument used to record metric values conforming to the
873 // "vcs.ref.lines_delta" semantic conventions. It represents the number of lines
874 // added/removed in a ref (branch) relative to the ref from the
875 // `vcs.ref.base.name` attribute.
876 type RefLinesDelta struct {
877 metric.Int64Gauge
878 }
879
880 // NewRefLinesDelta returns a new RefLinesDelta instrument.
881 func NewRefLinesDelta(
882 m metric.Meter,
883 opt ...metric.Int64GaugeOption,
884 ) (RefLinesDelta, error) {
885 // Check if the meter is nil.
886 if m == nil {
887 return RefLinesDelta{noop.Int64Gauge{}}, nil
888 }
889
890 i, err := m.Int64Gauge(
891 "vcs.ref.lines_delta",
892 append([]metric.Int64GaugeOption{
893 metric.WithDescription("The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute."),
894 metric.WithUnit("{line}"),
895 }, opt...)...,
896 )
897 if err != nil {
898 return RefLinesDelta{noop.Int64Gauge{}}, err
899 }
900 return RefLinesDelta{i}, nil
901 }
902
903 // Inst returns the underlying metric instrument.
904 func (m RefLinesDelta) Inst() metric.Int64Gauge {
905 return m.Int64Gauge
906 }
907
908 // Name returns the semantic convention name of the instrument.
909 func (RefLinesDelta) Name() string {
910 return "vcs.ref.lines_delta"
911 }
912
913 // Unit returns the semantic convention unit of the instrument
914 func (RefLinesDelta) Unit() string {
915 return "{line}"
916 }
917
918 // Description returns the semantic convention description of the instrument
919 func (RefLinesDelta) Description() string {
920 return "The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute."
921 }
922
923 // Record records val to the current distribution.
924 //
925 // The lineChangeType is the the type of line change being measured on a branch
926 // or change.
927 //
928 // The refBaseName is the the name of the [reference] such as **branch** or
929 // **tag** in the repository.
930 //
931 // The refBaseType is the the type of the [reference] in the repository.
932 //
933 // The refHeadName is the the name of the [reference] such as **branch** or
934 // **tag** in the repository.
935 //
936 // The refHeadType is the the type of the [reference] in the repository.
937 //
938 // The repositoryUrlFull is the the [canonical URL] of the repository providing
939 // the complete HTTP(S) address in order to locate and identify the repository
940 // through a browser.
941 //
942 // All additional attrs passed are included in the recorded value.
943 //
944 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
945 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
946 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
947 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
948 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
949 //
950 // This metric should be reported for each `vcs.line_change.type` value. For
951 // example if a ref added 3 lines and removed 2 lines,
952 // instrumentation SHOULD report two measurements: 3 and 2 (both positive
953 // numbers).
954 // If number of lines added/removed should be calculated from the start of time,
955 // then `vcs.ref.base.name` SHOULD be set to an empty string.
956 func (m RefLinesDelta) Record(
957 ctx context.Context,
958 val int64,
959 lineChangeType LineChangeTypeAttr,
960 refBaseName string,
961 refBaseType RefBaseTypeAttr,
962 refHeadName string,
963 refHeadType RefHeadTypeAttr,
964 repositoryUrlFull string,
965 attrs ...attribute.KeyValue,
966 ) {
967 o := recOptPool.Get().(*[]metric.RecordOption)
968 defer func() {
969 *o = (*o)[:0]
970 recOptPool.Put(o)
971 }()
972
973 *o = append(
974 *o,
975 metric.WithAttributes(
976 append(
977 attrs,
978 attribute.String("vcs.line_change.type", string(lineChangeType)),
979 attribute.String("vcs.ref.base.name", refBaseName),
980 attribute.String("vcs.ref.base.type", string(refBaseType)),
981 attribute.String("vcs.ref.head.name", refHeadName),
982 attribute.String("vcs.ref.head.type", string(refHeadType)),
983 attribute.String("vcs.repository.url.full", repositoryUrlFull),
984 )...,
985 ),
986 )
987
988 m.Int64Gauge.Record(ctx, val, *o...)
989 }
990
991 // AttrChangeID returns an optional attribute for the "vcs.change.id" semantic
992 // convention. It represents the ID of the change (pull request/merge
993 // request/changelist) if applicable. This is usually a unique (within
994 // repository) identifier generated by the VCS system.
995 func (RefLinesDelta) AttrChangeID(val string) attribute.KeyValue {
996 return attribute.String("vcs.change.id", val)
997 }
998
999 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
1000 // convention. It represents the group owner within the version control system.
1001 func (RefLinesDelta) AttrOwnerName(val string) attribute.KeyValue {
1002 return attribute.String("vcs.owner.name", val)
1003 }
1004
1005 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
1006 // semantic convention. It represents the human readable name of the repository.
1007 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
1008 // or organization in GitHub.
1009 func (RefLinesDelta) AttrRepositoryName(val string) attribute.KeyValue {
1010 return attribute.String("vcs.repository.name", val)
1011 }
1012
1013 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
1014 // semantic convention. It represents the name of the version control system
1015 // provider.
1016 func (RefLinesDelta) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
1017 return attribute.String("vcs.provider.name", string(val))
1018 }
1019
1020 // RefRevisionsDelta is an instrument used to record metric values conforming to
1021 // the "vcs.ref.revisions_delta" semantic conventions. It represents the number
1022 // of revisions (commits) a ref (branch) is ahead/behind the branch from the
1023 // `vcs.ref.base.name` attribute.
1024 type RefRevisionsDelta struct {
1025 metric.Int64Gauge
1026 }
1027
1028 // NewRefRevisionsDelta returns a new RefRevisionsDelta instrument.
1029 func NewRefRevisionsDelta(
1030 m metric.Meter,
1031 opt ...metric.Int64GaugeOption,
1032 ) (RefRevisionsDelta, error) {
1033 // Check if the meter is nil.
1034 if m == nil {
1035 return RefRevisionsDelta{noop.Int64Gauge{}}, nil
1036 }
1037
1038 i, err := m.Int64Gauge(
1039 "vcs.ref.revisions_delta",
1040 append([]metric.Int64GaugeOption{
1041 metric.WithDescription("The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute"),
1042 metric.WithUnit("{revision}"),
1043 }, opt...)...,
1044 )
1045 if err != nil {
1046 return RefRevisionsDelta{noop.Int64Gauge{}}, err
1047 }
1048 return RefRevisionsDelta{i}, nil
1049 }
1050
1051 // Inst returns the underlying metric instrument.
1052 func (m RefRevisionsDelta) Inst() metric.Int64Gauge {
1053 return m.Int64Gauge
1054 }
1055
1056 // Name returns the semantic convention name of the instrument.
1057 func (RefRevisionsDelta) Name() string {
1058 return "vcs.ref.revisions_delta"
1059 }
1060
1061 // Unit returns the semantic convention unit of the instrument
1062 func (RefRevisionsDelta) Unit() string {
1063 return "{revision}"
1064 }
1065
1066 // Description returns the semantic convention description of the instrument
1067 func (RefRevisionsDelta) Description() string {
1068 return "The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute"
1069 }
1070
1071 // Record records val to the current distribution.
1072 //
1073 // The refBaseName is the the name of the [reference] such as **branch** or
1074 // **tag** in the repository.
1075 //
1076 // The refBaseType is the the type of the [reference] in the repository.
1077 //
1078 // The refHeadName is the the name of the [reference] such as **branch** or
1079 // **tag** in the repository.
1080 //
1081 // The refHeadType is the the type of the [reference] in the repository.
1082 //
1083 // The repositoryUrlFull is the the [canonical URL] of the repository providing
1084 // the complete HTTP(S) address in order to locate and identify the repository
1085 // through a browser.
1086 //
1087 // The revisionDeltaDirection is the the type of revision comparison.
1088 //
1089 // All additional attrs passed are included in the recorded value.
1090 //
1091 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1092 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1093 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1094 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1095 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
1096 //
1097 // This metric should be reported for each `vcs.revision_delta.direction` value.
1098 // For example if branch `a` is 3 commits behind and 2 commits ahead of `trunk`,
1099 // instrumentation SHOULD report two measurements: 3 and 2 (both positive
1100 // numbers) and `vcs.ref.base.name` is set to `trunk`.
1101 func (m RefRevisionsDelta) Record(
1102 ctx context.Context,
1103 val int64,
1104 refBaseName string,
1105 refBaseType RefBaseTypeAttr,
1106 refHeadName string,
1107 refHeadType RefHeadTypeAttr,
1108 repositoryUrlFull string,
1109 revisionDeltaDirection RevisionDeltaDirectionAttr,
1110 attrs ...attribute.KeyValue,
1111 ) {
1112 o := recOptPool.Get().(*[]metric.RecordOption)
1113 defer func() {
1114 *o = (*o)[:0]
1115 recOptPool.Put(o)
1116 }()
1117
1118 *o = append(
1119 *o,
1120 metric.WithAttributes(
1121 append(
1122 attrs,
1123 attribute.String("vcs.ref.base.name", refBaseName),
1124 attribute.String("vcs.ref.base.type", string(refBaseType)),
1125 attribute.String("vcs.ref.head.name", refHeadName),
1126 attribute.String("vcs.ref.head.type", string(refHeadType)),
1127 attribute.String("vcs.repository.url.full", repositoryUrlFull),
1128 attribute.String("vcs.revision_delta.direction", string(revisionDeltaDirection)),
1129 )...,
1130 ),
1131 )
1132
1133 m.Int64Gauge.Record(ctx, val, *o...)
1134 }
1135
1136 // AttrChangeID returns an optional attribute for the "vcs.change.id" semantic
1137 // convention. It represents the ID of the change (pull request/merge
1138 // request/changelist) if applicable. This is usually a unique (within
1139 // repository) identifier generated by the VCS system.
1140 func (RefRevisionsDelta) AttrChangeID(val string) attribute.KeyValue {
1141 return attribute.String("vcs.change.id", val)
1142 }
1143
1144 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
1145 // convention. It represents the group owner within the version control system.
1146 func (RefRevisionsDelta) AttrOwnerName(val string) attribute.KeyValue {
1147 return attribute.String("vcs.owner.name", val)
1148 }
1149
1150 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
1151 // semantic convention. It represents the human readable name of the repository.
1152 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
1153 // or organization in GitHub.
1154 func (RefRevisionsDelta) AttrRepositoryName(val string) attribute.KeyValue {
1155 return attribute.String("vcs.repository.name", val)
1156 }
1157
1158 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
1159 // semantic convention. It represents the name of the version control system
1160 // provider.
1161 func (RefRevisionsDelta) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
1162 return attribute.String("vcs.provider.name", string(val))
1163 }
1164
1165 // RefTime is an instrument used to record metric values conforming to the
1166 // "vcs.ref.time" semantic conventions. It represents the time a ref (branch)
1167 // created from the default branch (trunk) has existed. The `ref.type` attribute
1168 // will always be `branch`.
1169 type RefTime struct {
1170 metric.Float64Gauge
1171 }
1172
1173 // NewRefTime returns a new RefTime instrument.
1174 func NewRefTime(
1175 m metric.Meter,
1176 opt ...metric.Float64GaugeOption,
1177 ) (RefTime, error) {
1178 // Check if the meter is nil.
1179 if m == nil {
1180 return RefTime{noop.Float64Gauge{}}, nil
1181 }
1182
1183 i, err := m.Float64Gauge(
1184 "vcs.ref.time",
1185 append([]metric.Float64GaugeOption{
1186 metric.WithDescription("Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`"),
1187 metric.WithUnit("s"),
1188 }, opt...)...,
1189 )
1190 if err != nil {
1191 return RefTime{noop.Float64Gauge{}}, err
1192 }
1193 return RefTime{i}, nil
1194 }
1195
1196 // Inst returns the underlying metric instrument.
1197 func (m RefTime) Inst() metric.Float64Gauge {
1198 return m.Float64Gauge
1199 }
1200
1201 // Name returns the semantic convention name of the instrument.
1202 func (RefTime) Name() string {
1203 return "vcs.ref.time"
1204 }
1205
1206 // Unit returns the semantic convention unit of the instrument
1207 func (RefTime) Unit() string {
1208 return "s"
1209 }
1210
1211 // Description returns the semantic convention description of the instrument
1212 func (RefTime) Description() string {
1213 return "Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`"
1214 }
1215
1216 // Record records val to the current distribution.
1217 //
1218 // The refHeadName is the the name of the [reference] such as **branch** or
1219 // **tag** in the repository.
1220 //
1221 // The refHeadType is the the type of the [reference] in the repository.
1222 //
1223 // The repositoryUrlFull is the the [canonical URL] of the repository providing
1224 // the complete HTTP(S) address in order to locate and identify the repository
1225 // through a browser.
1226 //
1227 // All additional attrs passed are included in the recorded value.
1228 //
1229 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1230 // [reference]: https://git-scm.com/docs/gitglossary#def_ref
1231 // [canonical URL]: https://support.google.com/webmasters/answer/10347851?hl=en#:~:text=A%20canonical%20URL%20is%20the,Google%20chooses%20one%20as%20canonical.
1232 func (m RefTime) Record(
1233 ctx context.Context,
1234 val float64,
1235 refHeadName string,
1236 refHeadType RefHeadTypeAttr,
1237 repositoryUrlFull string,
1238 attrs ...attribute.KeyValue,
1239 ) {
1240 o := recOptPool.Get().(*[]metric.RecordOption)
1241 defer func() {
1242 *o = (*o)[:0]
1243 recOptPool.Put(o)
1244 }()
1245
1246 *o = append(
1247 *o,
1248 metric.WithAttributes(
1249 append(
1250 attrs,
1251 attribute.String("vcs.ref.head.name", refHeadName),
1252 attribute.String("vcs.ref.head.type", string(refHeadType)),
1253 attribute.String("vcs.repository.url.full", repositoryUrlFull),
1254 )...,
1255 ),
1256 )
1257
1258 m.Float64Gauge.Record(ctx, val, *o...)
1259 }
1260
1261 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
1262 // convention. It represents the group owner within the version control system.
1263 func (RefTime) AttrOwnerName(val string) attribute.KeyValue {
1264 return attribute.String("vcs.owner.name", val)
1265 }
1266
1267 // AttrRepositoryName returns an optional attribute for the "vcs.repository.name"
1268 // semantic convention. It represents the human readable name of the repository.
1269 // It SHOULD NOT include any additional identifier like Group/SubGroup in GitLab
1270 // or organization in GitHub.
1271 func (RefTime) AttrRepositoryName(val string) attribute.KeyValue {
1272 return attribute.String("vcs.repository.name", val)
1273 }
1274
1275 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
1276 // semantic convention. It represents the name of the version control system
1277 // provider.
1278 func (RefTime) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
1279 return attribute.String("vcs.provider.name", string(val))
1280 }
1281
1282 // RepositoryCount is an instrument used to record metric values conforming to
1283 // the "vcs.repository.count" semantic conventions. It represents the number of
1284 // repositories in an organization.
1285 type RepositoryCount struct {
1286 metric.Int64UpDownCounter
1287 }
1288
1289 // NewRepositoryCount returns a new RepositoryCount instrument.
1290 func NewRepositoryCount(
1291 m metric.Meter,
1292 opt ...metric.Int64UpDownCounterOption,
1293 ) (RepositoryCount, error) {
1294 // Check if the meter is nil.
1295 if m == nil {
1296 return RepositoryCount{noop.Int64UpDownCounter{}}, nil
1297 }
1298
1299 i, err := m.Int64UpDownCounter(
1300 "vcs.repository.count",
1301 append([]metric.Int64UpDownCounterOption{
1302 metric.WithDescription("The number of repositories in an organization."),
1303 metric.WithUnit("{repository}"),
1304 }, opt...)...,
1305 )
1306 if err != nil {
1307 return RepositoryCount{noop.Int64UpDownCounter{}}, err
1308 }
1309 return RepositoryCount{i}, nil
1310 }
1311
1312 // Inst returns the underlying metric instrument.
1313 func (m RepositoryCount) Inst() metric.Int64UpDownCounter {
1314 return m.Int64UpDownCounter
1315 }
1316
1317 // Name returns the semantic convention name of the instrument.
1318 func (RepositoryCount) Name() string {
1319 return "vcs.repository.count"
1320 }
1321
1322 // Unit returns the semantic convention unit of the instrument
1323 func (RepositoryCount) Unit() string {
1324 return "{repository}"
1325 }
1326
1327 // Description returns the semantic convention description of the instrument
1328 func (RepositoryCount) Description() string {
1329 return "The number of repositories in an organization."
1330 }
1331
1332 // Add adds incr to the existing count.
1333 //
1334 // All additional attrs passed are included in the recorded value.
1335 func (m RepositoryCount) Add(
1336 ctx context.Context,
1337 incr int64,
1338 attrs ...attribute.KeyValue,
1339 ) {
1340 o := addOptPool.Get().(*[]metric.AddOption)
1341 defer func() {
1342 *o = (*o)[:0]
1343 addOptPool.Put(o)
1344 }()
1345
1346 *o = append(
1347 *o,
1348 metric.WithAttributes(
1349 attrs...,
1350 ),
1351 )
1352
1353 m.Int64UpDownCounter.Add(ctx, incr, *o...)
1354 }
1355
1356 // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic
1357 // convention. It represents the group owner within the version control system.
1358 func (RepositoryCount) AttrOwnerName(val string) attribute.KeyValue {
1359 return attribute.String("vcs.owner.name", val)
1360 }
1361
1362 // AttrProviderName returns an optional attribute for the "vcs.provider.name"
1363 // semantic convention. It represents the name of the version control system
1364 // provider.
1365 func (RepositoryCount) AttrProviderName(val ProviderNameAttr) attribute.KeyValue {
1366 return attribute.String("vcs.provider.name", string(val))
1367 }