-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding cloud error telemetry * Revert server changes * Updating to use the new endpoint * PR comments * PR comments * Add org id
- Loading branch information
1 parent
44dd0f5
commit a5086e0
Showing
20 changed files
with
1,350 additions
and
978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package server | ||
|
||
import ( | ||
"context" | ||
|
||
adminv1 "github.com/rilldata/rill/proto/gen/rill/admin/v1" | ||
"go.opentelemetry.io/otel/attribute" | ||
) | ||
|
||
func (s *Server) Telemetry(ctx context.Context, req *adminv1.TelemetryRequest) (*adminv1.TelemetryResponse, error) { | ||
dims := make([]attribute.KeyValue, 0) | ||
for k, v := range req.Event.AsMap() { | ||
a, ok := toKeyValue(k, v) | ||
if ok { | ||
dims = append(dims, a) | ||
} | ||
} | ||
s.uiActivity.Emit(ctx, req.Name, float64(req.Value), dims...) | ||
return &adminv1.TelemetryResponse{}, nil | ||
} | ||
|
||
func toKeyValue(k string, v interface{}) (attribute.KeyValue, bool) { | ||
switch vt := v.(type) { | ||
case string: | ||
return attribute.String(k, vt), true | ||
case bool: | ||
return attribute.Bool(k, vt), true | ||
case int: | ||
return attribute.Int(k, vt), true | ||
case int64: | ||
return attribute.Int64(k, vt), true | ||
case float64: | ||
return attribute.Float64(k, vt), true | ||
} | ||
|
||
return attribute.KeyValue{}, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
web-admin/src/features/telemetry/RillAdminTelemetryClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ADMIN_URL } from "@rilldata/web-admin/client/http-client"; | ||
import type { MetricsEvent } from "@rilldata/web-common/metrics/service/MetricsTypes"; | ||
import type { TelemetryClient } from "@rilldata/web-common/metrics/service/RillIntakeClient"; | ||
|
||
export class RillAdminTelemetryClient implements TelemetryClient { | ||
public async fireEvent(event: MetricsEvent) { | ||
try { | ||
const resp = await fetch(`${ADMIN_URL}/v1/telemetry`, { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
name: event.app_name + "-ui-telemetry", | ||
value: 1, | ||
event, | ||
}), | ||
credentials: "include", | ||
}); | ||
if (!resp.ok) | ||
console.error(`Failed to send ${event.event_type}. ${resp.statusText}`); | ||
} catch (err) { | ||
console.error(`Failed to send ${event.event_type}. ${err.message}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { RillAdminTelemetryClient } from "@rilldata/web-admin/features/telemetry/RillAdminTelemetryClient"; | ||
import { collectCommonUserFields } from "@rilldata/web-common/metrics/collectCommonUserFields"; | ||
import { ErrorEventHandler } from "@rilldata/web-common/metrics/ErrorEventHandler"; | ||
import { | ||
metricsService, | ||
setErrorEvent, | ||
setMetricsService, | ||
} from "@rilldata/web-common/metrics/initMetrics"; | ||
import { BehaviourEventFactory } from "@rilldata/web-common/metrics/service/BehaviourEventFactory"; | ||
import { ErrorEventFactory } from "@rilldata/web-common/metrics/service/ErrorEventFactory"; | ||
import { MetricsService } from "@rilldata/web-common/metrics/service/MetricsService"; | ||
import { ProductHealthEventFactory } from "@rilldata/web-common/metrics/service/ProductHealthEventFactory"; | ||
|
||
export async function initCloudMetrics() { | ||
setMetricsService( | ||
new MetricsService(new RillAdminTelemetryClient(), [ | ||
new ProductHealthEventFactory(), | ||
new BehaviourEventFactory(), | ||
new ErrorEventFactory(), | ||
]) | ||
); | ||
|
||
const commonUserMetrics = await collectCommonUserFields(); | ||
setErrorEvent(new ErrorEventHandler(metricsService, commonUserMetrics)); | ||
// TODO: add other handlers and callers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a5086e0
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.
🎉 Published on https://ui.rilldata.io as production
🚀 Deployed on https://65672add3970d1085142ec10--rill-ui-stage.netlify.app