Skip to content

Commit

Permalink
feat(telemetry): set otel service instance key id (#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzy89 authored Jun 25, 2024
1 parent 49fab4a commit 4f16ad3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions tm2/pkg/telemetry/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ var errEndpointNotSet = errors.New("telemetry exporter endpoint not set")

// Config is the configuration struct for the tm2 telemetry package
type Config struct {
MetricsEnabled bool `json:"enabled" toml:"enabled"`
MeterName string `json:"meter_name" toml:"meter_name"`
ServiceName string `json:"service_name" toml:"service_name"`
ExporterEndpoint string `json:"exporter_endpoint" toml:"exporter_endpoint" comment:"the endpoint to export metrics to, like a local OpenTelemetry collector"`
MetricsEnabled bool `json:"enabled" toml:"enabled"`
MeterName string `json:"meter_name" toml:"meter_name"`
ServiceName string `json:"service_name" toml:"service_name"`
ServiceInstanceID string `json:"service_instance_id" toml:"service_instance_id" comment:"the ID helps to distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled service)"`
ExporterEndpoint string `json:"exporter_endpoint" toml:"exporter_endpoint" comment:"the endpoint to export metrics to, like a local OpenTelemetry collector"`
}

// DefaultTelemetryConfig is the default configuration used for the node
func DefaultTelemetryConfig() *Config {
return &Config{
MetricsEnabled: false,
MeterName: "gno.land",
ServiceName: "gno.land",
ExporterEndpoint: "",
MetricsEnabled: false,
MeterName: "gno.land",
ServiceName: "gno.land",
ServiceInstanceID: "gno-node-1",
ExporterEndpoint: "",
}
}

Expand Down
2 changes: 1 addition & 1 deletion tm2/pkg/telemetry/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func Init(config config.Config) error {
semconv.SchemaURL,
semconv.ServiceNameKey.String(config.ServiceName),
semconv.ServiceVersionKey.String("1.0.0"),
semconv.ServiceInstanceIDKey.String("gno-node-1"),
semconv.ServiceInstanceIDKey.String(config.ServiceInstanceID),
),
),
)
Expand Down

0 comments on commit 4f16ad3

Please sign in to comment.