toggly 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +34 -2
- data/lib/toggly/client/cache_telemetry.rb +36 -0
- data/lib/toggly/client/snapshot_support.rb +38 -0
- data/lib/toggly/client.rb +173 -51
- data/lib/toggly/config.rb +39 -1
- data/lib/toggly/definition_cache.rb +78 -0
- data/lib/toggly/definitions_provider.rb +72 -18
- data/lib/toggly/telemetry/grpc_clients.rb +333 -0
- data/lib/toggly/telemetry/metrics_batcher.rb +140 -0
- data/lib/toggly/telemetry/pb/metrics_pb.rb +28 -0
- data/lib/toggly/telemetry/pb/metrics_services_pb.rb +28 -0
- data/lib/toggly/telemetry/pb/usage_pb.rb +27 -0
- data/lib/toggly/telemetry/pb/usage_services_pb.rb +28 -0
- data/lib/toggly/telemetry/runtime.rb +262 -0
- data/lib/toggly/telemetry/runtime_flush.rb +89 -0
- data/lib/toggly/telemetry/usage_batcher.rb +277 -0
- data/lib/toggly/telemetry.rb +37 -0
- data/lib/toggly/version.rb +1 -1
- data/lib/toggly.rb +2 -0
- data/proto/metrics.proto +60 -0
- data/proto/usage.proto +55 -0
- metadata +18 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "telemetry/grpc_clients"
|
|
4
|
+
require_relative "telemetry/usage_batcher"
|
|
5
|
+
require_relative "telemetry/metrics_batcher"
|
|
6
|
+
require_relative "telemetry/runtime"
|
|
7
|
+
|
|
8
|
+
module Toggly
|
|
9
|
+
# Usage and business-metrics telemetry (optional gRPC transport).
|
|
10
|
+
module Telemetry
|
|
11
|
+
DEFAULT_METRICS_BASE_URL = GrpcClients::DEFAULT_METRICS_BASE_URL
|
|
12
|
+
DEFAULT_TELEMETRY_FLUSH_SECONDS = GrpcClients::DEFAULT_TELEMETRY_FLUSH_SECONDS
|
|
13
|
+
GRPC_USER_AGENT_METADATA_KEY = GrpcClients::GRPC_USER_AGENT_METADATA_KEY
|
|
14
|
+
|
|
15
|
+
module_function
|
|
16
|
+
|
|
17
|
+
def hash_identity(identity)
|
|
18
|
+
GrpcClients.hash_identity(identity)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def feature_stat_from_payload(payload)
|
|
22
|
+
GrpcClients.feature_stat_from_payload(payload)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def metric_stat_from_payload(payload)
|
|
26
|
+
GrpcClients.metric_stat_from_payload(payload)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def grpc_available?
|
|
30
|
+
GrpcClients.grpc_available?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def resolve_user_agent(override = nil)
|
|
34
|
+
GrpcClients.resolve_user_agent(override)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/toggly/version.rb
CHANGED
data/lib/toggly.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "toggly/version"
|
|
4
|
+
require_relative "toggly/telemetry"
|
|
4
5
|
require_relative "toggly/config"
|
|
5
6
|
require_relative "toggly/request_context"
|
|
6
7
|
require_relative "toggly/http_request_mapper"
|
|
@@ -30,6 +31,7 @@ require_relative "toggly/evaluation_engine"
|
|
|
30
31
|
require_relative "toggly/snapshot_providers/base"
|
|
31
32
|
require_relative "toggly/snapshot_providers/memory"
|
|
32
33
|
require_relative "toggly/snapshot_providers/file"
|
|
34
|
+
require_relative "toggly/definition_cache"
|
|
33
35
|
require_relative "toggly/definitions_provider"
|
|
34
36
|
require_relative "toggly/client"
|
|
35
37
|
|
data/proto/metrics.proto
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package Metrics;
|
|
4
|
+
|
|
5
|
+
option go_package = "github.com/ops-ai/Toggly.FeatureManagement/toggly-go/toggly/metrics/metricspb";
|
|
6
|
+
|
|
7
|
+
import "google/protobuf/timestamp.proto";
|
|
8
|
+
|
|
9
|
+
message MetricStat {
|
|
10
|
+
string appKey = 1;
|
|
11
|
+
string environment = 2;
|
|
12
|
+
google.protobuf.Timestamp time = 3;
|
|
13
|
+
repeated MetricStatMessage stats = 4;
|
|
14
|
+
repeated MetricCounterMessage counters = 5;
|
|
15
|
+
repeated MetricObservationMessage observations = 6;
|
|
16
|
+
optional string instanceName = 7;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message MetricStatMessage {
|
|
20
|
+
string metric = 1;
|
|
21
|
+
int32 enabledCount = 2 [deprecated = true];
|
|
22
|
+
int32 disabledCount = 3 [deprecated = true];
|
|
23
|
+
optional string feature = 4;
|
|
24
|
+
double value = 5 [deprecated = true];
|
|
25
|
+
optional double valueDisabled = 6 [deprecated = true];
|
|
26
|
+
|
|
27
|
+
// Multi-variate support - Key: variant name (e.g., "enabled", "control")
|
|
28
|
+
map<string, double> variantValues = 7;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message MetricCounterMessage {
|
|
32
|
+
string metric = 1;
|
|
33
|
+
int32 enabledCount = 2 [deprecated = true];
|
|
34
|
+
int32 disabledCount = 3 [deprecated = true];
|
|
35
|
+
optional string feature = 4;
|
|
36
|
+
double value = 5 [deprecated = true];
|
|
37
|
+
optional double valueDisabled = 6 [deprecated = true];
|
|
38
|
+
|
|
39
|
+
map<string, double> variantValues = 7;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message MetricObservationMessage {
|
|
43
|
+
google.protobuf.Timestamp time = 1;
|
|
44
|
+
string metric = 2;
|
|
45
|
+
int32 enabledCount = 3 [deprecated = true];
|
|
46
|
+
int32 disabledCount = 4 [deprecated = true];
|
|
47
|
+
optional string feature = 5;
|
|
48
|
+
double value = 6 [deprecated = true];
|
|
49
|
+
optional double valueDisabled = 7 [deprecated = true];
|
|
50
|
+
|
|
51
|
+
map<string, double> variantValues = 8;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
message MetricResult {
|
|
55
|
+
int32 count = 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
service Metrics {
|
|
59
|
+
rpc SendMetrics(MetricStat) returns (MetricResult);
|
|
60
|
+
}
|
data/proto/usage.proto
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package Usage;
|
|
4
|
+
|
|
5
|
+
option go_package = "github.com/ops-ai/Toggly.FeatureManagement/toggly-go/toggly/usage/usagepb";
|
|
6
|
+
|
|
7
|
+
import "google/protobuf/timestamp.proto";
|
|
8
|
+
|
|
9
|
+
message FeatureStat {
|
|
10
|
+
string appKey = 1;
|
|
11
|
+
string environment = 2;
|
|
12
|
+
google.protobuf.Timestamp time = 3;
|
|
13
|
+
repeated StatMessage stats = 4;
|
|
14
|
+
int32 totalUniqueUsers = 5;
|
|
15
|
+
optional string instanceName = 6;
|
|
16
|
+
optional google.protobuf.Timestamp processStartTime = 7;
|
|
17
|
+
optional string appVersion = 8;
|
|
18
|
+
repeated int32 uniqueUserHashes = 9; // Application-level unique user ID hashes
|
|
19
|
+
optional int32 definitionCacheHits = 10; // SDK-reported definition-refresh cache hits (batch delta)
|
|
20
|
+
optional int32 definitionCacheMisses = 11; // SDK-reported definition-refresh cache misses (batch delta)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message StatMessage {
|
|
24
|
+
string feature = 1;
|
|
25
|
+
int32 enabledCount = 2 [deprecated = true]; // Legacy: use variantStats instead
|
|
26
|
+
int32 disabledCount = 3 [deprecated = true]; // Legacy: use variantStats instead
|
|
27
|
+
int32 uniqueContextIdentifierEnabledCount = 4;
|
|
28
|
+
int32 uniqueContextIdentifierDisabledCount = 5;
|
|
29
|
+
int32 uniqueRequestEnabledCount = 6 [deprecated = true]; // Legacy: use variantStats instead
|
|
30
|
+
int32 uniqueRequestDisabledCount = 7 [deprecated = true]; // Legacy: use variantStats instead
|
|
31
|
+
int32 usedCount = 8 [deprecated = true]; // Legacy: use variantStats instead
|
|
32
|
+
int32 uniqueUsersUsedCount = 9;
|
|
33
|
+
repeated int32 uniqueUserHashes = 10; // Unique user ID hashes for "used" tracking
|
|
34
|
+
|
|
35
|
+
// Multi-variate support - all new metrics should use this
|
|
36
|
+
map<string, VariantStats> variantStats = 11; // Key: variant name (e.g., "enabled", "disabled")
|
|
37
|
+
|
|
38
|
+
// Unique user tracking for "viewed" metric (per feature, not per variant)
|
|
39
|
+
repeated int32 uniqueViewedUserHashes = 12;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message VariantStats {
|
|
43
|
+
int32 checkCount = 1;
|
|
44
|
+
int32 requestCount = 2;
|
|
45
|
+
int32 usedCount = 3;
|
|
46
|
+
int32 viewedCount = 4;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
message StatResult {
|
|
50
|
+
int32 featureCount = 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
service Usage {
|
|
54
|
+
rpc SendStats(FeatureStat) returns (StatResult);
|
|
55
|
+
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: toggly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ops.ai
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: High-performance Ruby SDK for Toggly feature flag management. Works with
|
|
14
14
|
or without Toggly.io.
|
|
@@ -23,8 +23,11 @@ files:
|
|
|
23
23
|
- README.md
|
|
24
24
|
- lib/toggly.rb
|
|
25
25
|
- lib/toggly/client.rb
|
|
26
|
+
- lib/toggly/client/cache_telemetry.rb
|
|
27
|
+
- lib/toggly/client/snapshot_support.rb
|
|
26
28
|
- lib/toggly/config.rb
|
|
27
29
|
- lib/toggly/context.rb
|
|
30
|
+
- lib/toggly/definition_cache.rb
|
|
28
31
|
- lib/toggly/definitions_provider.rb
|
|
29
32
|
- lib/toggly/entity_context.rb
|
|
30
33
|
- lib/toggly/errors.rb
|
|
@@ -52,8 +55,20 @@ files:
|
|
|
52
55
|
- lib/toggly/snapshot_providers/file.rb
|
|
53
56
|
- lib/toggly/snapshot_providers/memory.rb
|
|
54
57
|
- lib/toggly/sticky_hash.rb
|
|
58
|
+
- lib/toggly/telemetry.rb
|
|
59
|
+
- lib/toggly/telemetry/grpc_clients.rb
|
|
60
|
+
- lib/toggly/telemetry/metrics_batcher.rb
|
|
61
|
+
- lib/toggly/telemetry/pb/metrics_pb.rb
|
|
62
|
+
- lib/toggly/telemetry/pb/metrics_services_pb.rb
|
|
63
|
+
- lib/toggly/telemetry/pb/usage_pb.rb
|
|
64
|
+
- lib/toggly/telemetry/pb/usage_services_pb.rb
|
|
65
|
+
- lib/toggly/telemetry/runtime.rb
|
|
66
|
+
- lib/toggly/telemetry/runtime_flush.rb
|
|
67
|
+
- lib/toggly/telemetry/usage_batcher.rb
|
|
55
68
|
- lib/toggly/user_agent_parser.rb
|
|
56
69
|
- lib/toggly/version.rb
|
|
70
|
+
- proto/metrics.proto
|
|
71
|
+
- proto/usage.proto
|
|
57
72
|
homepage: https://toggly.io
|
|
58
73
|
licenses:
|
|
59
74
|
- MIT
|
|
@@ -63,7 +78,7 @@ metadata:
|
|
|
63
78
|
changelog_uri: https://github.com/ops-ai/toggly-ruby/blob/main/CHANGELOG.md
|
|
64
79
|
documentation_uri: https://docs.toggly.io/sdks/ruby
|
|
65
80
|
rubygems_mfa_required: 'true'
|
|
66
|
-
optional_dependencies: websocket-client-simple
|
|
81
|
+
optional_dependencies: websocket-client-simple, grpc, google-protobuf
|
|
67
82
|
post_install_message:
|
|
68
83
|
rdoc_options: []
|
|
69
84
|
require_paths:
|