-
-
Notifications
You must be signed in to change notification settings - Fork 32
Feature - OpenTelemetry support #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - OpenTelemetry support #92
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is great. Just a few minor suggestions.
I really need to have been organizing the code better with not so many things in the main
package. Do you mind putting your new files in an otel
package similar to slp
?
opentelemetry_metrics.go
Outdated
func (m *serverMetrics) RecordResponseTime(responseTime float64, attributes []attribute.KeyValue) { | ||
_, err := meter.Float64ObservableGauge( | ||
"minecraft_status_response_time", | ||
metric.WithDescription("The response time of the server"), | ||
metric.WithUnit("ms"), | ||
metric.WithFloat64Callback( | ||
func(ctx context.Context, observer metric.Float64Observer) error { | ||
observer.Observe(responseTime, metric.WithAttributes(attributes...)) | ||
return nil | ||
}, | ||
), | ||
) | ||
handleError("Error creating response time metric", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a fair amount of repetition across these methods. Would be nice to have a consolidated method that takes the necessary differences like the name and description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a new commit trying to reduce the verbosity, at least creating a method that handles the description and other options.
Also, changed the type for minecraft_players_online_count
and minecraft_players_max_count
, that were using Float64. It makes more sense to use Int64.
Sure! I'll move these OTel implementations into a separate package. Even being a small implementation, I'm missing some unit tests just to make sure that future changes won't break anything 😬 Once this PR is merged I can work on separating Telegraf and Prometheus into their own packages also. ;) |
…for common resources. Deprecate shared resources from main package
otel/metrics.go
Outdated
} | ||
|
||
func (m *serverMetrics) RecordHealth(healthy bool, attributes []attribute.KeyValue) { | ||
_ = NewInt64ObservableGauge( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking it's better not to return the gauge from the new functions if it's always ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. We're not using for now and I think it will not have any use in the future!
Co-authored-by: Geoff Bourne <[email protected]>
Description
This PR adds support to export metrics through Open Telemetry protocol, which makes it easier to handle the generated data and process it by using multiple backends.
At first, this will export the same metrics that are currently being exported for Telegraf or Prometheus:
minecraft_status_healthy
minecraft_status_response_time_seconds
minecraft_status_players_online_count
minecraft_status_players_max_count
However, I'll be looking for other possibilites and other metrics to gather, since they always can be useful for monitoring a server.
Next steps
In the future, I feel excited about expanding the telemetry support for mc-monitor, so we can be able to export other signals like logs or even traces (if we think that this can be useful at all).
Since this is my very first contribution for itzg/minecraft projects, I'm very open for any comments or suggestions!
Thanks in advance.