mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Semconv: Change keys to private constants (#91508)
This commit is contained in:
parent
a397bca02e
commit
8c43b9ec2f
@ -14,7 +14,7 @@ const (
|
|||||||
// RequirementLevel: Optional
|
// RequirementLevel: Optional
|
||||||
// Stability: stable
|
// Stability: stable
|
||||||
// Examples: 'prometheus', 'loki', 'grafana-github-datasource'
|
// Examples: 'prometheus', 'loki', 'grafana-github-datasource'
|
||||||
GrafanaDatasourceTypeKey = attribute.Key("grafana.datasource.type")
|
grafanaDatasourceTypeKey = attribute.Key("grafana.datasource.type")
|
||||||
|
|
||||||
// GrafanaDatasourceUidKey is the attribute Key conforming to the
|
// GrafanaDatasourceUidKey is the attribute Key conforming to the
|
||||||
// "grafana.datasource.uid" semantic conventions. It represents the
|
// "grafana.datasource.uid" semantic conventions. It represents the
|
||||||
@ -24,21 +24,21 @@ const (
|
|||||||
// RequirementLevel: Optional
|
// RequirementLevel: Optional
|
||||||
// Stability: stable
|
// Stability: stable
|
||||||
// Examples: 'abcdefg-123456'
|
// Examples: 'abcdefg-123456'
|
||||||
GrafanaDatasourceUidKey = attribute.Key("grafana.datasource.uid")
|
grafanaDatasourceUidKey = attribute.Key("grafana.datasource.uid")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GrafanaDatasourceType returns an attribute KeyValue conforming to the
|
// GrafanaDatasourceType returns an attribute KeyValue conforming to the
|
||||||
// "grafana.datasource.type" semantic conventions. It represents the datasource
|
// "grafana.datasource.type" semantic conventions. It represents the datasource
|
||||||
// type.
|
// type.
|
||||||
func GrafanaDatasourceType(val string) attribute.KeyValue {
|
func GrafanaDatasourceType(val string) attribute.KeyValue {
|
||||||
return GrafanaDatasourceTypeKey.String(val)
|
return grafanaDatasourceTypeKey.String(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GrafanaDatasourceUid returns an attribute KeyValue conforming to the
|
// GrafanaDatasourceUid returns an attribute KeyValue conforming to the
|
||||||
// "grafana.datasource.uid" semantic conventions. It represents the datasource
|
// "grafana.datasource.uid" semantic conventions. It represents the datasource
|
||||||
// unique identifier.
|
// unique identifier.
|
||||||
func GrafanaDatasourceUid(val string) attribute.KeyValue {
|
func GrafanaDatasourceUid(val string) attribute.KeyValue {
|
||||||
return GrafanaDatasourceUidKey.String(val)
|
return grafanaDatasourceUidKey.String(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describes Grafana data source request attributes.
|
// Describes Grafana data source request attributes.
|
||||||
@ -51,14 +51,14 @@ const (
|
|||||||
// RequirementLevel: Optional
|
// RequirementLevel: Optional
|
||||||
// Stability: stable
|
// Stability: stable
|
||||||
// Examples: 3
|
// Examples: 3
|
||||||
GrafanaDatasourceRequestQueryCountKey = attribute.Key("grafana.datasource.request.query_count")
|
grafanaDatasourceRequestQueryCountKey = attribute.Key("grafana.datasource.request.query_count")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GrafanaDatasourceRequestQueryCount returns an attribute KeyValue
|
// GrafanaDatasourceRequestQueryCount returns an attribute KeyValue
|
||||||
// conforming to the "grafana.datasource.request.query_count" semantic
|
// conforming to the "grafana.datasource.request.query_count" semantic
|
||||||
// conventions. It represents the number of queries in the request.
|
// conventions. It represents the number of queries in the request.
|
||||||
func GrafanaDatasourceRequestQueryCount(val int) attribute.KeyValue {
|
func GrafanaDatasourceRequestQueryCount(val int) attribute.KeyValue {
|
||||||
return GrafanaDatasourceRequestQueryCountKey.Int(val)
|
return grafanaDatasourceRequestQueryCountKey.Int(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describes Grafana plugin attributes.
|
// Describes Grafana plugin attributes.
|
||||||
@ -70,7 +70,7 @@ const (
|
|||||||
// RequirementLevel: Optional
|
// RequirementLevel: Optional
|
||||||
// Stability: stable
|
// Stability: stable
|
||||||
// Examples: 'prometheus', 'loki', 'grafana-github-datasource'
|
// Examples: 'prometheus', 'loki', 'grafana-github-datasource'
|
||||||
GrafanaPluginIdKey = attribute.Key("grafana.plugin.id")
|
grafanaPluginIdKey = attribute.Key("grafana.plugin.id")
|
||||||
|
|
||||||
// GrafanaPluginTypeKey is the attribute Key conforming to the
|
// GrafanaPluginTypeKey is the attribute Key conforming to the
|
||||||
// "grafana.plugin.type" semantic conventions. It represents the plugin
|
// "grafana.plugin.type" semantic conventions. It represents the plugin
|
||||||
@ -80,24 +80,24 @@ const (
|
|||||||
// RequirementLevel: Optional
|
// RequirementLevel: Optional
|
||||||
// Stability: stable
|
// Stability: stable
|
||||||
// Examples: 'datasource'
|
// Examples: 'datasource'
|
||||||
GrafanaPluginTypeKey = attribute.Key("grafana.plugin.type")
|
grafanaPluginTypeKey = attribute.Key("grafana.plugin.type")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Data Source Plugin
|
// Data Source Plugin
|
||||||
GrafanaPluginTypeDatasource = GrafanaPluginTypeKey.String("datasource")
|
GrafanaPluginTypeDatasource = grafanaPluginTypeKey.String("datasource")
|
||||||
// Panel Plugin
|
// Panel Plugin
|
||||||
GrafanaPluginTypePanel = GrafanaPluginTypeKey.String("panel")
|
GrafanaPluginTypePanel = grafanaPluginTypeKey.String("panel")
|
||||||
// App Plugin
|
// App Plugin
|
||||||
GrafanaPluginTypeApp = GrafanaPluginTypeKey.String("app")
|
GrafanaPluginTypeApp = grafanaPluginTypeKey.String("app")
|
||||||
// Renderer Plugin
|
// Renderer Plugin
|
||||||
GrafanaPluginTypeRenderer = GrafanaPluginTypeKey.String("renderer")
|
GrafanaPluginTypeRenderer = grafanaPluginTypeKey.String("renderer")
|
||||||
// Secret Manager Plugin
|
// Secret Manager Plugin
|
||||||
GrafanaPluginTypeSecretmanager = GrafanaPluginTypeKey.String("secretmanager")
|
GrafanaPluginTypeSecretmanager = grafanaPluginTypeKey.String("secretmanager")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GrafanaPluginId returns an attribute KeyValue conforming to the
|
// GrafanaPluginId returns an attribute KeyValue conforming to the
|
||||||
// "grafana.plugin.id" semantic conventions. It represents the plugin ID.
|
// "grafana.plugin.id" semantic conventions. It represents the plugin ID.
|
||||||
func GrafanaPluginId(val string) attribute.KeyValue {
|
func GrafanaPluginId(val string) attribute.KeyValue {
|
||||||
return GrafanaPluginIdKey.String(val)
|
return grafanaPluginIdKey.String(val)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
{%- macro to_go_attr_type(type, val) -%}
|
{%- macro to_go_attr_type(type, val) -%}
|
||||||
{{keyval_method(type)}}({% if type == "string" %}"{{val}}"{% else %}{{val}}{% endif %})
|
{{keyval_method(type)}}({% if type == "string" %}"{{val}}"{% else %}{{val}}{% endif %})
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
{%- macro to_private_go_name(fqn) -%}
|
||||||
|
{{fqn | replace(".", "_") | replace(" ", "") | to_camelcase }}
|
||||||
|
{%- endmacro -%}
|
||||||
{%- macro to_go_name(fqn) -%}
|
{%- macro to_go_name(fqn) -%}
|
||||||
{{fqn | replace(".", " ") | replace("_", " ") | title | replace(" ", "")}}
|
{{fqn | replace(".", " ") | replace("_", " ") | title | replace(" ", "")}}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
@ -74,7 +77,7 @@ Deprecated: {{ attr.brief | replace("Deprecated, ", "") }}
|
|||||||
// {{ to_go_name(attr.fqn) }} returns an attribute KeyValue conforming to the "{{ attr.fqn }}" semantic conventions. {{ it_reps(attr.brief) }}
|
// {{ to_go_name(attr.fqn) }} returns an attribute KeyValue conforming to the "{{ attr.fqn }}" semantic conventions. {{ it_reps(attr.brief) }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro to_go_func(type, name) -%}
|
{%- macro to_go_func(type, name, keyname) -%}
|
||||||
{%- if type == "string" -%}
|
{%- if type == "string" -%}
|
||||||
func {{name}}(val string) attribute.KeyValue {
|
func {{name}}(val string) attribute.KeyValue {
|
||||||
{%- elif type == "string[]" -%}
|
{%- elif type == "string[]" -%}
|
||||||
@ -92,7 +95,7 @@ func {{name}}(val bool) attribute.KeyValue {
|
|||||||
{%- elif type == "boolean[]" -%}
|
{%- elif type == "boolean[]" -%}
|
||||||
func {{name}}(val ...bool) attribute.KeyValue {
|
func {{name}}(val ...bool) attribute.KeyValue {
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
return {{name}}Key.{{keyval_method(type)}}(val)
|
return {{keyname}}Key.{{keyval_method(type)}}(val)
|
||||||
}
|
}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
{%- macro sentence_case(text) -%}
|
{%- macro sentence_case(text) -%}
|
||||||
@ -111,7 +114,7 @@ const (
|
|||||||
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated %}
|
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated %}
|
||||||
// {{ keydoc(attr) | wordwrap(72, break_long_words=false, break_on_hyphens=false, wrapstring="\n\t// ") }}
|
// {{ keydoc(attr) | wordwrap(72, break_long_words=false, break_on_hyphens=false, wrapstring="\n\t// ") }}
|
||||||
// {{ keydetails(attr) | wordwrap(72, break_long_words=false, break_on_hyphens=false, wrapstring="\n\t// ") }}
|
// {{ keydetails(attr) | wordwrap(72, break_long_words=false, break_on_hyphens=false, wrapstring="\n\t// ") }}
|
||||||
{{to_go_name(attr.fqn)}}Key = attribute.Key("{{attr.fqn}}")
|
{{to_private_go_name(attr.fqn)}}Key = attribute.Key("{{attr.fqn}}")
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
)
|
)
|
||||||
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated -%}
|
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated -%}
|
||||||
@ -124,7 +127,7 @@ var (
|
|||||||
//
|
//
|
||||||
// Deprecated: {{ attr.brief | replace("Deprecated, ", "") | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
|
// Deprecated: {{ attr.brief | replace("Deprecated, ", "") | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{{to_go_name("{}.{}".format(attr.fqn, val.member_id))}} = {{to_go_name(attr.fqn)}}Key.{{to_go_attr_type(attr.attr_type.enum_type, val.value)}}
|
{{to_go_name("{}.{}".format(attr.fqn, val.member_id))}} = {{to_private_go_name(attr.fqn)}}Key.{{to_go_attr_type(attr.attr_type.enum_type, val.value)}}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
)
|
)
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
@ -133,7 +136,7 @@ var (
|
|||||||
{%- if attr.attr_type is string %}
|
{%- if attr.attr_type is string %}
|
||||||
|
|
||||||
{{ fndoc(attr) | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
|
{{ fndoc(attr) | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
|
||||||
{{to_go_func(attr.attr_type, to_go_name(attr.fqn))}}
|
{{to_go_func(attr.attr_type, to_go_name(attr.fqn), to_private_go_name(attr.fqn))}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user