diff --git a/otel/autometrics/otel.go b/otel/autometrics/otel.go index 3d1a231..dea2f4d 100644 --- a/otel/autometrics/otel.go +++ b/otel/autometrics/otel.go @@ -35,6 +35,10 @@ var ( ) const ( + // AutometricsSpecVersion is the version of the specification the library follows + // The specifications can be found in https://github.com/autometrics-dev/autometrics-shared/tree/main/specs + AutometricsSpecVersion = "1.0.0" + // FunctionCallsCountName is the name of the openTelemetry metric for the counter of calls to specific functions. FunctionCallsCountName = "function.calls" // FunctionCallsDurationName is the name of the openTelemetry metric for the duration histogram of calls to specific functions. @@ -91,6 +95,10 @@ const ( // service repository url RepositoryProviderLabel = "repository.provider" + // AutometricsVersionLabel is the openTelemetry attribute that describes the version of the Autometrics specification + // the library follows + AutometricsVersionLabel = "autometrics.version" + // ServiceNameLabel is the openTelemetry attribute that describes the name of the Service being monitored. ServiceNameLabel = "service.name" @@ -244,6 +252,7 @@ func Init(meterName string, histogramBuckets []float64, buildInformation BuildIn attribute.Key(RepositoryProviderLabel).String(autometrics.GetRepositoryProvider()), attribute.Key(RepositoryURLLabel).String(autometrics.GetRepositoryURL()), attribute.Key(JobNameLabel).String(autometrics.GetPushJobName()), + attribute.Key(AutometricsVersionLabel).String(AutometricsSpecVersion), }...)) return cancelFunc, nil diff --git a/prometheus/autometrics/prometheus.go b/prometheus/autometrics/prometheus.go index d77a04d..73414d6 100644 --- a/prometheus/autometrics/prometheus.go +++ b/prometheus/autometrics/prometheus.go @@ -27,6 +27,10 @@ var ( ) const ( + // AutometricsSpecVersion is the version of the specification the library follows + // The specifications can be found in https://github.com/autometrics-dev/autometrics-shared/tree/main/specs + AutometricsSpecVersion = "1.0.0" + // FunctionCallsCountName is the name of the prometheus metric for the counter of calls to specific functions. FunctionCallsCountName = "function_calls_total" // FunctionCallsDurationName is the name of the prometheus metric for the duration histogram of calls to specific functions. @@ -83,6 +87,10 @@ const ( // service repository url RepositoryProviderLabel = "repository_provider" + // AutometricsVersionLabel is the prometheus label that describes the version of the Autometrics specification + // the library follows + AutometricsVersionLabel = "autometrics_version" + // ServiceNameLabel is the prometheus label that describes the name of the service being monitored ServiceNameLabel = "service_name" @@ -186,7 +194,7 @@ func Init(reg *prometheus.Registry, histogramBuckets []float64, buildInformation buildInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: BuildInfoName, - }, []string{CommitLabel, VersionLabel, BranchLabel, ServiceNameLabel, RepositoryURLLabel, RepositoryProviderLabel}) + }, []string{CommitLabel, VersionLabel, BranchLabel, ServiceNameLabel, RepositoryURLLabel, RepositoryProviderLabel, AutometricsVersionLabel}) if reg != nil { reg.MustRegister(functionCallsCount) @@ -207,6 +215,7 @@ func Init(reg *prometheus.Registry, histogramBuckets []float64, buildInformation ServiceNameLabel: autometrics.GetService(), RepositoryURLLabel: autometrics.GetRepositoryURL(), RepositoryProviderLabel: autometrics.GetRepositoryProvider(), + AutometricsVersionLabel: AutometricsSpecVersion, }).Set(1) if pusher != nil {