Skip to content
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

feat: project telemetry config models #1972

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jonaro00
Copy link
Member

No description provided.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces telemetry configuration models to support external telemetry sink integrations with Betterstack, Datadog, and Grafana Cloud services.

  • Added telemetry.rs with ProjectTelemetrySinkConfig enum for handling different telemetry provider configurations
  • Implemented From<Vec<ProjectTelemetrySinkConfig>> trait for safe display representation in ProjectTelemetryConfigResponse
  • Added TypeScript type definitions in types.ts with corresponding interfaces and discriminated unions for telemetry configurations

3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

common/src/models/telemetry.rs Outdated Show resolved Hide resolved
common/src/models/telemetry.rs Outdated Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

This PR updates the telemetry configuration models with improved field accessibility and enum handling patterns.

  • Made configuration fields public (pub) in BetterstackConfig, DatadogConfig, and GrafanaCloudConfig structs for external access
  • Added strum::AsRefStr derive macro to ProjectTelemetrySinkConfig enum for string conversion support
  • Simplified enum pattern matching from { .. } to (_) for cleaner code in From implementation

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

This PR adds the final touches to the telemetry configuration models with improved type safety and database integration.

  • Added #[typeshare::typeshare] attribute to all telemetry structs and enums for TypeScript type generation
  • Implemented as_db_type() method on ProjectTelemetrySinkConfig for database type string generation
  • Added TelemetrySinkStatus struct with enabled field for safe status representation

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +73 to +76
pub struct GrafanaCloudConfig {
pub token: String,
pub endpoint: String,
pub instance_id: String,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding validation for the endpoint URL and instance_id format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation can happen in backend handler if needed

common/src/models/telemetry.rs Show resolved Hide resolved
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

This PR updates the telemetry configuration models to ensure consistent naming conventions between Rust and TypeScript.

  • Changed TypeScript type discriminators in types.ts from PascalCase to snake_case for consistency with Rust enums
  • Added #[serde(rename_all = "snake_case")] to ensure consistent serialization across languages
  • Added #[strum(serialize_all = "snake_case")] for string conversion consistency

2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +293 to +300
/** The user-supplied config required to export telemetry to a given external sink */
export type ProjectTelemetrySinkConfig =
/** [Betterstack](https://betterstack.com/docs/logs/open-telemetry/) */
| { type: "betterstack", content: BetterstackConfig }
/** [Datadog](https://docs.datadoghq.com/opentelemetry/collector_exporter/otel_collector_datadog_exporter) */
| { type: "datadog", content: DatadogConfig }
/** [Grafana Cloud](https://grafana.com/docs/grafana-cloud/send-data/otlp/) */
| { type: "grafana_cloud", content: GrafanaCloudConfig };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Breaking change: changing type discriminators from PascalCase to snake_case will break existing API consumers. Consider versioning the API or coordinating with consumers before deploying.

Comment on lines +57 to +59
pub fn as_db_type(&self) -> String {
format!("project::telemetry::{}::config", self.as_ref())
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: as_db_type could panic if as_ref() returns an unexpected value. Consider using a match statement for exhaustive pattern matching.

Suggested change
pub fn as_db_type(&self) -> String {
format!("project::telemetry::{}::config", self.as_ref())
}
pub fn as_db_type(&self) -> String {
let sink_type = match self {
Self::Betterstack(_) => "betterstack",
Self::Datadog(_) => "datadog",
Self::GrafanaCloud(_) => "grafana_cloud",
};
format!("project::telemetry::{}::config", sink_type)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant