-
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.
- Loading branch information
1 parent
8c92dbd
commit 7455526
Showing
13 changed files
with
1,048 additions
and
991 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, "cloud-ui-telemetry", 1, 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
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
19 changes: 19 additions & 0 deletions
19
web-common/src/metrics/service/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,19 @@ | ||
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({ 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
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