Documentation ¶
Index ¶
- Constants
- Variables
- type AttributeChangeState
- type AttributeCveSeverity
- type AttributeRefType
- type MetricBuilderOption
- type MetricConfig
- type MetricsBuilder
- func (mb *MetricsBuilder) Emit(options ...ResourceMetricsOption) pmetric.Metrics
- func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption)
- func (mb *MetricsBuilder) NewResourceBuilder() *ResourceBuilder
- func (mb *MetricsBuilder) RecordVcsRepositoryChangeCountDataPoint(ts pcommon.Timestamp, val int64, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeOpenDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeToApprovalDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeToMergeDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryContributorCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string)
- func (mb *MetricsBuilder) RecordVcsRepositoryCountDataPoint(ts pcommon.Timestamp, val int64)
- func (mb *MetricsBuilder) RecordVcsRepositoryCveCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefLinesAddedDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefLinesDeletedDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefRevisionsAheadDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefRevisionsBehindDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) RecordVcsRepositoryRefTimeDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, ...)
- func (mb *MetricsBuilder) Reset(options ...MetricBuilderOption)
- type MetricsBuilderConfig
- type MetricsConfig
- type ResourceAttributeConfig
- type ResourceAttributesConfig
- type ResourceBuilder
- type ResourceMetricsOption
Constants ¶
const (
MetricsStability = component.StabilityLevelDevelopment
)
Variables ¶
var ( Type = component.MustNewType("github") ScopeName = "github.com/liatrio/liatrio-otel-collector/receiver/githubreceiver" )
var MapAttributeChangeState = map[string]AttributeChangeState{ "open": AttributeChangeStateOpen, "merged": AttributeChangeStateMerged, }
MapAttributeChangeState is a helper map of string to AttributeChangeState attribute value.
var MapAttributeCveSeverity = map[string]AttributeCveSeverity{ "critical": AttributeCveSeverityCritical, "high": AttributeCveSeverityHigh, "medium": AttributeCveSeverityMedium, "low": AttributeCveSeverityLow, "none": AttributeCveSeverityNone, }
MapAttributeCveSeverity is a helper map of string to AttributeCveSeverity attribute value.
var MapAttributeRefType = map[string]AttributeRefType{ "branch": AttributeRefTypeBranch, "tag": AttributeRefTypeTag, }
MapAttributeRefType is a helper map of string to AttributeRefType attribute value.
Functions ¶
This section is empty.
Types ¶
type AttributeChangeState ¶
type AttributeChangeState int
AttributeChangeState specifies the a value change.state attribute.
const ( AttributeChangeStateOpen AttributeChangeState AttributeChangeStateMerged )
func (AttributeChangeState) String ¶
func (av AttributeChangeState) String() string
String returns the string representation of the AttributeChangeState.
type AttributeCveSeverity ¶ added in v0.74.0
type AttributeCveSeverity int
AttributeCveSeverity specifies the a value cve.severity attribute.
const ( AttributeCveSeverityCritical AttributeCveSeverity AttributeCveSeverityHigh AttributeCveSeverityMedium AttributeCveSeverityLow AttributeCveSeverityNone )
func (AttributeCveSeverity) String ¶ added in v0.74.0
func (av AttributeCveSeverity) String() string
String returns the string representation of the AttributeCveSeverity.
type AttributeRefType ¶
type AttributeRefType int
AttributeRefType specifies the a value ref.type attribute.
const ( AttributeRefTypeBranch AttributeRefType AttributeRefTypeTag )
func (AttributeRefType) String ¶
func (av AttributeRefType) String() string
String returns the string representation of the AttributeRefType.
type MetricBuilderOption ¶ added in v0.72.9
type MetricBuilderOption interface {
// contains filtered or unexported methods
}
MetricBuilderOption applies changes to default metrics builder.
func WithStartTime ¶
func WithStartTime(startTime pcommon.Timestamp) MetricBuilderOption
WithStartTime sets startTime on the metrics builder.
type MetricConfig ¶
type MetricConfig struct { Enabled bool `mapstructure:"enabled"` // contains filtered or unexported fields }
MetricConfig provides common config for a particular metric.
type MetricsBuilder ¶
type MetricsBuilder struct {
// contains filtered or unexported fields
}
MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations required to produce metric representation defined in metadata and user config.
func NewMetricsBuilder ¶
func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, options ...MetricBuilderOption) *MetricsBuilder
func (*MetricsBuilder) Emit ¶
func (mb *MetricsBuilder) Emit(options ...ResourceMetricsOption) pmetric.Metrics
Emit returns all the metrics accumulated by the metrics builder and updates the internal state to be ready for recording another set of metrics. This function will be responsible for applying all the transformations required to produce metric representation defined in metadata and user config, e.g. delta or cumulative.
func (*MetricsBuilder) EmitForResource ¶
func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption)
EmitForResource saves all the generated metrics under a new resource and updates the internal state to be ready for recording another set of data points as part of another resource. This function can be helpful when one scraper needs to emit metrics from several resources. Otherwise calling this function is not required, just `Emit` function can be called instead. Resource attributes should be provided as ResourceMetricsOption arguments.
func (*MetricsBuilder) NewResourceBuilder ¶
func (mb *MetricsBuilder) NewResourceBuilder() *ResourceBuilder
NewResourceBuilder returns a new resource builder that should be used to build a resource associated with for the emitted metrics.
func (*MetricsBuilder) RecordVcsRepositoryChangeCountDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryChangeCountDataPoint(ts pcommon.Timestamp, val int64, changeStateAttributeValue AttributeChangeState, repositoryNameAttributeValue string)
RecordVcsRepositoryChangeCountDataPoint adds a data point to vcs.repository.change.count metric.
func (*MetricsBuilder) RecordVcsRepositoryChangeTimeOpenDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeOpenDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string)
RecordVcsRepositoryChangeTimeOpenDataPoint adds a data point to vcs.repository.change.time_open metric.
func (*MetricsBuilder) RecordVcsRepositoryChangeTimeToApprovalDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeToApprovalDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string)
RecordVcsRepositoryChangeTimeToApprovalDataPoint adds a data point to vcs.repository.change.time_to_approval metric.
func (*MetricsBuilder) RecordVcsRepositoryChangeTimeToMergeDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryChangeTimeToMergeDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string)
RecordVcsRepositoryChangeTimeToMergeDataPoint adds a data point to vcs.repository.change.time_to_merge metric.
func (*MetricsBuilder) RecordVcsRepositoryContributorCountDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryContributorCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string)
RecordVcsRepositoryContributorCountDataPoint adds a data point to vcs.repository.contributor.count metric.
func (*MetricsBuilder) RecordVcsRepositoryCountDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryCountDataPoint(ts pcommon.Timestamp, val int64)
RecordVcsRepositoryCountDataPoint adds a data point to vcs.repository.count metric.
func (*MetricsBuilder) RecordVcsRepositoryCveCountDataPoint ¶ added in v0.74.0
func (mb *MetricsBuilder) RecordVcsRepositoryCveCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, cveSeverityAttributeValue AttributeCveSeverity)
RecordVcsRepositoryCveCountDataPoint adds a data point to vcs.repository.cve.count metric.
func (*MetricsBuilder) RecordVcsRepositoryRefCountDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefCountDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefCountDataPoint adds a data point to vcs.repository.ref.count metric.
func (*MetricsBuilder) RecordVcsRepositoryRefLinesAddedDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefLinesAddedDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefLinesAddedDataPoint adds a data point to vcs.repository.ref.lines_added metric.
func (*MetricsBuilder) RecordVcsRepositoryRefLinesDeletedDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefLinesDeletedDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefLinesDeletedDataPoint adds a data point to vcs.repository.ref.lines_deleted metric.
func (*MetricsBuilder) RecordVcsRepositoryRefRevisionsAheadDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefRevisionsAheadDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefRevisionsAheadDataPoint adds a data point to vcs.repository.ref.revisions_ahead metric.
func (*MetricsBuilder) RecordVcsRepositoryRefRevisionsBehindDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefRevisionsBehindDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefRevisionsBehindDataPoint adds a data point to vcs.repository.ref.revisions_behind metric.
func (*MetricsBuilder) RecordVcsRepositoryRefTimeDataPoint ¶
func (mb *MetricsBuilder) RecordVcsRepositoryRefTimeDataPoint(ts pcommon.Timestamp, val int64, repositoryNameAttributeValue string, refNameAttributeValue string, refTypeAttributeValue AttributeRefType)
RecordVcsRepositoryRefTimeDataPoint adds a data point to vcs.repository.ref.time metric.
func (*MetricsBuilder) Reset ¶
func (mb *MetricsBuilder) Reset(options ...MetricBuilderOption)
Reset resets metrics builder to its initial state. It should be used when external metrics source is restarted, and metrics builder should update its startTime and reset it's internal state accordingly.
type MetricsBuilderConfig ¶
type MetricsBuilderConfig struct { Metrics MetricsConfig `mapstructure:"metrics"` ResourceAttributes ResourceAttributesConfig `mapstructure:"resource_attributes"` }
MetricsBuilderConfig is a configuration for github metrics builder.
func DefaultMetricsBuilderConfig ¶
func DefaultMetricsBuilderConfig() MetricsBuilderConfig
type MetricsConfig ¶
type MetricsConfig struct { VcsRepositoryChangeCount MetricConfig `mapstructure:"vcs.repository.change.count"` VcsRepositoryChangeTimeOpen MetricConfig `mapstructure:"vcs.repository.change.time_open"` VcsRepositoryChangeTimeToApproval MetricConfig `mapstructure:"vcs.repository.change.time_to_approval"` VcsRepositoryChangeTimeToMerge MetricConfig `mapstructure:"vcs.repository.change.time_to_merge"` VcsRepositoryContributorCount MetricConfig `mapstructure:"vcs.repository.contributor.count"` VcsRepositoryCount MetricConfig `mapstructure:"vcs.repository.count"` VcsRepositoryCveCount MetricConfig `mapstructure:"vcs.repository.cve.count"` VcsRepositoryRefCount MetricConfig `mapstructure:"vcs.repository.ref.count"` VcsRepositoryRefLinesAdded MetricConfig `mapstructure:"vcs.repository.ref.lines_added"` VcsRepositoryRefLinesDeleted MetricConfig `mapstructure:"vcs.repository.ref.lines_deleted"` VcsRepositoryRefRevisionsAhead MetricConfig `mapstructure:"vcs.repository.ref.revisions_ahead"` VcsRepositoryRefRevisionsBehind MetricConfig `mapstructure:"vcs.repository.ref.revisions_behind"` VcsRepositoryRefTime MetricConfig `mapstructure:"vcs.repository.ref.time"` }
MetricsConfig provides config for github metrics.
func DefaultMetricsConfig ¶
func DefaultMetricsConfig() MetricsConfig
type ResourceAttributeConfig ¶
type ResourceAttributeConfig struct { Enabled bool `mapstructure:"enabled"` // Experimental: MetricsInclude defines a list of filters for attribute values. // If the list is not empty, only metrics with matching resource attribute values will be emitted. MetricsInclude []filter.Config `mapstructure:"metrics_include"` // Experimental: MetricsExclude defines a list of filters for attribute values. // If the list is not empty, metrics with matching resource attribute values will not be emitted. // MetricsInclude has higher priority than MetricsExclude. MetricsExclude []filter.Config `mapstructure:"metrics_exclude"` // contains filtered or unexported fields }
ResourceAttributeConfig provides common config for a particular resource attribute.
type ResourceAttributesConfig ¶
type ResourceAttributesConfig struct { OrganizationName ResourceAttributeConfig `mapstructure:"organization.name"` TeamName ResourceAttributeConfig `mapstructure:"team.name"` VcsVendorName ResourceAttributeConfig `mapstructure:"vcs.vendor.name"` }
ResourceAttributesConfig provides config for github resource attributes.
func DefaultResourceAttributesConfig ¶
func DefaultResourceAttributesConfig() ResourceAttributesConfig
type ResourceBuilder ¶
type ResourceBuilder struct {
// contains filtered or unexported fields
}
ResourceBuilder is a helper struct to build resources predefined in metadata.yaml. The ResourceBuilder is not thread-safe and must not to be used in multiple goroutines.
func NewResourceBuilder ¶
func NewResourceBuilder(rac ResourceAttributesConfig) *ResourceBuilder
NewResourceBuilder creates a new ResourceBuilder. This method should be called on the start of the application.
func (*ResourceBuilder) Emit ¶
func (rb *ResourceBuilder) Emit() pcommon.Resource
Emit returns the built resource and resets the internal builder state.
func (*ResourceBuilder) SetOrganizationName ¶
func (rb *ResourceBuilder) SetOrganizationName(val string)
SetOrganizationName sets provided value as "organization.name" attribute.
func (*ResourceBuilder) SetTeamName ¶ added in v0.74.0
func (rb *ResourceBuilder) SetTeamName(val string)
SetTeamName sets provided value as "team.name" attribute.
func (*ResourceBuilder) SetVcsVendorName ¶
func (rb *ResourceBuilder) SetVcsVendorName(val string)
SetVcsVendorName sets provided value as "vcs.vendor.name" attribute.
type ResourceMetricsOption ¶
type ResourceMetricsOption interface {
// contains filtered or unexported methods
}
ResourceMetricsOption applies changes to provided resource metrics.
func WithResource ¶
func WithResource(res pcommon.Resource) ResourceMetricsOption
WithResource sets the provided resource on the emitted ResourceMetrics. It's recommended to use ResourceBuilder to create the resource.
func WithStartTimeOverride ¶
func WithStartTimeOverride(start pcommon.Timestamp) ResourceMetricsOption
WithStartTimeOverride overrides start time for all the resource metrics data points. This option should be only used if different start time has to be set on metrics coming from different resources.